Field Count, Field Separators, Number of Fields

Started by Patrick Denny, December 04, 2022, 11:13:35 PM

Previous topic - Next topic

Patrick Denny

I had difficulty determining the Number of Fields (Field Separators) as defined by a file's internal Dictionary.
Here is the solution I came up with to determine the Number of Field Separators:

LET FCHN = HFN
OPEN INPUT (FCHN,IOL=*)"FILE"
!
LET FCNT = POS(SEP=REC(IOL(FCHN)),1,0) ; REM "---<<< Here's the code >>>
!
CLOSE (FCHN)

You could substitute $8A$ for SEP if that is required?
Use OPEN INPUT vs. OPEN, if doing an immediate CLOSE?

If issuing a DIM array definition, don't forget to reduce the number of array elements by 1, if your first ARRAY element starts at Zero (default).

DIM X$[10]  Creates 11 element array with elements X$[0] thru X$[10]
DIM X$[0:10] Same as above
DIM X$[1:6] Creates 6 element array with elements X$[1] thru X$[6]