**CIGAL Reference Manual, Chapter 2 (Commands): IF** ===== IF -- Conditional test within a CIGAL macro program ===== **usage: if(expression) command**\\ **or: if(expression) command**\\ **or: if(expression) {...many commands}**\\ **or: if(expression) {...many commands} else {...many commands}**\\ The IF statement is used to control the flow of command execution. The "expression" argument to the IF command can be anything that evaluates to a number. If the number is not zero, then the IF tests true; if the expression results in a zero value, then the test is false. A TRUE result means that the 'command' part of the IF statement is executed as the next command; or if the brackets are used, then the whole block of commands between the pair of brackets are executed. The ELSE part of the command is skipped if the result was TRUE. If the result was FALSE, then the first command or block of commands is skipped and only the commands in the ELSE block, if present, are executed. Any number of commands can be enclosed within a pair of brackets. If an end-of-file is encountered before the closing bracket, then an error is reported. IF statements can be nested in macro programs up to 20 blocks deep. Spaces are optional within the test condition of an IF statement, but there must be no spaces between the IF and the left parenthesis, '(', and there must be a space after the last right parenthesis of the test condition. NOTE: When comparing character strings only an exact match will make '==' true. For '!=' to be true the two strings must differ at some character; if one string is an abbreviation of the other, then '!=' will be false. If you want to accept abbreviations, test if STRING1 %%<=%% STRING2. An empty string will always be != to a nonempty string. Valid examples: if(a) ftype 'A= %d is nonzero\n' a if(accept('Enter yes or no',string) <= 'yes') return if(a > 2 & b < 100 | (a == 5 & b > 0)) { c = 1 } else { type 'Values out of range' if(c == 0) return } if(a > 2) return Invalid examples: if (a > 2) return ; space between IF and ( if(a > 2)return ; no space between ) and RETURN **See Also:**\\ [[jvs:cigal|CIGAL Home]], [[jvs:cigal:manual|CIGAL Manual]], [[jvs:cigal:manual:chapter2|Commands List]], [[jvs:cigal:manual:help|Manual Help]]