Help needed with Global, Frame, Extension Template

Hi,

I hope someone can help me please.
I am trying to make a Template with various options.

What I am trying to do is the following:

  1. When I add the Global Template it must Automatically add the Extension Template to the FRAME Procedure if it exists and %AddMyTemplateTagToFrameProcedure is Ticked.
  2. When I add the Global Template it must Automatically add the Extension Template to all the Windows Procedures if %AddMyTemplateTagWindows is Ticked.
  3. If %AddMyTemplateTagWindows is not Ticked then it should not Automatically add the Extentions Template to all the Windows, I will then add it myself only to the Windows where I need it.

The problem at this stage is that when I add the Global Template:

  1. it does not Automatically add the Extension Template to the FRAME Procedure
  2. it Automatically add the Extension Template to all the Windows Procedures
  3. I am not sure how to use/implement the %AddMyTemplateTagToFrameProcedure and %AddMyTemplateTagWindows options

Another problem I can’t get sorted is how to use the %MyTemplateTagTPLVersion on the Extension Templates Descriptions to display the Version.
At this stage I have to manually change the version text on the Descriptions of the Extension Templates

Any help, guidance, advice would be appreciated.

Regards

Johan de Klerk

#! My Template
#!------------------------------------------------------------------------------
#TEMPLATE(MyTemplateTag,‘Template that applies My Template to every window’),FAMILY(‘abc’)
#!------------------------------------------------------------------------------
#System
#EQUATE(%MyTemplateTagTPLVersion,‘1.00’)
#!------------------------------------------------------------------------------
#Extension(ActivateMyTemplateTag,‘Activate My Template - Global 1.00’),Application(LocalMyTemplateTag(MyTemplateTag))
#SHEET
#TAB(‘Functions’)
#BOXED(’’)
#DISPLAY(‘My Template Version ‘& %MyTemplateTagTPLVersion)
#DISPLAY(’’)
#Prompt(‘Disable My Template in this application.’,Check),%GloDisableMyTemplateTag,At(10)
#Display(‘No My Template code will be generated.’)
#Display(’’)
#Prompt(‘Automatically Add Extension Template to Frame.’,Check),%AddMyTemplateTagToFrameProcedure,DEFAULT(%True),At(10)
#Prompt(‘Automatically Add Extension Template to all Windows’,Check),%AddMyTemplateTagWindows,DEFAULT(%False),At(10)
#Display(’’)
#ENDBOXED
#ENDTAB
#TAB(‘About’)
#BOXED(’’)
#DISPLAY(‘My Template Version ‘& %MyTemplateTagTPLVersion)
#DISPLAY(‘32 Bit only’)
#DISPLAY(’’)
#ENDBOXED
#ENDTAB
#ENDSHEET
#!#################################################################################################
#! End of GLOBAL EXTENSION
#!#################################################################################################
#AT(%GlobalData),Where(%GloDisableMyTemplateTag=0 and %ProgramExtension=‘EXE’ and %AppTemplateFamily=‘ABC’),DESCRIPTION(‘Declare My Template Global Variables’)
#INSERT(%MyTemplateTagGlobalData)
#ENDAT
#!------------------------------------------------------------------------------
#Extension(LocalFrameMyTemplateTag,‘My Template Frame Object - Local 1.00’),Procedure,req(ActivateMyTemplateTag(MyTemplateTag))
#RESTRICT,WHERE(UPPER(%ProcedureTemplate)=‘FRAME’)
#ENDRESTRICT
#BOXED(’’)
#DISPLAY(‘My Template Version ‘& %MyTemplateTagTPLVersion),At(10,4)
#DISPLAY(’’)
#Prompt(‘Disable My Template in this Procedure.’,Check),%DisableMyTemplateTagLocalFrame,At(10,16)
#DISPLAY(’’)
#ENDBOXED
#AT(%WindowManagerMethodCodeSection, ‘Init’, ‘(),BYTE’),LAST,WHERE(%GloDisableMyTemplateTag=0 and %DisableMyTemplateTagLocalFrame=0 and %ProgramExtension=‘EXE’ and %AppTemplateFamily=‘ABC’),DESCRIPTION(‘Declare My Template Init’),Priority(8001)
#INSERT(%MyTemplateTagFrameAfterOpenWindow)
#ENDAT
#!------------------------------------------------------------------------------
#Extension(LocalMyTemplateTag,‘My Template Object - Local 1.00’),Procedure,req(ActivateMyTemplateTag(MyTemplateTag))
#RESTRICT,WHERE(~EXTRACT(%WindowStatement,‘MDI’))
#ENDRESTRICT
#RESTRICT,WHERE(UPPER(%ProcedureTemplate)<>‘FRAME’)
#ENDRESTRICT
#RESTRICT,WHERE(UPPER(%ProcedureTemplate)<>‘SOURCE’)
#ENDRESTRICT
#RESTRICT,WHERE(UPPER(%ProcedureTemplate)<>‘REPORT’)
#ENDRESTRICT
#RESTRICT,WHERE(UPPER(%ProcedureTemplate)<>‘EXTERNAL’)
#ENDRESTRICT
#RESTRICT,WHERE(UPPER(%ProcedureTemplate)<>‘MENU’)
#ENDRESTRICT
#BOXED(’’)
#DISPLAY(‘My Template Version ‘& %MyTemplateTagTPLVersion),At(10,4)
#DISPLAY(’’)
#Prompt(‘Disable My Template in this Procedure.’,Check),%DisableMyTemplateTagLocal,At(10,16)
#DISPLAY(’’)
#ENDBOXED
#AT(%WindowManagerMethodCodeSection, ‘Init’, ‘(),BYTE’),LAST,WHERE(%GloDisableMyTemplateTag=0 and %DisableMyTemplateTagLocal=0 and %AppTemplateFamily=‘ABC’),DESCRIPTION(‘Declare My Template Init’),Priority(8001)
#INSERT(%MyTemplateTagAfterOpenWindow)
#ENDAT
#AT(%ProcedureRoutines,’()’),LAST,WHERE(%GloDisableMyTemplateTag=0 and %DisableMyTemplateTagLocal=0 and %AppTemplateFamily=‘ABC’),DESCRIPTION(‘Declare My Template Routine’),Priority(8001)
#INSERT(%MyTemplateTagProcedureRoutines)
#ENDAT

