Built array from string

expression

#1

I would like to be able to built a list or an array from a string. I send some arguments from web browser and I can extract those like this: john,alex,greg inside a variable but I would like to built a kind of array to be able to iterate through it. I could use some complex expression like left function with find…remove the found name and then do it again for the second one…
But it should have a function to get an array from those name with coma ? Or maybe another structure to allow it…? Thanks


#2

After reading various posts on the forum about building arrays, this is the solution I came up with. The input data is predictable so I know how far ahead to jump in the string each time. You would need to find the next delimiter each time I guess.

Summary


#3

Hi, thanks for your reply! Actually, I dont know the exact length of each elements but its separated with coma. Its arguments that are coming from url. I would like to have something like: name=bob,alex,george&value=12,34,55
The goal is to update variable with its name with the assossiated value. (you can replace the name by my global variable name). The things is that webcore not consider those args as array or json… So I cannot use $args.name[1] or something so no way to iterate through this.
For now, I have this solution that still have issues (the local variable not erasing at the end to stop the loop)
1- I open a for loop
2- check if args.name is not empty
3- for index =1 I just use left($args.name,indexof($args.name,",")) to get first item and store it in local variable
4- if index >1 then I use mid function with the local variable within the indexof() to get second item and store it…and then same formula will gives 3rd…etc…
5- if the length($args.name)>indexof(local var)+length(local var) == false then I set my local to “” and exit loop.
It works exept the local act weird at the end…I have 1 for the name and 1 for value and the one for the name takes in between values and the loop dont stop…
But its messy so I was thinking of simply set my local to $args.name and then built array with it since its already in the list form : aaa,bbb,cccc,dd
Hope webcore will allow to pass array from arguments once a day!