Generic Expansion Tokens

 

Generic expansion tokens are tokens which insert generic (non structure specific) information or take some generic action, and can be used at anywhere in a template file.

Generic Token

Description

<AUTHOR>

Inserts your name, which you specify via the environment variable CODEGEN_AUTHOR.

When you install CodeGen you are prompted to enter your name during the installation process and the value that you enter is saved in the Windows Registry.  If CodeGen finds that the environment variable CODEGEN_AUTHOR is not set then it will attempt to read this value from the registry and will set the CODEGEN_AUTHOR environment variable automatically.

If no author name can be determined the string CodeGen is inserted.

Video: Using AUTHOR and COMPANY Tokens

<CODEGEN_VERSION>

Inserts the CodeGen version number.

Example:  CodeGen V5.6.5

<COMPANY>

This token is inserts your company name, which you specify via the environment variable CODEGEN_COMPANY.

Example:  Synergex Professional Services Group

When you install CodeGen on a Windows system you are prompted to enter your company during the installation process and the value that you enter is saved in the Windows Registry.  If CodeGen finds that the environment variable CODEGEN_COMPANY is not set then it will attempt to read this value from the registry and will set the CODEGEN_COMPANY environment variable automatically.

If no company name can be determined the string Synergex is inserted.

Video:  Using AUTHOR and COMPANY Tokens

<COUNTER_1_DECREMENT>

CodeGen provides two built in counters that developers can use when designing template files. For each code generation task both counters start off with a value of zero. Tokens in the template file can cause the value of each counter to be incremented, decremented or reset to zero. Another token can be used to insert the current value of a counter into the text output stream.

This token decrements the value of counter 1 by 1. If the token appears inside of an expression that currently evaluates to false then the value will not be decremented.

This token does not cause any text to be written to the output stream.

<COUNTER_1_INCREMENT>

CodeGen provides two built in counters that developers can use when designing template files. For each code generation task both counters start off with a value of zero. Tokens in the template file can cause the value of each counter to be incremented, decremented or reset to zero. Another token can be used to insert the current value of a counter into the text output stream.

This token increments the value of counter 1 by 1. If the token appears inside of an expression that currently evaluates to false then the value will not be incremented.

This token does not cause any text to be written to the output stream.

<COUNTER_1_RESET>

CodeGen provides two built in counters that developers can use when designing template files. For each code generation task both counters start off with a value of zero. Tokens in the template file can cause the value of each counter to be incremented, decremented or reset to zero. Another token can be used to insert the current value of a counter into the text output stream.

This token resets the value of counter 1 to 0. If the token appears inside of an expression that currently evaluates to false then the value will not be reset.

This token does not cause any text to be written to the output stream.

<COUNTER_1_VALUE>

CodeGen provides two built in counters that developers can use when designing template files. For each code generation task both counters start off with a value of zero. Tokens in the template file can cause the value of each counter to be incremented, decremented or reset to zero. Another token can be used to insert the current value of a counter into the text output stream.

Inserts the current value of counter 1 into the output stream. If the token appears inside of an expression that currently evaluates to false then the value will not be inserted.

<COUNTER_2_DECREMENT>

CodeGen provides two built in counters that developers can use when designing template files. For each code generation task both counters start off with a value of zero. Tokens in the template file can cause the value of each counter to be incremented, decremented or reset to zero. Another token can be used to insert the current value of a counter into the text output stream.

This token decrements the value of counter 2 by 1. If the token appears inside of an expression that currently evaluates to false then the value will not be decremented.

This token does not cause any text to be written to the output stream.

<COUNTER_2_INCREMENT>

CodeGen provides two built in counters that developers can use when designing template files. For each code generation task both counters start off with a value of zero. Tokens in the template file can cause the value of each counter to be incremented, decremented or reset to zero. Another token can be used to insert the current value of a counter into the text output stream.

This token increments the value of counter 2 by 1. If the token appears inside of an expression that currently evaluates to false then the value will not be incremented.

This token does not cause any text to be written to the output stream.

<COUNTER_2_RESET>

CodeGen provides two built in counters that developers can use when designing template files. For each code generation task both counters start off with a value of zero. Tokens in the template file can cause the value of each counter to be incremented, decremented or reset to zero. Another token can be used to insert the current value of a counter into the text output stream.

This token resets the value of counter 2 to 0. If the token appears inside of an expression that currently evaluates to false then the value will not be reset.

This token does not cause any text to be written to the output stream.

<COUNTER_2_VALUE>

CodeGen provides two built in counters that developers can use when designing template files. For each code generation task both counters start off with a value of zero. Tokens in the template file can cause the value of each counter to be incremented, decremented or reset to zero. Another token can be used to insert the current value of a counter into the text output stream.

Inserts the current value of counter 2 into the output stream. If the token appears inside of an expression that currently evaluates to false then the value will not be inserted.

<DATABASE>

 

Inserts the name of the current relational database being targeted. For more information refer to the command line option -database.

 

Possible Values:  MySQL, PostgreSQL, SQLServer

