Products Downloads


French version


 


ADELIA

VADELIA

SADELIA

WADELIA

EADELIA

(I/B)

(I/B) (C/S)

(B) (S)

(I/B) (C/S)

(B) (C/S)


Section for use

All


Syntax

IF VarId1 LogicalOperator VarId2

DO_WHILE VarId1 LogicalOperator VarId2


Description

The various logical operators can be used to test the content or value of specific fields in comparison expressions (IF... or DO_WHILE...). You can combine more than one test in the same expression by using the AND and OR linking operators.


Where numeric fields are compared, fields of different lengths are aligned according to the decimal point.

Where alphanumeric fields are compared, fields of different lengths are aligned from the character at the extreme left. The shorter field will be filled with spaces to make it the same length as the (initially) longer field.


Positive fields are always greater than negative fields.


Numeric fields cannot be compared with alphanumeric fields.


A set of brackets can be used.


The EQUAL operator ( = ) can be used as follows:

IF VAR = A;B;C;D

In this case, the program tests whether the variable VAR is equal to A or B or C or D. The linking term OR is implied.


The NOT EQUAL operator ( <> ) can be used as follows:

IF VAR <> A;B;C;D

In this case, the program tests whether the variable VAR is not equal to A and B and C and D. The linking term AND is implied.


Note: The >, <, >= and <= comparisons are done with respect to the EBCDIC character sequence when working with RPG generator, and the ANSI character sequence with the C generator.


Example

IF OPTION_CODE <> '2';'3';'4'

ERROR

END

*

IF TOTAL <> 0 AND PAYMENT_CODE <> 'CASH'

RESULT = TOTAL + ( TOTAL * TAX_1 / 100 )

ELSE

RESULT = TOTAL + ( TOTAL * TAX_2 / 100 )

END

*

IF ANSWER = 'YES';'JA';'SI';'OUI';'DA'

CALL PRINT_LIST

END

*

READ CUSTOMERS

DO_WHILE CUSTOMERS EXISTS AND LINE_NUMBER <= 50

PRINT CUST_INFO

LINE_NUMBER = LINE_NUMBER + 1

READ CUSTOMERS

REDO


↑ Top of page

  • Aucune étiquette