Previous Topic: Explanation of SCREEN2 ProgramNext Topic: KEY, ENTER, HOME, and TABF Statements


COMPARE and BRANCH Statements

The following COMPARE statement checks to see if you are at the ISPF Primary Option screen by comparing the 14 characters starting at position 31 with the string "PRIMARY OPTION". If you are at the ISPF Option screen, the first BRANCH statement directs the program to the line labeled EDIT, which prepares a TSO data set member to receive the data from the array. If you are not at the ISPF Primary Option screen, the PF statement simulates the PF3 key to back out to the option screen. The second BRANCH statement then directs the program to execute the COMPARE statement again.

COMPARE &SCREEN(31,14),'PRIMARY OPTION' 
BRANCH EQ,EDIT 
PF 3 
BRANCH ANY,ELOOP

The SEARCH command could have been used here to produce the same result. The difference between the SEARCH and COMPARE statements is that the COMPARE statement will determine if the string is in a particular place on the screen and the SEARCH statement simply determines whether the string is displayed somewhere on the screen.