String split function and arrays

newbie-question

#1

I am using Axure 8 and it has a function to split a string into an array. I have not found any documentation or examples about how to use this in Axure. I would greatly appreciate it if someone could give me a brief code sample showing how to use the array that is returned from this function.

for an example… let’s say I have a global variable myStr

myStr = “Dave|Rita|Zoey|Maggie|Chelsea|CJ”

then if I set another global variable myArr that is the result of splitting myStr

set value of myArr to “[[myStr.split(’|’)]]”

result: myArr = “Dave”,“Rita”,“Zoey”,“Maggie”,“Chelsea”,“CJ”

All I want to do is something like

set value of Person to “[[ myArr[3] ]]” but this does not work

Any and all help will be greatly appreciated


#2

Hi!

As you can see, rather than creating an array, split() creates a comma delimited list. (Axure doesn’t have arrays.)

Okay, fine, but you’d think if that’s the non-array solution here, Axure would have provided a string method like listItemAtIndex(). Well, they didn’t.

Here’s a shabby workaround.

Live sample

To use it in your code, you can hide the UI, set text of both the list and the desire index fields using Set Text, use Fire Event OnClick on the Go button, and grab the text of the result rectangle. (Hey, I said it was shabby…)

get_list_item.rp (65.9 KB)


Random answers by chat bot
closed #3

unlisted #4