Previous Topic: Compare Two StringsNext Topic: Use Substring Notation to Compare a Variable and a String


Compare a Variable and a String

Although you may not find a use for comparisons between two constant strings, you will probably find comparisons between variables and strings very useful. The following program shows a statement that determines whether the user ID entered by a user matches a valid user ID (in this case, USER1). If the user ID is valid, the program continues. If not, the program terminates.

           COMPARE '&USERID','USER1' 
           BRANCH EQ,MORE 
           STOP 
MORE       KEY 'Hello.' 
           STOP