DELIM.POS Function
Gets the position of a specified delimiter in a dynamic array.
Syntax
Position = DELIM.POS(array<a {,v {,s}}> {, position})
Syntax elements
aAttribute number.
vValue number.
sSubvalue number.
positionA string starting with one of the following characters:
BOffset of delimiter before the specified element.
EOffset of delimiter delimiting the specified field.
Only the character in the first position is significant. Subsequent characters are ignored. If the string is not specified or the first character is not a B or an E, B is assumed. If keyword case-insensitivity is selected, the parameter can be in upper- or lower-case; otherwise, it must be upper-case.
Operation
The function returns the value of the character position of the system delimiter immediately preceding or following the requested system element of the specified dynamic array. If the requested element does not exist in the dynamic array, a value of -1 is returned.
If the end delimiter is specified, any trailing zero values of value and subvalue numbers will be ignored; that is:
DELIM.POS(ARRAY<1,0,0> ,"E") will be treated as DELIM.POS(ARRAY<1> ,"E")
Returning the offset of the delimiting delimiter of the first attribute.
DELIM.POS(ARRAY<1,1,0> ,"E") will be treated as DELIM.POS(ARRAY<1,1> ,"E")
Returning the offset of the delimiting delimiter of the first value.
DELIM.POS(ARRAY<1,1,1> ,"E")
Will return the offset of the delimiting delimiter of the first sub-value.
Note: Unlike regular dynamic array notation all of the attribute, value and sub-value numbers can all be negative; that is:
DELIM.POS(ARRAY<-1,-1,-1>)
Will return the offset of the delimiter prior to the last subvalue of the last value of the last attribute of the dynamic array ARRAY.
MultiValue compatibility
Refer to MultiValue Compatibility.
Example 1
READ ITEM FROM SALES,"2012" THEN SPOS = DELIM.POS(ITEM<100>, "B") + 1 EPOS = DELIM.POS(ITEM<120>, "E") IF EPOS GT 0 THEN PARTITEM = ITEM[SPOS, EPOS-SPOS] END ELSE PARTITEM = "" END END
Reads item 2012 from the file opened to the SALES file variable.
If the item exists, it saves the position of the first character of the 100th attribute of sales item in SPOS.
Saves the position of the end delimiter of the 120th attribute of sales item in EPOS.
Ensures both offsets are positive; that is, both attributes exist in the dynamic array.
Save attributes 100 through to 120 in variable PARTITEM.
Example 2
READ ITEM FROM SALES,"2012" THEN RESTART = DELIM.POS(ITEM<100,4,2>) IF RESTART GE 0 THEN REMOVE.POS(ITEM) = RESTART REMOVE PART FROM ITEM TO @SVM SETTING SET END END
Reads item 2012 from the file opened to the SALES file variable.
Saves the position of the start of the 2nd sub-value of the 4th value of the 100th attribute of sales item in RESTART.
Ensures RESTART is positive; that is, field exists in the string.
If valid set the internal REMOVE pointer prior to the 2nd sub-value of the 4th value of the 100th attribute of the sales item.
Removes the 2nd sub-value of the 4th value of the 100th attribute from the sales item into PART and sets SET to the delimiter type.