#!------------------------------------------------------------------------------
#GROUP(%MyTemplateTagGlobalData)
!Start My Template - Global Data
!Insert Global Variables here
!End My Template - Global Data
#!------------------------------------------------------------------------------
#GROUP(%MyTemplateTagFrameAfterOpenWindow)
!Start My Template - Frame WindowManagerMethodCodeSection Init
!Insert Local Variables here
!End My Template - Frame WindowManagerMethodCodeSection Init
#!------------------------------------------------------------------------------
#GROUP(%MyTemplateTagAfterOpenWindow)
!Start My Template - Window WindowManagerMethodCodeSection Init
DO MyTemplateTag
!End My Template - Window WindowManagerMethodCodeSection Init
#!------------------------------------------------------------------------------
#GROUP(%MyTemplateTagProcedureRoutines)
!Start My Template - Procedure Routines
MyTemplateTag ROUTINE
!Insert Code Here
!End My Template - Window Procedure Routines

With all template questions I always recommend examining existing (ideally small) 3rd party templates that do similar to what you want to see how they do it.

  • When I add the Global Template it must Automatically add the Extension Template to the FRAME Procedure if it exists and %AddMyTemplateTagToFrameProcedure is Ticked.

You are thinking of this backwards. The global template will add the local template.
Then whether the local template generates any code depends on the global setting.
In other words don’t try and “populate or not populate” the local extension. Rather set the local extension to generate, or not generate code.

For example in all our templates we have a global “disable” switch and a local “disable” switch. The templates remain, but what they generate depends on these switches.

  • When I add the Global Template it must Automatically add the Extension Template to all the Windows Procedures if %AddMyTemplateTagWindows is Ticked.

Same as above. Except that the global extension only adds one child template. So your one child template needs to cater for the frame case and the window case. It detects what case it’s on and generates the appropriate code.

  • If %AddMyTemplateTagWindows is not Ticked then it should not Automatically add the Extentions Template to all the Windows, I will then add it myself only to the Windows where I need it.

Probably in this situation you need a second global extension. In my case I have the main global that doesn’t add children, but then a second global (that “requires the first”) which does. See like say the Draw and Draw header global extensions. The second global auto-adds the children so a user can use that, or not, as they prefer.

Cheers
Bruce