` Checking if template instance exists (Brian Staff) - Icetips Article
Icetips - Templates, Tools & Utilities for Clarion Developers

Templates, Tools and Utilities
for Clarion Developers

Icetips Article

Back to article list   Search Articles     Add Comment     Printer friendly     Direct link  

Templates: Checking if template instance exists
1998-09-08 -- Brian Staff
 
Newsgroups: topspeed.products.c4 > I am writing a Procedure Estension template. This template call a > function at %ProgramSetup. However, when I include this template in > more than one procedure, it generates that function call for each > procedure it is included in. I only need the function called once > regardless of the number of procedures that include this extension > template. > > How can the above be done? #DECLARE(%FirstInstance) #DECLARE(%LastInstance) #DECLARE(%ThisTemplate) #SET(%ThisTemplate,%ActiveTemplate) #!do NOT put the UNIQUE attribute on the following DECLARE - it will cause the ADD to sort #DECLARE(%AllInstances),MULTI #FOR(%ActiveTemplate),WHERE(%ActiveTemplate=%ThisTemplate) #FOR(%ActiveTemplateInstance) #ADD(%AllInstances,%ActiveTemplateInstance) #ENDFOR #ENDFOR #SELECT(%AllInstances,1) #IF(%AllInstances=%ActiveTemplateInstance) #SET(%FirstInstance,1) #ELSE #SET(%FirstInstance,0) #ENDIF #SELECT(%AllInstances,ITEMS(%AllInstances)) #IF(%AllInstances=%ActiveTemplateInstance) #SET(%LastInstance,1) #ELSE #SET(%LastInstance,0) #ENDIF #AT(%GlobalData) #IF(%FirstInstance) Myvariable LONG #ENDIF #ENDAT This technique also allows you to build complex structures like: #IF(%FirstInstance) CASE MyVariable #ENDIF OF Whatever !one for every instance DO Something #IF(%LastInstance) END #ENDIF HTH Brian Staff (Phoenix) - Team TopSpeed [CW] http://ourworld.compuserve.com/homepages/BrianStaff/


Today is November 21, 2024, 3:49 am
This article has been viewed 35212 times.
Google search has resulted in 2 hits on this article since January 25, 2004.



Back to article list   Search Articles   Add Comment   Printer friendly

Login

User Name:

Password: