Translating messages in STDFunc.tpw with a template

Hi All,

I am working on a migration from Clarion 6 to Clarion 11.This is legacy. The problem is that a lot of the shipping templates are modified in Clarion 6. I try to avoid that in Clarion 11.

One modified template is STDFunc.tpw. The modifications done are just translations of the error messages into Dutch. Is there some way to make these translations without modifying the shipping template?

One solution there might be is using the embed:
#EMBED (%BeforeStandardWarningCase, 'Before Standard Warning'), HIDE
which is just before the generated case structure which must be translated into Dutch. If I can place my own
case structure here that would be a solution.
Is this possible and if so how van I do that?But that is just an idea, no clue how I can do that?

Koen Tjoa
The Netherlands

Yes with an #EXTENSION(),APPLICATION (a Global Extension)
that has an

    Your  Spreek je Nederlands message code

I suggest adding MsgMode CanCopy to the messages so the user can copy content.

Thanks, I didn’t think of creating an extension template. At first I was hoping to get my code in the generated standard function files (‘appname_sf.clw’) but that seems hard to do. Your suggestion is much easier.

Well I tried with a global extension template like you suggested but that didn’t work out. The code in my extension template is not added at all.

I investigated the CW.tpl file to see when the template code in STDFunc.tpw is called with #INSERT(%GenerateStandardFunctions).
I think that try to add code in the won’t work because the .clw is already created before my extension template comes into scope.

For now I accept that I have to make some modifications in the shipping Clarion templates to get my translations done. Or there must be a solution I overlooked.

Koen Tjoa
The Netherlands

Some changes I made in StdFunc.TPW

In 8 places CheckOpen() passes NAME(File) as in StandardWarning(Warn:xxx, NAME(File)) so you know what file caused the error.

Problem is sometimes the File Name Name(var) is blank (a bug) so the Warning Message file name is blank, which makes it almost impossible to find the problem. In CheckOpen() I changed so if the Name(File) is blank then I show “Alternative Text”. I created a variable NameOfFile and use that in place of Name(File) in those 8 places.

There is no way I know of to get the Label of the File so my “Alternative Text” is File{Prop:Label,1} i.e. the Label of the 1st Field. That way you at least get a Prefix so should have an idea of the file.

Here’s the CheckOpen first few lines of code.

CheckOpen         PROCEDURE(FILE File,<BYTE OverrideCreate>,<BYTE OverrideOpenMode>)
OpenMode          BYTE
NameOfFile PSTRING(256),AUTO !Name(File) or Prop:Label     #! Carl added
  #! Carl Show 1st field Label if Name is blank (until SV fixes F{Prop:Label})
  NameOfFile=CLIP(CHOOSE(~NAME(File),'Name=Blank [' & File{Prop:Label,1} &']',NAME(File)))
  #EMBED(%CheckOpenSetup,'CheckOpen: Setup Procedure')

The CHOOSE(~Name...) checks if there’s a blank NAME() then uses File{Prop:Label,1} formatted as: Name=Blank [Pre:LabelField1] e.g. Name=Blank [Cus:AutoNo]

Next change the 8 calls that pass NAME(File) to variable NameOfFile - e.g.:

Old: IF StandardWarning(Warn:CreateError,NAME(File)).  !Name() could be blank
New: IF StandardWarning(Warn:CreateError,NameOfFile).  !Carl New code

There is a bug in OF Warn:BadKeyedRec that there is a missing comma. The Icon ends up in the Caption and the Button in the Icon. Plus the language refers to “Insert Aborted” when it’s a “'Read Failed”. Here’s the old and my fixed code:

  OF Warn:BadKeyedRec
     RETURN(MESSAGE('Unable to read keyed record.  Error: ' |
Old:  & CLIP(ErrorText) & '.  Insert Aborted',ICON:Exclamation,|
Fix:  & CLIP(ErrorText)  , 'Read Failed'     ,ICON:Exclamation,|

All the message code ends with “,0)” which can be changed to “,MSGMODE:CANCOPY)” so the user can copy the message text:

Old:   Button:OK,Button:OK,0))
New:   Button:OK,Button:OK,MSGMODE:CANCOPY))

In which version did you make this modifications? It looks to me as good modifications.

But my problem is that I am in a process of a migration from Clarion 6 to Clarion 11 where a lot a lot of the shipping templates are modified in Clarion 6. All these modifications hold back the migration to Clarion 9 - 11 for years. In the ideal situation all these modifications are undone and moved to our own templates. That makes it easier to migrate to new builds without the need to modify the shipping templates over and over again.

On the other hand I realize that some modifications are unavoidable like your improvements above and as it appears to be the translations I need.

Very helpful, thank you!

I’ve made these changes in 9, 10 and 11.

The Legacy templates do not change that much, and there are not that many releases, so it is hard to keep up with.

I keep a “Clean” install (unmodified) of each release so that I can compare the Clean install for changes by SV. Usually there are none so I can copy my modified TPWs. I also do a compare of CLWs after building with the new release to see if the generated code changed. Source control and compare are so useful.

To get all the generated code to work the desired way it is worth making a few template changes, and repeat them on releases.

I agree, but the problem I am working on a conversion where a lot of lot of (not documented) changes are done in the C6 templates and also in some source files. Not all of them are still needed. Right now I am in the process of removing unneeded changes and put as much as possible in separate .tpw files. The idea for that latter thing is the at the end I only need to modify the CW.tpl file at the end by adding a few #INCLUDE(MyTemplate.tpw) lines.

Of course some modifications must be done in the shipping template but I trying to keep that to a minimum.
The C9/C10/C11 legacy templates might not differ much, as far as I can see the C6 do a bit more. And it will make future upgrades a bit easier.

BTW: BeyondCompare is my friend in this.