Chapter 9 Generation Reference Guide (GTL)


if macro

The if macro is used for conditional generation, it has the following syntax:

if=			.if[not] <condition>
			<complex-template>
			[(.elsif[not] <condition>
			<complex-template>)*]
			[.else
			<complex-template>]
			.endif ['(' <tail> ')']
condition=	'(' <condition> ')' or '(' <condition> ')'	|
			'(' <condition> ')' and '(' <condition> ')'																			|
			'(' <condition> ')'																											|
			<simple-condition>
simple-condition=		<variable> [ <comparison-operator> <condition-rhs> ]
comparison-operator=	'=='	|
							'!='	|
							'<='	|
							'>='	|
							'<'		|
							'>'		|
condition-rhs=			<simple-template>	|
							<string-constant>	|
							true					|
							false					|
							null					|
							notnull				|
string constant=			'"' <text> '"'

Parameters

Parameter Type Description
<tail> Text Appended to the output, if there is one

When a simple condition consists of a single variable without any comparison operator, the condition is false if the value of the variable is "false", "null" or the null string, otherwise it is considered to be true.

The <, >, >=, and <= comparison operators perform integer comparisons if both operands are integers, otherwise they induce an intelligent string comparison that takes into account embedded numbers (example: Class_10 is greater than Class_2).

 


Copyright (C) 2005. Sybase Inc. All rights reserved.