See also:  Command line option -database, Environment variable CODEGEN_DATABASE_TYPE

<DATE>

Inserts the current date in MM/DD/YYYY format.

Example: 10/23/2008

<DATE1>

Inserts the current date in DD/MM/YYYY format.

Example:  23/10/2008

<DAY>

Inserts the current numeric day of the month in DD format.

Example:  23

<DAYNAME>

 

Inserts the current alphabetic day of the week.

 

Example:  Monday

<ENV:variable>

Inserts the value of an environment variable into the output stream. If the environment variable does not exist then an error is generated.

Note that the translation value of the environment variable may generic and structure expansion tokens.

<ENVIFEXIST:variable>

Inserts the value of an environment variable into the output stream. If the environment variable does not exist then the token will be ignored and no error will be generated.

Note that the translation value of the environment variable may generic and structure expansion tokens.

<FILE:name.ext>

Video: Using Template Include Files

This token reads the content of a text file and inserts the resulting data into the output stream. The file can either be located in the current directory, or you can include a logical name specification to specify the location of the file. If the file is not found then an error is generated.

The file may contain any number of lines of text, and may also contain generic or structure expansion tokens, which will be expanded in the usual way. If the token exists on the same line as and subsequent to other text, then the first record from the file will follow that text in the resulting output file. Any subsequent records from the file will appear on new lines in the output file.

Examples:  <FILE:name.ext>, <FILE:LOCATION:name.ext>

<FILEIFEXIST:name.ext>

Video: Using Template Include Files

This token reads the content of a text file and inserts the resulting data into the output stream. The file can either be located in the current directory, or you can include a logical name specification to specify the location of the file. If the file is not found then the token is ignored and no error is generated.

The file may contain any number of lines of text, and may also contain generic or structure expansion tokens, which will be expanded in the usual way. If the token exists on the same line as and subsequent to other text, then the first record from the file will follow that text in the resulting output file. Any subsequent records from the file will appear on new lines in the output file.

Examples:  <FILEIFEXIST:name.ext>, <FILEIFEXIST:LOCATION:name.ext>

<GUID>

 

(Several variations, see notes)

CodeGen supports inserting GUID values into generated code.

 

Example:  {8d881f51-8d3e-4ee7-9e20-17ee24452da9}

Tokens:  <GUID>, <GUID_NOBRACE>, <GUID1>, <GUID1_NOBRACE>, <GUID2>, <GUID2_NOBRACE>, <GUID3>, <GUID3_NOBRACE>

The <GUID> and <GUID_NOBRACE> tokens always generate a new GUID value every time they are encountered, either with or without surrounding brace characters.

The tokens that include numbers (e.g. <GUID1>) generate a new GUID value the first time they are encountered, but then maintain that same value for the remainder of that invocation of CodeGen. The <GUID1>, <GUID2> and <GUID3> tokens can be used to persist and refer back to up to three separate GUID values.

Alternates:  <guid>, <guid_nobrace>, <guid1>, <guid1_nobrace>, <guid2>, <guid3_nobrace>, <guid3>, <gui3_nobrace>

<HOST_DNS_NAME>

 

Inserts the DNS name of the computer that you are running CodeGen on. If there is a problem determining the DNS name then "LOCALHOST" is used.

 

Example: IVES.SYNERGEX.COM

Alternates: <host_dns_name>

<HOST_IP_ADDRESS>

 

Inserts the IP address name of the computer that you are running CodeGen on. If the system has multiple IP addresses then the first IP address reported by Windows is used. If there is a problem determining the IP address then the "localhost" address of "127.0.0.1" is used.

 

Example:  10.1.1.254

<MONTH>

Inserts the current numeric month (MM).

Example:  10

<MONTHNAME>

Inserts the alphanumeric name of the current month.

Example:  October

<MONTHSHORTNAME>

Inserts the abbreviated alphanumeric name of the current month.

Example:  Oct

<NAMESPACE>

Inserts the default namespace, which can be specified either via the environment variable SYNDEFNS, or via the -n command line option.

Example:  SynPSG.CodeGen

If a namespace token is encountered and no default namespace can be determined then CodeGen will report an error.

<RANDOM_10>

Inserts a random number in the range of 1 to 10.

 

<RANDOM_100>

Inserts a random number in the range of 1 to 100.

 

<RANDOM_1000>

Inserts a random number in the range of 1 to 1000.

 

<RANDOM_INT>

Inserts a random number in the range of 1 to 2147483647.

 

<TEMPLATE>

Inserts the base name of the template file. The base name of the template is the name of the template file with no file extension.

 

Example (if processing a template called get_record.tpl): GET_RECORD

Alternates:  <template>

<TIME>

Inserts the current time in 24 hour HH:MM format.

Example: 16:06

<TIMEZONE_OFFSET>

Inserts the current timezone offset from UTC in [+-]HH:MM format.

 

Example: -08:00

 

<WEEKDAY>

Inserts the name of the current weekday.

Example: Thursday

<YEAR>

Inserts the current year in YYYY format.

Example: 2020

 

 


Copyright © 2021  Synergex International, Inc.