This section discusses various file handling techniques and tools.
Topics on this page include:
(empty), the open instruction will present the standard Windows open dialog window. The user can browse to the file of their choice.
To do this, the file name string must be completely nul. You can NOT include a partial file name like "*.JPG". If that's what you want to do, look at the next item: OPENDEFAULT.
These two don't actually perform any opening actions. Instead they set the default PROMPT and FILE MASK that will be used in other open methods. For example you could say
The next OPEN which gets Windows' open dialog will have that prompt and will only allow files with extension
This will just retreive information about an open file. If you open a file using a NUL name, which means that the user browses to the file of choice, you can use the
This is a simple instruction and it's well documented in the Sunbelt manuals.
We've added more information under:
GETFILE
Get information about a file after it's open.
This is really handy when you let the user enter the file name and they enter a blank which causes Windows to let them broswe for the file. You need some way to know which file they chose. Use GETFILE after the file is open,
then you can use FINDFILE to get even more information about the file.
[label] GETFILE {file},{keyword}={value}[,{keyword=value}...]
If the file is NOT OPEN, the ZERO flag is cleared and the variables remain unchanged.
If the file is OPEN, the ZERO flag is set.
The EOS flag is set if any variable overflows.
...........................
. Example
.
MYFILE FILE
FILENAME DIM 250
OPEN MYFILE, "ZZDATA"
GETFILE MYFILE, TXTNAME=FILENAME
IF ZERO
DISPLAY "File name is ",*HON,*LL,FILENAME,*PL,*HOFF
ELSE
DISPLAY "File is NOT OPEN"
ENDIF
Selected Keywords from the Sunbelt Visual PL/B manual. (There are lots more)
ISINAME={svar} qualified (with path) ISI file name.
MODE={nva} opened: 0=Not Defined, 1=EXCLUSIVE, 2=SHARE, 3=READ, 4=SHARENF.
PRTNAME={svar} name stored for a PFILE.
TXTNAME={svar} qualified (with path) text file name.
Check the manual for information relating to COMFILEs, PFILEs, etc.
Fillow this with a FINDFILE to get even more information about the file
VERSION 9.x: GETFILE FILEFORMAT={nvar}
Version 9 added a FILEFORMAT flag to the GETFILE. This gives some useful information about an ISI file.
The basic usage would be something like:
OPEN ISIFILE,"NAME"
GETFILE FILEFORMAT=NWK03
The language ref says the FILEFORMAT value contains bits with the following meaning
0x1 0000 0001 IFILE
0x2 0000 0010 AFILE
0x10 0001 0000 version 9.0x format
0x20 0010 0000 version 8.7x format
0x40 0100 0000 the ISI file supports file larger than 4BG.
The GETFILE FILEFORMAT should be given a 3 digit FORM field for the return value. That's because you're going to get a decimal number which could range from 0 to 255 (8 bit binary value).
Move that number to an INTEGER 1 to get the binary value in a single byte.
Move the INTEGER 1 to a DIM 1 so that you can do a logical AND against it.
Now test with the AND. If the ZERO flag is not set then the bit position you're testing has a 1. (1 AND 1 = 1 . . . 1 AND 0 = 0)
If you test multiple flags, be sure to move the integer to the DIM 1 again because the AND is destructive.
TEST_ISI_FILE IFILE
NWK03 FORM 3
INT1 INTEGER 1
WORK01 DIM 1
.
OPEN TEST_ISI_FILE,"TESTFILE"
GETFILE TEST_ISI_FILE, FILEFORMAT=NWK03
MOVE NWK03, INT1
.
MOVE INT1, WORK01
AND 0x1, WORK01
IF NOT ZERO
..... I file
ENDIF
.
MOVE INT1, WORK01
AND 0x2, WORK01
IF NOT ZERO
..... A file
ENDIF
.
MOVE INT1, WORK01
AND 0x10, WORK01
IF NOT ZERO
..... 9.x ISI
ENDIF
.
MOVE INT1, WORK01
AND 0x20, WORK01
IF NOT ZERO
..... 8.7 ISI
ENDIF
.
MOVE INT1, WORK01
AND 0x40, WORK01
IF NOT ZERO
..... allows 4GB files
ENDIF