Split Function Returns an Object List.
Turnovus
24 Apr 2020, 06:13I'm trying to use the Split()
function to split up a string into a list of strings, as is the intended purpose. The strings I'm using look something like this:
1;Curse;10
However, instead of returning a list of strings, the function returns a list of objects. So if I try doing something like this:
splitlist = split ( "1;Curse;10" )
ToInt (ListItem (splitlist, 2) )
That causes this error:
FunctionCallElement: Could find not function 'ToInt(Object)'
Basically, what am I doing wrong?
mrangel
24 Apr 2020, 07:20It's not an objectlist.
ListItem
has a declared return type of 'string or object`, because you can use it on any type of list.
But because Split
is a built-in function, Quest checks that the function inside of it has a declared return type of 'string' before even attempting to run it.
splitlist = split ( "1;Curse;10" )
listitem = ListItem (splitlist, 2)
ToInt (listitem)
will work fine; because it asks "what type is this variable?", rather than "what type can ListItem
return?"
This is why there is a separate function StringListItem
, which only works on stringlists.