How do you write an Global Extension Template?
You can download the full template here.
Here is a template I started writing along time ago when I was learning about temples and how they could help me be a more efficient developer....
Open a text editor and create a new file called for example clarionx.tpl (template)
1. Define the template Chain
#TEMPLATE(ClarionXTemplates,'ClarionX Dev Tools 1.0')
2. Define the Global Extension Template
#EXTENSION(ClarionXGlobal,'ClarionX Dev Tools 1.0 Global'),APPLICATION
,APPLICATION means that it should only be available as a Global Extension and not at the procedure level.
3. Give the User/developer some options to play around with in the IDE...
To generate an include file, txa or txd and/or perform backups of application txa after each compile...feel free to take this code and improve it....
#DISPLAY('ClarionX Dev Tools are Enabled'),AT(10,,,)
#PROMPT('Generate Include File ' & %Application & '.inc',CHECK),%GenerateAppIncludeFile,DEFAULT(1),AT(10,20,,)
#PROMPT('Generate TXA File ' & %Application & '.txa',CHECK),%GenerateTxaFile,DEFAULT(0),AT(10,30,,)
#PROMPT('Generate TXD File ' & %Application & '.txd',CHECK),%GenerateTxdFile,DEFAULT(0),AT(10,40,,)
#PROMPT('Auto Backup eg. TXA ' & %Application & '_yyyymmdd_hhmmss.txa',CHECK),%AutoBackups,DEFAULT(1),AT(10,50,,)
These are all pretty self explanatory steps.
4. Lets get to the guts....
To get this template to work we need to make sure this template code is only executed when the template is initialised...
#ATSTART
#ENDAT
Generate INC File .... Pretty Simple
#IF (%GenerateAppIncludeFile = 1)
#DECLARE(%AppIncludeFile)
#SET(%AppIncludeFile,%Application & '.inc')
#CREATE(%AppIncludeFile)
#FOR(%Procedure),WHERE(%ProcedureExported = 1)
%(%Procedure & %Prototype)
#ENDFOR
#CLOSE(%AppIncludeFile)
#ENDIF
Generate TXA File .... Pretty Simple
#IF (%GenerateTxaFile = 1)
#DECLARE(%TxaFile)
#SET(%TxaFile,%Application & '.txa')
#CREATE(%TxaFile)
#EXPORT
#CLOSE(%TxaFile)
#ENDIF
Generate TXD File .... Pretty Simple
#IF (%GenerateTxdFile = 1)
#DECLARE(%TxdFile)
#SET(%TxdFile,%Application & '.txd')
#CREATE(%TxdFile)
#MESSAGE('Exporting Dictionary...',2)
#EXPORT(%DictionaryFile)
#CLOSE(%TxdFile)
#ENDIF
#ENDAT
#ATEND
Auto Backup .... Pretty Simple...just a datetime stamped TXA
#IF (%AutoBackups = 1)
#DECLARE(%BackupFile)
#SET(%BackupFile,%Application & '_' & CLIP(FORMAT(%ProgramDateChanged,@d12)) & '_' & CLIP(FORMAT(%ProgramTimeChanged,@t5))&'.txa')
#CREATE(%BackupFile)
#MESSAGE('Backing Up Program Settings...',2)
#EXPORT
#CLOSE(%BackupFile)
#ENDIF
#ENDAT
You can download the full template here. Simply register it in the template registry and thats it....
This is a good example of the usefulness of templates. With clarionx.tpl dev tools template you can tick a checkbox and generate a txa or txd, generate an inc file for your dlls and without knowing it checkpoint your code with autobackups ..... pretty handy.
More templates coming soon....