The latest find is always the one the availability check will work against - a unsuccesful find will make AVAILABLE
return false:
DEFINE TEMP-TABLE tt NO-UNDO
FIELD nr AS INTEGER.
CREATE tt.
tt.nr = 1.
CREATE tt.
tt.nr = 2.
CREATE tt.
tt.nr = 3.
DISPLAY AVAILABL tt. // yes (tt with nr = 3 is still available)
FIND FIRST tt WHERE tt.nr = 1 NO-ERROR.
DISPLAY AVAILABLE tt. //yes
FIND FIRST tt WHERE tt.nr = 2 NO-ERROR.
DISPLAY AVAILABLE tt. //yes
FIND FIRST tt WHERE tt.nr = 3 NO-ERROR.
DISPLAY AVAILABLE tt. //yes
FIND FIRST tt WHERE tt.nr = 4 NO-ERROR.
DISPLAY AVAILABLE tt. //no
A record found in "main" will be available in any procedures.
DEFINE TEMP-TABLE tt NO-UNDO
FIELD nr AS INTEGER.
PROCEDURE av:
DISPLAY AVAILABLE tt.
IF AVAILABLE tt THEN DO:
DISPLAY tt.nr.
END.
END PROCEDURE.
CREATE tt.
tt.nr = 1.
RUN av. // yes. tt.nr = 1
CREATE tt.
tt.nr = 2.
RUN av. // yes. tt.nr = 2
FIND FIRST tt WHERE tt.nr = 4 NO-ERROR.
RUN av. // no (and no tt.nr displayed)
Also, a record found in a procedure will still be available after that procedure has exited.
DEFINE TEMP-TABLE tt NO-UNDO
FIELD nr AS INTEGER.
PROCEDURE av:
FIND FIRST tt WHERE tt.nr = 1.
END PROCEDURE.
CREATE tt.
tt.nr = 1.
CREATE tt.
tt.nr = 2.
DISPLAY AVAILABLE tt WITH FRAME x1. // yes.
IF AVAILABLE tt THEN DO:
DISPLAY tt.nr WITH FRAME x1. //tt.nr = 2
END.
PAUSE.
RUN av.
DISPLAY AVAILABLE tt WITH FRAME x2. // yes.
IF AVAILABLE tt THEN DO:
DISPLAY tt.nr WITH FRAME x2. //tt.nr = 1
END.