How to tell if a Template is ABC or Clarion

Hello,

I have a simple question, since I can not find the answer in Clarion help file.

How does Clarion know which template is ABC and which is Clarion (legacy)?

If I have some procedure #PROCEDURE... in some TPW file, how do I say this procedure is for ABC, and some other is for Clarion?

Thank you in advance.

See #TEMPLATE topic in the help. For example,
#TEMPLATE(EasyEdge,‘Easy Edge (Chromium)’),FAMILY(‘ABC’),FAMILY(‘CW20’)

#! FAMILY() Names the other Template sets in which the #TEMPLATE is valid for use with.
#! #TEMPLATE(IS_Skeleton01,'IS Skeleton Template - #Template Example 1'),FAMILY('ABC'),FAMILY('CW20')
#! #TEMPLATE(IS_Skeleton01,'IS Skeleton Template - #Template Example 1'),FAMILY('CW20','ABC')
#! #TEMPLATE(IS_Skeleton01,'IS Skeleton Template - #Template Example 1'),FAMILY('ABC'),FAMILY('CW20'),FAMILY('IPServer')
#! #TEMPLATE(IS_Skeleton01,'IS Skeleton Template - #Template Example 1'),FAMILY('ABC'),FAMILY('CW20'),FAMILY('IPServer'),FAMILY('IS_Skeleton01')

There is a symbol %AppTemplateFamily set by the 2 chains

ABCHAIN.TPL - #SET(%AppTemplateFamily,'ABC') 

CW.TPL - #SET(%AppTemplateFamily,'CLARION') 

You will see a lot of code testing that symbol like below (some # Pound signs removed to format better):

AT(%AfterWindowOpening),WHERE(%AppTemplateFamily = 'CLARION' AND %TARGET32)  was #AT
AT(%AfterOpeningWindow),WHERE(%AppTemplateFamily <> 'CLARION')  was #AT

IF(%AppTemplateFamily='ABC')   was #IF etc
?IF Access:%BlobFile.TryFetch(%BlobFileKey)=Level:Benign
ELSIF(%AppTemplateFamily='CLARION')
?GET(%BlobFile,%BlobFileKey)
?IF NOT ERRORCODE()
ENDIF

IF LocEnableEnterByTab
   IF EnterByTabManager.TakeEvent()
       #IF(%AppTemplateFamily='ABC')
      RETURN(Level:Notify)
       #ELSIF(%AppTemplateFamily='CLARION')
      CYCLE
       #ENDIF
   END
END

Thank you all for help.

I just cant figure it out how to create simple Template that will show MESSAGE('Hello').

I have a Demo.tpl:

#TEMPLATE(DemoABC,'Demo ABC Template'),FAMILY('ABC')
#INCLUDE('TestABC.tpw)      #! Test template

Inside TestABC.tpw is:

#PROCEDURE(TestMessageTemplate, 'Test MESSAGE window','ABC')
%Procedure PROCEDURE()
ReturnValue BYTE
    CODE
    MESSAGE('Hello')
#!    
    RETURN

ReturnValue is just to test variable declaration.

When I try to register template i get error

Could not open include file

and

Invalid Expression

What is missing? I have found Clarion Magazine article An Introduction To Writing
Templates, but that did not help me, because it is more on adding functionality to existing templates. I have looked at templates in Clarion installation folder, but there is just so much lines. I have also looked at Clarion #PROCEDURE(Source,'Source Procedure')..., but I could not find what I am missing…

Yeah… so the problem was is in #INCLUDE, it was missing ' at the end. It is also necessary to edit Clarion110.red file, it is necessary to add path to your *.tp?.

If your files are not in \template\win or \accessory\template\win you will need to edit the RED file.

1 Like

Yes and No. It depends on whether your folders containing the tpl & tpw files are listed in the windows system environment path.
If they are not listed in the windows system environment path, then you need to add the folder to the redirection file
Now you can have your tpl in one main folder (eg %ROOT%\3RDPARTY\BIN) and all your tpw files in subfolders, this is what I do.

Now, whats not clear in the help docs is the continuation symbol doesnt work.
Now if you end up writing lots and lots of templates (at the last count I think I had 600+ template files) I found out the continuation symbol doesnt work and you can end up with a filemask and folders separated with semicolons that go well into the many hundreds of characters long, ie you need a seriously ultrawide monitor to see the entire width of the line. Thats not practical if you want to work on a laptop. Likewise having all loads of tpw files makes hunting them down in file explorer or select file dialog a slow process because .bak files get created for you automatically which get in the way sometimes!

Clarion Redirection File Line continuation symbol - questions / tips - ClarionHub

So you can have a redirection file that has one filemask and one folder per line, which keeps things nicely organised.

You can also have 3 different types of redirection file, which is app, project (folder) and IDE (default).
App is the appfilename.red located in the same folder as the app file.
Project/Folder which applies to all app files in the same folder is C60EE.red or CLARION110.RED.
IDE default is the C60EE.red or CLARION110.RED located in %Root%\bin folder.
If an app.red file exist this is used over the other two, if a folder/project red file exists this applies over the default IDE red file.

I’m actually working on a template which manages the redirection files, macros and registry.
This is the redirection file for my library app which explains what I put above.

And this is what it looks like inside the actual RED file.
– C:\C6 Work\Library\Library.red
[Common]
*.dll = %ROOT%\3RDPARTY\BIN
*.dll = %ROOT%\BIN
*.dll = .
*.dll = C:\CLARION6\3rdParty\Bin
*.stt = %ROOT%\template
*.tp? = %ROOT%\3RDPARTY\TEMPLATE
*.tp? = %ROOT%\3rdParty\template\C6grpSendDebugViewMsg
*.tp? = %ROOT%\3rdParty\template\C6grpViewEmbedSourceButton
*.tp? = %ROOT%\3rdParty\template\C6UtilDLL
*.tp? = %ROOT%\3rdParty\template\IS_api32
*.tp? = %ROOT%\3rdParty\template\IS_AppInfo
*.tp? = %ROOT%\3rdParty\template\IS_AutoBackup
*.tp? = %ROOT%\3rdParty\template\IS_BasicAppTemplate
*.tp? = %ROOT%\3rdParty\template\IS_BasicAppTemplateV2
*.tp? = %ROOT%\3rdParty\template\IS_BasicAppTemplateV3
*.tp? = %ROOT%\3rdParty\template\IS_BlankColumn
*.tp? = %ROOT%\3rdParty\template\IS_BrowseTreecontrol
*.tp? = %ROOT%\3rdParty\template\IS_ClassWriter
*.tp? = %ROOT%\3rdParty\template\IS_COMMS
*.tp? = %ROOT%\3rdParty\template\IS_CtrlAltP
*.tp? = %ROOT%\3rdParty\template\IS_DebugView
*.tp? = %ROOT%\3rdParty\template\IS_DebugView_Template_Group_Include_File
*.tp? = %ROOT%\3rdParty\template\IS_DisableWindowCloseButton
*.tp? = %ROOT%\3rdParty\template\IS_EmbedInfo
*.tp? = %ROOT%\3rdParty\template\IS_EntryFieldCutNPaste
*.tp? = %ROOT%\3rdParty\template\IS_ExeManifest
*.tp? = %ROOT%\3rdParty\template\IS_FileFolderLookup
*.tp? = %ROOT%\3rdParty\template\IS_FilePath
*.tp? = %ROOT%\3rdParty\template\IS_FormFirstField
*.tp? = %ROOT%\3rdParty\template\IS_FormSettings
*.tp? = %ROOT%\3rdParty\template\IS_GlobalEquates
*.tp? = %ROOT%\3rdParty\template\IS_HasAutoInc
*.tp? = %ROOT%\3rdParty\template\IS_LoadSettings
*.tp? = %ROOT%\3rdParty\template\IS_LocalError
*.tp? = %ROOT%\3rdParty\template\IS_LocalProcedure
*.tp? = %ROOT%\3rdParty\template\IS_LookupButton
*.tp? = %ROOT%\3rdParty\template\IS_Notes
*.tp? = %ROOT%\3rdParty\template\IS_ParameterPrototyper
*.tp? = %ROOT%\3rdParty\template\IS_RedirectionFile
*.tp? = %ROOT%\3rdParty\template\IS_RefreshTemplate
*.tp? = %ROOT%\3rdParty\template\IS_SetFont
*.tp? = %ROOT%\3rdParty\template\IS_SharedGlobals
*.tp? = %ROOT%\3rdParty\template\IS_SimpleApp
*.tp? = %ROOT%\3rdParty\template\IS_SingleProcAppPRJextras
*.tp? = %ROOT%\3rdParty\template\IS_SubClass
*.tp? = %ROOT%\3rdParty\template\IS_Synch
*.tp? = %ROOT%\3rdParty\template\IS_Test
*.tp? = %ROOT%\3rdParty\template\IS_ThiswindowRunExtender
*.tp? = %ROOT%\TEMPLATE
*.trf = %ROOT%\template
*.txs = %ROOT%\template
[Debug32]
*.obj = %ROOT%\obj32
*.res = %ROOT%\obj32
*.rsc = %ROOT%\obj32
[Release32]
*.obj = %ROOT%\obj32\release
*.res = %ROOT%\obj32\release
*.rsc = %ROOT%\obj32\release

In C7+ there are extra directives like [Copy] but with the templates you can do anything so I can replicate everything C11 does in C6 and probably earlier versions but havent tested below C6.

Because I can select multiple tpl files when registering templates, I place all my tpl files in
*.tp? = %ROOT%\3RDPARTY\TEMPLATE
and all my tpw’s go in their respective subfolder.

Another trick you might be interested in, is the two lines in this red file that start “C6grp” are templates (tpw files) which start with a #Group(%grpMyGroupName) which are used in a variety of other templates, its a quick way of bolting in standard repetitive template code across multiple different templates.

With an app or project redirection file, you will also get a new registry.trf so an app folder with subdirectories can contain everything it needs to build the app, but it also makes it quick and easy to move to other locations or developers, because you only have to copy one folder and its contents. Templates that are not used dont need to be registered in the app or folder registry.

I’m also working on the redirection macros which will replace all the %ROOT% you see in the redirection file, but these need to be located in C60EE.ini or ClarionProperties.xml for C7+ IDE’s.

This particular template will even notify you when the IDE has loaded the wrong RED file just to be on the safe side.

And because the template source file can get rather large with quite a few hundred lines in each file, the template code to display these tabs in these pictures in the global extension section is simply this. This is a tpw file called from a tpl file which has the #Application… template line.

#EXTENSION(IS_RedirectionFileManager,'IS_RedirectionFileManager - Manage the Clarion Redirection File from within the AppGen')
#Prepare
#Call(%grpPrepare )
#EndPrepare
#Sheet,HScroll
#Tab('&1 Settings')
    #Insert(%grpTabSettings)
#EndTab
#Tab('&2 Redirection Macros')
    #Insert(%grpTabRedirMacros)
#EndTab
#Tab('&3 Folder Layout')
    #Insert(%grpTabFolderLayout)
#EndTab
#TAB('&4 [AppFilename] .Red')   
    #Insert(%grpTabAppFilename)
#EndTab
#TAB('&5 [AppFolder] .Red')     
    #Insert(%grpTabAppFolder)
#EndTab
#TAB('&6 [IDE] .Red')           
    #Insert(%grpTabIDE)
#EndTab
#TAB('&7 Debug')
    #Insert(%grpTabDebug)
#EndTab
#Endsheet

Where #Insert(%grpXYZ) is simply a Group like so…

#Group(%grpTabAppFolder)
    #Display('')
    #Display('Folder Redir File')
    #Enable(%False)
    #Prompt('Folder Redir File',TEXT),%FolderRedirFilepath,At(,,175,20)
    #Prompt('Folder Redir File Exist',Check),%FolderRedirExist,At(10)
    #EndEnable
    #Display('')
    #Enable(%FolderRedirExist)
    #Button('Folder Redirection File'),Multi(%FolderRedirList,%FolderRedirList &' '& %FolderDisplayLine),Inline,Prop(Prop:Font,'Lucida Console'),Prop(Prop:FontStyle,400),Prop(Prop:FontSize,7)
        #Sheet
        #Tab('&1 Line Entry'),Where(%FolderSection<>'Comment')
            #Display('')
            #Prompt('Section',Drop(%grpPopulateClarionRedSections)),%FolderSection,Default('Common')
            #Enable(%FolderSection<>'Comment')
            #Prompt('Filemask',@s255),%FolderRedFileMask
            #Display('Folder')
            #Prompt('Folder',Text),%FolderRedFolder
            #EndEnable
        #EndTab
        #Tab('&1 Comment'),Where(%FolderSection='Comment')
            #Enable(%FolderSection='Comment')
            #Display('Comment')
            #Prompt('Comment',Text),%FolderComment,at(,,175,30)
            #EndEnable
        #EndTab
        #Tab('&2 Debug') 
            #Display('%FolderRedirLine')
            #Prompt('%FolderRedirLine',Text),%FolderRedirLine,At(,,,20)
            #Display('')
            #Display('%FolderDisplayLine')
            #Prompt('%FolderDisplayLine',Text),%FolderDisplayLine,At(,,,20)
        #EndTab
        #EndSheet
    #EndButton
    #EndEnable
    #Display('')
    #Button('Add AppFolder Redir Comment'),At(,,175,14),WhenAccepted(%grpAddAppFolderRedirComment() )
    #EndButton
    #Enable(%FolderRedirExist)
    #Button('Import AppFolder Redirection File'),At(,,175,14),WhenAccepted(%grpImportFolderRedirFile() )
    #EndButton
    #EndEnable
    #Enable(%FolderRedirList)
    #Button('Export AppFolder Redirection File'),At(,,175,14),WhenAccepted(%grpExportFolderRedirFile() )
    #EndButton
    #EndEnable
    #Display('')

hth

A post was split to a new topic: Template to access VIEW that is created by the Browse template?