Part of Templates and the Application Generator: the hub. 77 entries under this heading; every entry opens as its own topic.
- How to reach the symbols of another vendor's template instance from your own template - Loop the active template instances with a WHERE on TemplateName(ChainName) in upper case, and enter each with CONTEXT to reach another template's symbols.
- A template prompt value with an apostrophe gives "string not terminated" in the generated code - Wrap the template variable in the shipped StripPling group, called as an expression, so apostrophes are doubled and the string terminates.
- Is the %CWRoot template symbol safe to use? It is not in the help index - The CWRoot symbol is documented, with CWVersion, in the help topic Miscellaneous Symbols, though the help index does not list it.
- How to sort a multi-valued symbol so a #PROMPT list shows alphabetically - Copy the values into a second symbol declared with UNIQUE; UNIQUE stores values in ascending order, so a prompt list built from it comes out sorted.
- Making a template #PROMPT stay selected until it has a value - A prompt cannot be held until filled; options were enabling fields only after it is filled, a DLL window via #RUNDLL, or a #BOXED group shown only when the control is set.
- Generating one IF statement around many lines instead of one IF per line - Put the generated IF and END outside the #FOR so only the HIDE line repeats; guard with #IF(ITEMS()) if there may be no buttons.
- Reading the procedure template's symbols from an extension's #PREPARE - Use #CONTEXT inside #PREPARE to reach the procedure template's symbols that are otherwise out of scope there; #PREPARE only shapes the prompt interface.
- How do I loop the contents of a list control's queue in a template to write it to a text file? - PROP:From is runtime only; in a template use %ControlFrom and generate code with WHO() and WHAT() to walk the queue fields, or start from a posted browse-to-ASCII template.
- How do I get the prefix of a local queue in a template when I only have %ControlFrom? - Find the colon in a %ControlField and slice off the prefix, or use EXTRACT on the queue declaration with 'PRE',1; the first form was confirmed.
- Is there an OMIT() equivalent for templates, to skip #PDEFINE when the template loads in Clarion 5? (Reported, not reproduced) - Posters suggested testing %CWVersion or wrapping the line in #COMPILE, or keeping two template versions; nobody reported a result, and dropping Clarion 5 support was advised.
- One TPL file for all my templates, or many separate TPL files? - Use one .tpl with #INCLUDE lines naming .tpw files, as CW.TPL does; each .tpl holds one #TEMPLATE and gives one node in the template registry.
- How do I let the user pick procedures from a list in a utility template and loop only the selected ones? - Fill a MULTI symbol with #FOR(%Procedure) and #ADD in #PREPARE, offer it with a #PROMPT FROM SELECTION, then #FIX against the chosen symbol to test for selected procedures.
- How do I show a template prompt list (such as the controls) in alphabetical order? - Add SORT to a #BUTTON FROM list; for prompts without a sort attribute, fill your own UNIQUE symbol, which stays sorted.
- How a template detects that another template is in the application - Loop over %ActiveTemplate, compare the upper-cased name with the other template's name, set a flag and #BREAK to generate code conditionally.
- What does %' (a percent sign before a single quote) mean in template symbols? - %'symbol expands the symbol doubling single quotes and unpaired left angle brackets and curly braces; it equals '%(QUOTE(%Procedure))'.
- How a template can tell whether a procedure is local to the app or external - Test the procedure template symbol for the value EXTERNAL while looping the procedures to tell external procedures from local ones.
- How an extension template detects whether the application uses the ABC or Legacy chain - An extension template can read the application template family symbol on 5.5 and 6; older versions needed a helper group called once with an override prompt.
- A template symbol set in a global extension is never found in the procedure extension it adds (Reported, not reproduced) - A symbol declared and prompted in a global extension was not found in the procedure extension it added; posters disagreed on #DECLARE with #PROMPT, with no settled answer.
- An extension template cannot change the procedure's %Prototype; how to enforce the parameters it needs - An extension template cannot set the read-only %Prototype; test it in #ATSTART with INSTRING and raise an #ERROR naming the procedure and template.
- Template code to list only the files that use a derived FileManager class - Walk the ClassItem symbol for FileManager items and test UseDefaultABCBaseClass to list files with a derived class; the file list itself does not carry this.
- Giving a template #PROMPT a default value, then "Unknown identifier" for the variable the user typed - Add DEFAULT to the PROMPT; a prompt stores only text, so declare the variable in the GlobalData embed or pick existing ones with FROM.
- How do I add prompts (such as check boxes) for each control of a window from a template? - To give each control its own prompts use #FIELD in the template; an extension with an inline control list also worked, with a self-filled list sorting alphabetically.
- A template #PROMPT with a @S3 picture shows 1.0 as 1: the trailing zero is lost - An unquoted DEFAULT(1.0) makes the symbol numeric so the zero vanishes; quote the default and quote the symbol where the generated code expands it.
- How a #CONTROL template finds the USE variable and equate of its own ENTRY controls - Loop the control symbol filtered to the active template instance and keep it in your own declared symbol; including a TXA from the template was another idea.
- Is there a case-insensitive #FIX or #FIND in the template language? - Add the NOCASE attribute to the FIX statement to match a file name regardless of case; the poster found it in neither the help nor the guide.
- A third-party template that registered fine now fails: pipe character in a #! comment line - A pipe in a #! comment line failed to register in 5.5b because it became the line-continuation character; remove the pipes from the comments.
- How do I split %FileUserOptions and %FieldUserOptions into their separate options in a template? - Position with FIND and read each option by name with EXTRACT on the user options symbol; loop a list of names for several.
- Can a template prompt dialog show a live preview that changes as the user picks a font or color? - A template prompt page cannot refresh a live sample as choices change; the poster settled for a Preview button opening a second page.
- Converting existing entry controls to use a control template without deleting and re-populating them - Existing controls cannot simply switch to a control template; use an extension or code template, change the control type via the dictionary, or edit through a TXA export and import.
- A #CODE template with REQ(extension) and #RESTRICT gives "Unknown Variable" for the extension's symbol (Reported, not reproduced) - A #CODE template with REQ(extension) and #RESTRICT gave Unknown Variable; suggestions were VAREXISTS, re-entering the procedure, a #CONTEXT block; poster dropped the #RESTRICT.
- Template error "%Parameters is read only" on #SET(%Parameters, ...) in Clarion 9, fine in Clarion 8 - Clarion 9 made %Parameters read only; remove the #SET and use a fully qualified #PROTOTYPE on the procedure template to force the parameters.
- A #PROMPT that takes either a dictionary field or a literal, like the !variable / file name box in the DCT - Use #PROMPT with OPTFIELD for a field or a constant, or EXPR for any expression; the leading ! is a template convention you must strip in your code.
- A #CONTROL template with REQ(MultiChildRelationTree(ABC)) never appears in the control list - In REQ the bracketed part is the required template's own name from its TEMPLATE line, not the family, and the control name takes no percent sign; spell it out.
- EMBEDBUTTON in an extension template opens one embed point: how to offer all of the extension's embeds - EMBEDBUTTON opens the embeds of one identifier symbol; multi-valued symbols, redefined EMBED statements and the TREE attribute were the ideas, but the poster's final change is cut off.
- Using a control template's equate (?Button1) without the question mark in generated code - You cannot change a populated control's equate, but #IF with Slice on %Control and #SET can strip the leading question mark into your own symbol.
- Template code: collecting every file a procedure uses (Primary, Secondary, Other and the templates' files) - Collect Primary, Secondary and Other files into a list in a #GROUP, then repeat the loop inside each active template instance.
- A build date and time template forces a full recompile on every build - Instead of a global equate that forces a full recompile, write the equate to an INC file with CREATE and CLOSE and include it in one separate module.
- Converting many apps from an old extension template to a new one with similar symbols - Export each app to TXA, search and replace the old extension template names with the new ones, import, and test one app first.
- Adding a procedure extension template only to procedures that already have WindowResize(ABC) - Add a RESTRICT that loops ActiveTemplate for WindowResize(ABC), and name your own template chain in the global extension's APPLICATION attribute.
- #LocalData with a %TemplateSymbol gives "Identifier Expected": how do I get a template variable into the list box formatter? - All DATA sections of a template take literals only, so a template symbol in LocalData gives Identifier Expected; no way to reach the formatter was found.
- A control template that turns on "Enable Sort Header" and sets the locator control of a browse - Make the control template require the browse template and #SET its prompt symbols for sort header and locator, finding them in the standard browse template; use #CONTEXT otherwise.
- How do I replace the default message of a ToDo procedure? - A ToDo is a procedure template, so write your own default procedure template in a TPL file, register it, and pick it instead of the standard ToDo.
- Template code from #CALL or #INSERT is generated at column 3, not column 1 - Save %OutputIndent in an equate, apply INDENT with its negative, write the line, then restore the saved indent to get column 1.
- [What does %[55] mean in a template statement such as %55?](What does %[55] mean in a template statement such as %[55](LINKNAME(...))?) - In a template, %55 pads the expansion to a field width of 55 characters so columns line up; longer values are not cut.
- An #AT placed inside #FOR(%File) / #FOR(%Field) in an extension template does not generate - Do not wrap an #AT in #FOR; the #AT repeats per file and field itself, so limit it with a Where clause or a test inside.
- Registering the UltimatePlaceholder template fails: "Expected a section header" at line 1 (Reported, not reproduced) - Registering a downloaded template gave "Expected a section header"; moving the #SYSTEM block and fixing Unix line endings were suggested but the error stayed.
- A template #PROMPT with FIELD will not accept a global variable (the lookup button is disabled) - A FIELD prompt does not offer global data; use an EDIT or EXPR prompt, or a FROM on the global data symbol, to reach globals.
- #RUNDLL warning "Error: 998" and "DLL can't be found" when generating a Clarion 6 app from the Clarion 7 IDE (Reported, not reproduced) - A #RUNDLL call to a Clarion 6 DLL warned "Error: 998" when generating from the Clarion 7 IDE; copying the DLL to the Clarion 7 bin folder did not help.
- Changing the text of a PROMPT inside a control template so the window formatter shows it - A PROMPT in a control template cannot be changed for the window formatter; only during generation with difficulty, or at run time in code.
- Letting the template user pick a font: FONTDIALOG in a #PROMPT, and the SVFnGrp.TPW groups - FONTDIALOG is not a usable #PROMPT type; call the font groups in SVFnGrp.TPW and add the chain name, such as (ABC), to a group from another chain.
- Template language: testing whether a window control's help (PROP:Hlp) is empty - Test a control's help in template language with EXTRACT on %ControlStatement for HLP, because comparing %Control{PROP:Hlp} to empty is rejected.
- Sending e-mail with the Global Document Handling template: the mail server wants a user name and password - Register ABMAIL.TPL for Global Document Handling; the AuthUser and AuthPass properties carry the mail login, and the demo needed them set for transmit first.
- An extension template writes empty external files when the Embeditor is opened: how to detect Embeditor generation - Test %EditProcedure or compare %GenerateMode with 'SOURCE' or 'PWEE' to tell Embeditor generation from source generation, so an extension template writes files only for source.
- A procedure template that loops %LocalData to FREE every local queue crashes the IDE - Loop %LocalData with a WHERE(INSTRING('QUEUE',%LocalDataStatement)) filter to FREE local queues; slicing the symbol with [1 : 5] crashed the C55 IDE, SUB() also worked.
- How do I share the #AT code between an extension template and a control template? (#GROUP refuses #AT) - A #GROUP cannot hold #AT; group the code between #AT and #END, or use a global template with %GatherSymbols priorities; #INCLUDE of a .tpw crashed the IDE.
- A control template prompt should be filled the moment the control is populated, not after the first generate - Put the #PREPARE block above the #PROMPT and drop the prompt's DEFAULT attribute, so a control template prompt is filled the moment the control is populated.
- Old templates test %CWTemplateVersion < 'v6.1' and stopped working in Clarion 10 - %CWTemplateVersion is a string, so 'v10.0' sorts below 'v6.1'; compare the numeric %CWVersion instead, for example #IF(%CWVersion < 6100).
- How to read the %Primary of a related extension template from a control template - To read an extension template's %Primary from a control template, use %ActiveTemplateParentInstance with #SELECT in a #PREPARE block before the field prompt.
- A code template that writes code at two places with room for your own statements between them - A code template with one #EMBED and two #AT blocks tied to the template instance gave code at two priorities, but orphan embeds; three prompts with #IF was the standard form.
- Making a template prompt window wider - The template prompt window has a fixed width; AT on a sheet did nothing, so hide tabs conditionally, nest the sheet in a button, or use a RUNDLL dialog.
- Template code to list all the files a procedure uses when it has several browses - Loop over %ActiveTemplate and %ActiveTemplateInstance, add each instance's %Primary and its %Secondary files to your own multi-valued symbol, so several browses are all listed.
- A symbol set in %ProcedureSetup is "not yet declared" in ThisWindow.Init() - A symbol declared in the ProcedureSetup embed is not yet visible in Init; replies pointed to #ATSTART and the data section, without a full explanation.
- How do I make the PRIMARY file of an extension template optional? - Add the OPTIONAL flag to the PRIMARY attribute of an extension template; the template language cannot set %Primary, so the developer picks the file in the schematic.
- A WINDOW added to a #DEFAULT section of a #PROCEDURE template does not appear and the Window button stays disabled - A window in a procedure template's default section only appears, and the Window button only enables, when the procedure template line carries the WINDOW attribute.
- An #EMBED in a code template is replicated at every instance of the template - Make the embed depend on the Active Template Instance: declare a MULTI symbol in #ATSTART, then use #EMBED with the instance and MAP attribute so each instance gets its own embed point.
- A #PROMPT list built FROM(%ModuleData) shows nothing, while %GlobalData and %LocalData list fine - Put a PREPARE block with FIND on the module-procedure symbol before the prompts, so the module symbol is fixed and the module variable list fills.
- Adding a field to every window structure from a template (is there a window section embed?) - There is no window section symbol; create the control with CREATE in the window manager Init embed after the window opens, or add the name to the caption.
- %ControlUse gives a negative number for a MENU item; which symbol gives ?MENU1 as text - Use %Control, not %ControlUse, for the field equate; quote it as '%Control' to generate the equate label as a string.
- Generating a whole function from a template instead of adding an extension to a hand-made Source procedure - Convert the extension template to a procedure template with #PROCEDURE and #PROTOTYPE, study an existing procedure template's source, and generate a separate module through global embeds.
- A template fails to register with "A section called GlobalInit has already been defined" - Two #EXTENSION lines with the same name in one template give "section already defined"; give each extension its own name and register again.
- #WITH(%ClassItem,...) in an extension template reports a reference to an unknown symbol - An unknown-symbol error at #WITH on the class item came from #INSERT(%OOPPrompts) written without the (ABC) family.
- A template #BUTTON with WHERE(...) is always shown, while #BOXED with the same WHERE works (Reported, not reproduced) - A template #BUTTON with WHERE and no FROM stayed visible while #BOXED hid; wrapping the button in #ENABLE worked for the poster.
- Adding the same custom code to about 50 update procedures in one step - Write a global #EXTENSION template with an #AT embed restricted by WHERE on the procedure template, or buy a ready-made global extension product.
- Templates moved from Clarion 6.3 to 10 fail at the #IF test of %CWTemplateVersion against 'v6' - Test %CWTemplateVersion against v10.0 with SUB count 5 in Clarion 10, and close each #IF with #ENDIF because #END is stricter now.
- What breaks when a Clarion 5.5 ABC app and its templates are opened and compiled in Clarion 6? - Third-party libraries need Clarion 6 versions, and #PROJECT lines naming C55 libraries must change; a version test with CWVersion was posted.
- How does a template find out which Clarion version it runs under (5.5 or 6)? - Compare the %CWVersion symbol as a number, such as 6000 or 6100, or cut its first digit with SUB inside the template.
- GEN: Unknown Variable '%GlobalUseABCClasess' in my own template chain - The misspelled symbol ships in the standard templates and is not hard coded; an #INCLUDE buried in the poster's own templates used it.