GetArrayItem(Array$,SeparatorChar$,Position)
|
|
Description
|
|
This function returns item from Array$ at defined Position. SeparatorChar$ is an array delimiter character.
Remember that each array item must be delimited by separator character. In fact, it can be any character from ASCII table (0-255), but we recommend to use less usual characters (#, *, /,|...).
Extended characters (127-255) can be added by CHR(number) code.
|
|
Code Examples
|
|
This code show item1..item5 in message box.
Items$ = 'item1#item2#item3#item4#item5#'
For i = 1 To 5
ArrayItem$ = GetArrayItem(Items$,#,i)
Message("Obtained array item: ","ArrayItem$")
Next i
Here is more advanced example:
This code returns selected item(s) from ListBox object
ListBoxGetSelectedItems("ListBox","Items$,ItemsNum$,#,NumItems")
For i=NumItems To 1
ArrayItem$ = GetArrayItem(Items$,#,i)
Message("Selected item: ","ArrayItem$")
Next i
|
|
Additional Info
|
|
Coma (,) character cannot be (by default) used as an array delimiter. However, there is a trick, how to use it ;)
Instead of this..
Name$=GetArrayItem(String$,',',1)
or this..
Name$=GetArrayItem(String$,,,1)
use this..
Name$=GetArrayItem(String$,'0x2C',1)
..where the 0x2C code is just the hexadecimal representation of the coma character (in ASCII table).
|
|
GetArrayNum(Array$,SeparatorChar$)
|
|
Description
|
|
This function returns a number of Items in the Array$ with predefined delimiter (SeparatorChar$).
This function is useful in cases if you don't know the number of items in the array.
|
|
Code Examples
|
|
This code show item1..item5 in message box.
Items$ = 'item1#item2#item3#item4#item5#'
NumOfItems=GetArrayNum(Items$,#)
For i = 1 To NumOfItems
ArrayItem$ = GetArrayItem(Items$,#,i)
Message("Obtained array item: ","ArrayItem$")
Next i
|
|
|