! ----- VALID_FILE.FUN ----- ! ! ----- FUNCTION TO SEE IF FILE EXISTS ----- ! ! ---------- PASSED: ---------- ! ----- FILE_SPEC = File spec to search for ! ---------- RETURNED: ---------- ! ----- VALID_FILE = TRUE if the passed filespec exists, else ! ----- FALSE ! ! ----- Last Change 07/06/93 by Brian Lomasky ----- ! FUNCTION WORD VALID_FILE(STRING FILE_SPEC) %INCLUDE "NUSER.INC" %INCLUDE "$FABDEF" %FROM %LIBRARY "SYS$LIBRARY:BASIC$STARLET.TLB" %INCLUDE "$NAMDEF" %FROM %LIBRARY "SYS$LIBRARY:BASIC$STARLET.TLB" %INCLUDE "$RMSDEF" %FROM %LIBRARY "SYS$LIBRARY:BASIC$STARLET.TLB" DECLARE FABDEF FAB ! DEFINE THE FAB BLOCK DECLARE LONG LOCAL_STATUS ! SYSTEM SERVICE EXIT STATUS DECLARE NAMDEF NAM ! DEFINE THE NAM BLOCK EXTERNAL LONG FUNCTION SYS$PARSE! $PARSE SYSTEM SERVICE EXTERNAL LONG FUNCTION SYS$SEARCH ! $SEARCH SYSTEM SERVICE ! ----- FIXED-LENGTH STRINGS PASSED TO/FROM RMS ----- MAP (FPARSE) STRING SEARCH_SPEC = 255%, & STRING EXPANDED_SPEC = 255%, & STRING RESULT_SPEC = 255% SEARCH_SPEC = FILE_SPEC ! STORE PASSED FILE SPEC EXPANDED_SPEC = "" ! CLEAR EXPANDED FILE SPEC RESULT_SPEC = "" ! CLEAR RESULTING FILE SPEC ! ----- SET UP THE FAB BLOCK ----- FAB::FAB$B_BID = FAB$C_BID ! FAB BLOCK IDENTIFIER FAB::FAB$B_BLN = FAB$C_BLN ! FAB BLOCK LENGTH ! ----- LOCATION OF PASSED FILE SPEC ----- FAB::FAB$L_FNA = LOC(SEARCH_SPEC) FAB::FAB$B_FNS = LEN(FILE_SPEC) ! LENGTH OF PASSED FILESPEC FAB::FAB$L_NAM = LOC(NAM) ! LOCATION OF NAM BLOCK ! ----- SET UP THE NAM BLOCK ----- NAM::NAM$B_BID = NAM$C_BID ! NAM BLOCK IDENTIFIER NAM::NAM$B_BLN = NAM$C_BLN ! NAM BLOCK LENGTH IF NAM$C_MAXRSS > 127% THEN ! ----- SIZE OF RESULTING SPEC ----- NAM::NAM$B_RSS = NAM$C_MAXRSS - 256% ELSE ! ----- SIZE OF RESULTING SPEC ----- NAM::NAM$B_RSS = NAM$C_MAXRSS END IF ! ----- LOCATION OF RESULTING SPEC ----- NAM::NAM$L_RSA = LOC(RESULT_SPEC) IF NAM$C_MAXRSS > 127% THEN ! ----- SIZE OF EXPANDED SPEC ----- NAM::NAM$B_ESS = NAM$C_MAXRSS - 256% ELSE ! ----- SIZE OF EXPANDED SPEC ----- NAM::NAM$B_ESS = NAM$C_MAXRSS END IF ! ----- LOCATION OF EXPANDED SPEC ----- NAM::NAM$L_ESA = LOC(EXPANDED_SPEC) LOCAL_STATUS = SYS$PARSE(FAB) ! GET INITIAL FILE INFORMATION IF LOCAL_STATUS = RMS$_DNF THEN ! IF DIRECTORY NOT FOUND: VALID_FILE = FALSE ! RETURN "NON-EXIST" STATUS EXIT FUNCTION END IF IF (LOCAL_STATUS AND 1%) = 0% THEN PRINT "Error for SYS$PARSE: " + NUM1$(LOCAL_STATUS) CALL LIB$STOP(LOCAL_STATUS BY VALUE) END IF ! ----- GET THE REST OF THE FILE INFORMATION ----- LOCAL_STATUS = SYS$SEARCH(FAB) IF (LOCAL_STATUS AND 1%) = 0% THEN VALID_FILE = FALSE ! RETURN "NON-EXIST" STATUS ELSE VALID_FILE = TRUE ! RETURN "FILE EXISTS" STATUS END IF END FUNCTION