Current Help System: Tutor Translator (View Core Help)

### DECODE Functions

The variables that are used as part of the ENCODE functions are defined as follows:

- INT_VAR is an Integer variable.

- IND is an integer variable.

- REAL_VAR is a real variable with format info (total and decimal digit)

- BOOL_VAR is a Boolean variable.

The logical function

DECODE(STR_VAR, INT_VAR,IND) translates to è

ASSIGN/DECODE_STR = MID(E.STR_VAR, E.IND-1)
ASSIGN/ E.INT_VAR = INT(DECODE_STR)

DO/
ASSIGN/INDX = STRPBRK(DECODE_STR," ,:;.")
ASSIGN/ E.IND = E.IND + INDX
ASSIGN/DECODE_STR = MID(E.STR_VAR, E.IND-1)
UNTIL/INDX <> 1

ASSIGN/DECODE = 1

IF DECODE(STR_VAR, INT_VAR,IND) THEN
. . . .
. . . .
END_IF translates to è

…….Same as DECODE(STR_VAR,INT_VAR,IND) function plus the following lines are added:

IF/DECODE == 1
. . . .
. . . .
END_IF/

BOOL_VAR=DECODE(STR_VAR, INT_VAR,IND) translates to è

…….Same as DECODE(STR_VAR,INT_VAR,IND) function plus the following line is added:

ASSIGN/ E.BOOL_VAR=DECODE

The logical function

DECODE(STR_VAR, REAL_VAR,IND) translates to è

ASSIGN/DECODE_STR = MID(E.STR_VAR, E.IND-1)
ASSIGN/ E.REAL_VAR = DOUBLE(DECODE_STR)

DO/
ASSIGN/INDX = STRPBRK(DECODE_STR," ,:;")
ASSIGN/ E.IND = E.IND + INDX
ASSIGN/DECODE_STR = MID(E.STR_VAR, E.IND-1)
UNTIL/INDX <> 1

ASSIGN/DECODE = 1

IF DECODE(STR_VAR, REAL_VAR,IND) THEN
. . . .
. . . .
END_IF translates to è

…….Same as DECODE(STR_VAR,REAL_VAR,IND) function plus the following lines are added:

IF/DECODE == 1
. . . .
. . . .
END_IF/

BOOL_VAR=DECODE(STR_VAR, REAL_VAR,IND) translates to è

…….Same as DECODE(STR_VAR,REAL_VAR,IND) function plus the following line is added:

ASSIGN/ E.BOOL_VAR=DECODE

The logical function

DECODE(STR_VAR, BOOL_VAR,IND) translates to è

ASSIGN/DECODE_STR = MID(E.STR_VAR, E.IND-1)
ASSIGN/ E.BOOL_VAR = DECODE_BOOL(DECODE_STR)

IF/ E.BOOL_VAR < 0
ASSIGN/DECODE = 0
END_IF/

ELSE/
ASSIGN/DECODE = 1

IF/ E.BOOL_VAR == 0
ASSIGN/ E.IND = E.IND+ INDEX(DECODE_STR,"FALSE")+4
END_IF/

ELSE/
ASSIGN/ E.IND = E.IND+ INDEX(DECODE_STR,"TRUE")+3
END_ELSE/
END_ELSE/

IF DECODE(STR_VAR, BOOL_VAR,IND) THEN
. . . .
. . . .
END_IF translates to è

…….Same as DECODE(STR_VAR,BOOL_VAR,IND) function plus the following lines are added:

IF/DECODE == 1
. . . .
. . . .
END_IF/

BOOL_VAR=DECODE(STR_VAR, BOOL_VAR,IND) translates to è

…….Same as DECODE(STR_VAR,BOOL_VAR,IND) function plus the following line is added:

ASSIGN/ E.BOOL_VAR=DECODE

The logical function

DECODE(STR_VAR,INT_VAR) translates to è

ASSIGN/ E.INT_VAR = INT(E.STR_VAR)
ASSIGN/DECODE = 1

IF DECODE(STR_VAR, INT_VAR) THEN
. . . .
. . . .
END_IF translates to è

…….Same as DECODE(STR_VAR,INT_VAR) function plus the following lines are added:

IF/DECODE == 1
. . . .
. . . .
END_IF/

BOOL_VAR=DECODE(STR_VAR,INT_VAR) translates to è

…….Same as DECODE(STR_VAR,INT_VAR) function plus the following line is added:

ASSIGN/ E.BOOL_VAR=DECODE

The logical function

DECODE(STR_VAR, REAL_VAR) translates to è

ASSIGN/ E.REAL_VAR = DOUBLE(E.STR_VAR)
ASSIGN/DECODE = 1

IF DECODE(STR_VAR, REAL_VAR) THEN
. . . .
. . . .
END_IF translates to è

…….Same as DECODE(STR_VAR,REAL_VAR) function plus the following lines are added:

IF/DECODE == 1
. . . .
. . . .
END_IF/

ASSIGN/BOOL_VAR=DECODE(STR_VAR, REAL_VAR) translates to è

…….Same as DECODE(STR_VAR,REAL_VAR) function plus the following line is added:

ASSIGN/ E.BOOL_VAR=DECODE

The logical function

DECODE(STR_VAR, BOOL_VAR) translates to è

ASSIGN/ E.BOOL_VAR = DECODE_BOOL(E.STR_VAR)

IF/ E.BOOL_VAR < 0
ASSIGN/ E.BOOL_VAR = 0
ASSIGN/DECODE = 0
END_IF/

ELSE/
ASSIGN/DECODE = 1
END_ELSE/

IF DECODE(STR_VAR, BOOL_VAR) THEN
. . . .
. . . .
END_IF translates to è

…….Same as DECODE(STR_VAR,BOOL_VAR) function plus the following lines are added:

IF/DECODE == 1
. . . .
. . . .
END_IF/

BOOL_VAR1=DECODE(STR_VAR, BOOL_VAR) translates to è

…….Same as DECODE(STR_VAR,BOOL_VAR) function plus the following line is added:

ASSIGN/ E.BOOL_VAR1=DECODE

IF DECODE(STR_VAR,INT_VAR) OR DECODE(STR_VAR, BOOL_VAR) THEN
. . . .
. . . .
END_IF translates to è

ASSIGN/ E.INT_VAR = INT(E.STR_VAR)
ASSIGN/DECODE = 1
ASSIGN/ E.BOOL_VAR = E.DECODE_BOOL(E.STR_VAR)

IF/ E.BOOL_VAR < 0
ASSIGN/ E.BOOL_VAR = 0
ASSIGN/DECODE_2 = 0
END_IF/

ELSE/
ASSIGN/DECODE_2 = 1
END_ELSE/

IF /DECODE==1 OR DECODE_2==1
. . . .
. . . .
END_IF/