Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

MICROS 3700 SIM Split Command 1

Status
Not open for further replies.

hannajo1

Programmer
Apr 10, 2015
8
US
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 ( : )
 
You need to put a # symbol for the number of records value.

Split discountTransactionIdList, chr(44), #4, result[]

Im not sure if you can use a variable for this or not. I assume you can, so it should be:

Split discountTransactionIdList, chr(44), #numberRecords, result[]

Do you want some custom SIM scripts developed. Contact me via my website
 
CathalMF - using a variable does work!
Split discountTransactionIdList, chr(44), #numberRecords, result[]

Thanks for the help!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top