REBOL for COBOL programmers |
IF
Date written: October 10, 2012 This page explains the REBOL equivalent of IF. COBOL IFThe COBOL IF is something like this: IF condition-1 imperative-statement-1 ELSE imperative-statement-2 .The imperative statements can be any number of statements, and they are executed until a period is encountered. The REBOL equivalentREBOL has an IF statement that looks something like this: if condition-1 [ imperative-statement-1 ]Where the statements in the brackets are executed when the condition is true. The ELSE option is like this: either condition-1 [ imperative-statement-1 ] [ imperative-statement-2 ]The imperative-statement actually can be many statements, just like COBOL. Now as to that condition, you may code it like a COBOL condition, you may use parentheses to make it readable, you may use functions that will be evaluated and the results plugged into the condition. The variations are too many to be listed. One thing to be aware of is what makes a condition true, or false. A COBOL-like condition is pretty obvious. Less obvious are other variations. The condition could be a word, and if the word is defined and has a value, the condition is true. If the word is undefined or has a value of "none," the condition is false. You also have to be wary of datatypes. A "character" datatype of "a" is not the same as a "string" datatype of "a" and so a comparison will be false. This is a big area to check if it appears that you are getting a "false" result on a condition that appears "true" to you. |