| **Navigation:**  [[templates.htm|Templates]] > [[tlrcontents.htm|Template Language Reference]] > Complete Alpha Listing >====== #GROUP (reusable statement group) {{c6h0068.jpg|C6H0068.jpg}} ====== | [[ globaldata default global data declarations .htm|{{btn_prev_n.gif|Previous page}}]][[tlrcontents.htm|{{btn_home_n.gif|Return to chapter overview}}]][[ help specify template help file .htm|{{btn_next_n.gif|Next page}}]] | | || **#GROUP(** //symbol// [, [ //type// ] //parameters //[//= default// ] ] **)** [, **AUTO** ] [, **PRESERVE** ] [, **HLP(** //helpid// **)** ] {{blk2blue.jpg|blk2blue.jpg}} | **#GROUP** | Begins a section of template code that may be inserted into another portion of the template. | | //symbol// | A user-defined symbol used as the #GROUP's identifier. | | //type// | The data type of a passed //parameter//: LONG, REAL, STRING, or * (asterisk). An asterisk (*) indicates it is a variable-parameter (passed by address), whose value may be changed by the #GROUP. LONG, REAL, and STRING indicates it is a value-parameter (passed by value), whose value is not changed by the #GROUP. If //type// is omitted, the //parameter// is a passed as a STRING. | | //parameters// | User-defined symbols by which values passed to the #GROUP are referenced. You may pass multiple //parameters//, each separated by commas, to a #GROUP. All specified //parameters// must be passed to the #GROUP; they may be omitted only if a //default// is supplied. | | //=default// | The value passed for an omitted //parameter//. | | **AUTO** | Opens a new scope for the group. This means that any #DECLARE statements in the #GROUP would not be available to the #PROCEDURE being generated. Passing //parameters// to a #GROUP implicitly opens a new scope. | | **PRESERVE** | Preserves the current fixed instances of all built-in multi-valued symbols when the #GROUP is called and restores all those instances when the #GROUP code terminates. | | **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." | **#GROUP** defines the beginning of a section of code which is generated into the source. A #GROUP section may contain Template and/or target language code. The #GROUP 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, separate #GROUP sections may not be defined with the same //symbol//. The //parameters// passed to a #GROUP fall into two categories: **value-parameters** and **variable-parameters**. **Value-parameters** are declared as user-defined symbols, with an optional //type //and are "passed by value" (a copy of the value is passed)// //Either symbols or expressions may be passed as value-parameters. When a multi-valued symbol is passed as a value-parameter, only the current instance is passed. **Variable-parameters** are declared as user-defined symbols with a prepended asterisk (*****) (and no //type//). A variable-parameter is "passed by address" and any change to its value by the #GROUP code changes the value of the passed symbol. Only symbols may be passed to a #GROUP as variable-parameters. When a multi-valued symbol is passed as a variable-parameter, all instances are passed. The statements contained in the #GROUP section are generated by the #INSERT or #CALL statements. A #GROUP may contain #EMBED statements to define embedded source code points. A #GROUP may contain #PROMPT statements to obtain programmer input. A #GROUP may act as a function if the #RETURN statement which passes control back from the #GROUP has a parameter. The value is returned to the CALL built-in procedure or directly to the expression in which the #GROUP is called as a function. If the #GROUP is called without the CALL built-in procedure and takes no parameters, open and close parentheses must be appended to the #GROUP symbol. For example, you may either place CALL(%MyGroup) in an expression or just %MyGroup(). **Example:** **#GROUP****(%GenerateFormulas)           #!A #GROUP without parameters** **  #FOR(%Formula)** **    #IF(%FormulaComputation)** **%Formula = %FormulaComputation** **    #ELSE** **IF(%FormulaCondition)** **  %Formula = %FormulaTrue** **ELSE** **  %Formula = %FormulaFalse** **END** **    #ENDIF** **  #ENDFOR** **#GROUP****(%ChangeProperty,%MyField,%Property,%Value) #!A #GROUP that receives parameters** **%MyField{%Property} = '%Value' #<;!Change the %Property of %MyField** **#!A #GROUP that receives a variable-parameter and a value-parameter:** **#GROUP****(%SomeGroup, * %VarParm, LONG %ValParm) ** **See Also:     [[ insert insert code from a group .htm|#INSERT]]** ,[[ return return from group .htm|#RETURN]] , [[call call a group as a function .htm|CALL]]