In some situations, I have found that I need to write a routine that is too complicated for SB+.
When using a SB+ screen, there is a nice ability to show who has locked the same record with options to abort or wait.
To see how this is done, simply generate the code for a simple screen and then using your favorite editor, have a look at the resultant code, searching for a READ statement, e.g.
LOCK.KEY = KEY READU RECORD FROM F.FILE,KEY LOCKED LOCK.KEY = '' CALL SB.DISP.LOCK(MAINFILE<1>,KEY<1>,ESC) IF ESC THEN STEPNO = KEYSTEP END RETURN END THEN FOUND = 1 ELSE FOUND = 0 * IF FOUND THEN ...... END ELSE ...... END
The MAINFILE variable holds the actual text name of the file and is not a file variable.
Using similar code as above in your own routine which reads a record, replacing the
IF ESC THEN with your required exit action (if possible else keep looping) and the final
IF THEN END ELSE END with your next actions.
EQUATE EMPTY.STR TO '' FOUND = EMPTY.STR LOOP UNTIL FOUND NE EMPTY.STR DO READU RECORD FROM F.FILE,KEY LOCKED CALL SB.DISP.LOCK(MAINFILE<1>,KEY<1>,ESC) IF ESC THEN * Either continue, return or if can not, inform the user CALL SB.DISP(3,'Can not ABORT process. Please wait for other user to finish.') END END THEN FOUND = @TRUE ELSE FOUND = @FALSE REPEAT IF FOUND THEN ...... END ELSE ...... END
All is nice structured code and will provide a consistent SB+ interface for the user.