The Conditional Statements

Description

Decision structures in Caravan script are created using If-endif and if-else-endif conditional statements. You can test conditions and then, depending on the results of that test,perform different operations. The condition is usually a comparison, but it can be any expression that evaluates to a value.You can place If statements inside of other conditional statements. You must end all If statements with EndIf or you will get an error message. The if-else-endif statement can be nested within one another. Care must be taken that each if is ended with a corresponding endif. With The GoTo and Label Statements Conditional Jump/s are allowed in program.


The if-endif statement

Description

The if-endif statement perform the task of checking a Condition if it returns true.If the Condition is Satisfied statement/s within the if-endif construct are executed. The If-Endif Does not check the False Part of Condition.

Syntax

if condition

statement1
statement2
.
.
.
endif

The if-else-endif statement

Description

The if-else-endif statement perform the task of checking a Condition if it returns true or false.If the Condition is Satisfied then statement/s within the if construct are executed else if the condition is not satisfied then statements within the else part are executed.

Syntax

if condition
statement1
statement2
.
.
else
statement1
statement2
.
.
endif

The if-elseif-endif statement

Description

The if-elseif-endif construct perform the task of checking multiple Conditions. If a particular condition is Satisfied then statement/s within that if construct are executed.The if-elseif-endif may have an optional else part.

Syntax

if condition

statement1
statement2
.
.
.
elseif condition

statement1
statement2
.
.
.
elseif condition

statement1
statement2
.
.
.
else statement1
statement2
.
.
.
endif

The GoTo and Label statement

Description

The Goto Statement is used with the Label Statement. Goto statement is specified with the Label variable to allow a conditional Jump matching the Specified Label's Label variable. Statements within the specified Matching Label variable are executed. There can be multiple goto statements in a program each with a different label variable.

Syntax

Goto LabelVariable1

Label LabelVariable1
Statement1
Statement2
.
.
Goto LabelVariable2

Label LabelVariable2
Statement1
Statement2
.
.

Back

 

 
© Copyright 2002 Niti Telecom Consultancy. All rights reserved