PxPlus User Forum

Twitter Twitter Twitter

Author Topic: How to find the number of fields in a string  (Read 1567 times)

PxPlus

  • Administrator
  • Diamond Member
  • *****
  • Posts: 1091
    • View Profile
How to find the number of fields in a string
« on: May 30, 2018, 04:34:27 PM »
If you have a string with a series of delimited fields such as:
  "a,b,c,d,e,f,"

You can figure out the number of fields in the string by using the POS function to count the number of delimiters.

  Count = POS("," = <string>,1,0)

Giving the POS function a increment of 1 with an occurence number of zero causes it to return the count instead of the position.

The only thing to watch for is if the string does not have a trailing delimiter such as "a,b,c" -- in this case the number will be one too low.