[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
#I
) The If command allows Cogsys to conditionally skip parts of the testlist. The first part of an If command specifies an expression to be evaluated. Constants allowed in the expression include
These may then be grouped into terms with standard relational operators. Terms may then be concatenated by logical operators into expressions. The complete grammar is enumerated below.
If statements may be nested up to IF_NESTLEVEL
levels deep.
Important: To ensure fast execution, the If statement skips the true-clause by looking for a matching brace in input. It does not start running a new interpreter on the subclause. For this reason, Cogsys does not understand the context of the brace characters it encounters as it skips over a clause. Thus, any brace characters in a clause that do not delimit nested clauses will cause unexpected results, even if they are escaped or part of another command.
For example, the following code will not behave as expected:
#I(5>2){#G[these braces{} in true clause confuse #I]}{false clause} |
#I
#Iexpr{true-clause}{false-clause}
White space is ignored between all tokens.
#I
constructs from old code will likely still work in
Cogsys 3.x.
#I(2>3 OR 4>1){This clause is true.}{This clause is false}
Press the letter 'A': #R
#I(K=&a O K=&A){You pressed a#I(K=&a)
{ lowercase}{n uppercase} 'A'.}{No, I said press an 'A'!}
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |