User Tools

Site Tools

Navigation:  Templates > Template Language Reference > Complete Alpha Listing >====== #CODE (define a code template) C6H0068.jpg ====== Previous pageReturn to chapter overviewNext page

#CODE( name,description [,target ] ) [, SINGLE][, HLP( helpid )] [, PRIMARY( message [, flag] )]

[, DESCRIPTION( expression ) ] [, ROUTINE ]

[, PRIORITY( number )] [, REQ( addition [,| BEFORE| ] ) ] [,| FIRST| ]

AFTER             LAST


#CODE Begins a code template that generates source into an embedded source code point.
name The label of the code template. This must be a valid Clarion label.
description A string constant describing the code template.
target A string constant that specifies the source language the code template generates. If omitted, it defaults to Clarion. This restricts the #CODE to matching target language use, only.
SINGLE Specifies the #CODE may be used only once in a given procedure (or program, if the embedded source code point is global).
HLP Specifies on-line help is available.
helpid A string constant containing the identifier to access the Help system. This may be either a Help keyword or “context string.”
PRIMARY Specifies a primary file for the code template must be placed in the procedure's Data / Tables Pad.
message A string constant containing a message that appears in the Data / Tables Pad next to the #CODE's Primary file.
flag Either OPTIONAL (the file is not required), OPTKEY (the key is not required), or NOKEY (the file is not required to have a key).
DESCRIPTION Specifies the display description of a #CODE that may be used multiple times in a given application or procedure.
expression A string constant or expression that contains the description to display.
ROUTINE Specifies the generated code is not automatically indented from column one.
PRIORITY Specifies the order in which the #CODE is generated into the embed point. The lowest value generates first. If omitted, the PRIORITY is assumed to be 5000.
number An integer constant in the range 1 to 10000.
REQ Specifies the #CODE requires a previously placed #CODE, #CONTROL, or #EXTENSION before it may be used. It also means all prompts and variables of the required addition are available to it.
addition The name of the previously placed #CODE, #CONTROL, or #EXTENSION template, from any template set.
BEFORE Legacy attribute, replaced by PRIORITY.
AFTER Legacy attribute, replaced by PRIORITY.
FIRST Equivalent to PRIORITY(1).
LAST Equivalent to PRIORITY(10000).

#CODE defines the beginning of a code template which can generate code into embedded source code points. A #CODE section may contain Template and/or target language code. The #CODE section is terminated by the first occurrence of a Template Code Section (#PROGRAM, #MODULE, #PROCEDURE, #CONTROL, #CODE, #EXTENSION, or #GROUP) statement, or the end of the file. Within a single Template set, separate #CODE sections may not be defined with the same name.

#CODE generates its code into a #EMBED embedded source code point. The generated code is automatically indented when placed in ROUTINEs, unless the ROUTINE attribute is present. A #CODE section may contain #PROMPT statements to prompt for the values needed to generate proper source code. It may also contain #EMBED statements, which become active only if the #CODE section is used.

You can use the #WHERE statement to limit the availability of the #CODE to those embedded source code points where the generated code would be appropriate. A #CODE may contain multiple #WHERE statements to explicitly define all the valid embedded source code points in which it may appear. #RESTRICT can also further restrict the availability of the #CODE based on an expression or Template language statements.

The #AT/#ENDAT structure allows a single #CODE to generate code into multiple embedded source code points to support its functionality.


#CODE(ChangeProperty,'Change control property')

 #WHERE(%SetupWindow..%ProcedureRoutines)   #!Appropriate only after window open

 #PROMPT('Control to change',CONTROL),%MyField,REQ

 #PROMPT('Property to change',@S20),%Property,REQ

 #PROMPT('New Value',@S20),%Value,REQ

%MyField{%Property} = '%Value'               #<;!Change the %Property of %MyField

See Also:     #EMBED ,



#AT (insert code in an embed point)

code_define_a_code_template_.htm.txt · Last modified: 2021/04/15 15:57 by