I’m trying to use the Split command to create a list array from a comma delimited string.
I can’t seem to get the syntax right and was wondering if anyone could help.
Here is my code:
Sub ParseDiscountTransactionIds(Ref discountTransactionId)
Var discountTransactionIdList : A512 = "21,32,43,54"
Var numberRecords : N5 = 4
Var result[10] : N5
Split discountTransactionIdList, chr(44), numberRecords, result[]
discountTransactionId = result[1]
EndSub
It fails (produces an ISL error – Invalid List Size) on the bolded line. I interpret the error to mean that the split command is expecting four variables, not two (I am using the list_spec syntax).
This works:
Sub ParseDiscountTransactionIds(Ref discountTransactionId)
Var discountTransactionIdList : A512 = "21,32,43,54"
Var record0 : N5
Var record1: N5
Var record2: N5
Var record3: N5
Split discountTransactionIdList, chr(44), record0, record1, record2, record3
discountTransactionId = record1
EndSub
But, according to the syntax below, the command should work for a list array.
Syntax (entered as a single line)
Split string_to_split, field_sep_char, user_variable or list_spec [, user_variable or list_spec...]
Argument/Description
string_to_split - the field-separated string to split
field_sep_char - the character used to the separate fields in the string_to_split; use the Chr function to define the character required
user_variable - a user_variable which will be assigned one of the individual fields from the string_to_split
list_spec is defined as:
· number_records: a user integer variable containing the number of records to be built from the string_to_split
· field_array[: field_array]: an array_variable that will hold one field per record; you can split a field into more than one array by separating the array_variables using a colon ( : )
I can’t seem to get the syntax right and was wondering if anyone could help.
Here is my code:
Sub ParseDiscountTransactionIds(Ref discountTransactionId)
Var discountTransactionIdList : A512 = "21,32,43,54"
Var numberRecords : N5 = 4
Var result[10] : N5
Split discountTransactionIdList, chr(44), numberRecords, result[]
discountTransactionId = result[1]
EndSub
It fails (produces an ISL error – Invalid List Size) on the bolded line. I interpret the error to mean that the split command is expecting four variables, not two (I am using the list_spec syntax).
This works:
Sub ParseDiscountTransactionIds(Ref discountTransactionId)
Var discountTransactionIdList : A512 = "21,32,43,54"
Var record0 : N5
Var record1: N5
Var record2: N5
Var record3: N5
Split discountTransactionIdList, chr(44), record0, record1, record2, record3
discountTransactionId = record1
EndSub
But, according to the syntax below, the command should work for a list array.
Syntax (entered as a single line)
Split string_to_split, field_sep_char, user_variable or list_spec [, user_variable or list_spec...]
Argument/Description
string_to_split - the field-separated string to split
field_sep_char - the character used to the separate fields in the string_to_split; use the Chr function to define the character required
user_variable - a user_variable which will be assigned one of the individual fields from the string_to_split
list_spec is defined as:
· number_records: a user integer variable containing the number of records to be built from the string_to_split
· field_array[: field_array]: an array_variable that will hold one field per record; you can split a field into more than one array by separating the array_variables using a colon ( : )