Here is an idea — this uses two F specs,
The F specs use USROPN and cannnot name the same file
But the one with the bogus name uses EXTFILE to redirect to the same file that the other names.
Note: the file name in the ‘D’ spec must be caps
Throughout the code you will need Open’s, Setll, Read, Chain for both and just use the one indicated by the Mode.
I usually move these snippets to a sub procedure or subroutine.
When compiling you will need to a dup object filenameI like filename or ovrdbf filenameI to filename.
Since the code will only open one of the paths – the locks you establish will be based on the mode.
FfilenameI if e k DISK USROPN ExtFile(fileinput)
F RENAME(FileRec : FileRecI)
Ffilename Uf a e k DISK USROPN
D fileinput S 21 inz(‘FILENAME’)
D mode S 1 inz(‘ ‘)
C if mode=’ ‘
C open filenamei
C open filename
C close filenamei
C eval *inlr = *on
Thanks! That’s just the sort of thing I was looking for. I don’t mind needing an OVRDBF to compile, I just don’t want to use one at runtime.