PxPlus User Forum

Twitter Twitter Twitter

Author Topic: Field Count, Field Separators, Number of Fields  (Read 497 times)

Patrick Denny

  • Member
  • **
  • Posts: 9
    • View Profile
Field Count, Field Separators, Number of Fields
« on: December 04, 2022, 11:13:35 PM »
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]
« Last Edit: December 05, 2022, 06:40:31 PM by Patrick Denny »