Template vs. Hand Code

Every time I try to insert code into a menu option in the Frame, the Clarion environment gets stuck in a loop. I decided to copy the code generated by the Templates system and create a procedure manually.

I’m running into something strange, but it’s not that it can’t be fixed; I just don’t understand what’s happening.

The following is the declaration that the Clarion ABC template makes of ThisWindow. But to see the generated code there are other methods (procedures). The amazing thing is that it compiles the generated code, but obviously, it doesn’t compile the manually created code.
I come across methods like DeleteAction, Init, etc.

Where’s the magic?

ThisWindow           CLASS(WindowManager)
Ask                     PROCEDURE(),DERIVED
ChangeAction            PROCEDURE(),BYTE,DERIVED
OnCloseEventCancelled   PROCEDURE(),DERIVED
PrimeUpdate             PROCEDURE(),BYTE,PROC,DERIVED
Reset                   PROCEDURE(BYTE Force=0),DERIVED
Run                     PROCEDURE(),BYTE,PROC,DERIVED
SetAlerts               PROCEDURE(),DERIVED
TakeAccepted            PROCEDURE(),BYTE,PROC,DERIVED
TakeDisableButton       PROCEDURE(SIGNED Control,BYTE MakeDisable),DERIVED
TakeEvent               PROCEDURE(),BYTE,PROC,DERIVED
Update                  PROCEDURE(),DERIVED
                     END
                     

Where are you inserting it?
From the menu editor? In the Embed tree? Or in the Embeditor?

I’ve found that the embeditor is the most reliable place to embed code. I seldome embed code elsewhere.

1 Like

You are confusing “potentially generated code” which you’ll see in the embeditor (“source”) with the actual generated code, whch you’ll see in the actual CLW (“module”).

2 Likes

I found a better explanation:

You’re right, there is a significant difference between the generated code shown in the ‘Filled / Source’ view and what is actually written to the ‘Module Source File’. This discrepancy becomes much more apparent when the ‘Generate Template Globals and ABC as External’ option is selected.

This and the fact that you found differences between “Embeditor Source” and “Module source file” are different things.

The “Generate Template Globals and ABC as External” is used when you work with multiple DLL’s and all the global dat is defined in a special DLL, the Data DLL. That DLL exports all global data to the other DLL’s. The other DLL’s “read” those exports hence there is no need to generate it themselves. There is what is this option for. And yes it makes a difference what code is generated but that is not related to the “Embeditor Source”.

The “Embeditor Source” contains all the code that can but not must be generated. Like Bruce said “potentially generated code”. For example the SetAlerts() procedure is visible in the CLASS section (as a derived method) and also as an embed further down the code. But if you not fill that embed there is no need to derive the method so it will not be generated in the class list. The actual generated code will be in the “Module source file”.

To get on your original problem. I would make a (source) procedure with the things you need to be done. Then call (or start?) that procedure from your menu item. That should work.

2 Likes