Topic: string_split bug


When you try to do a string split, and there'a a carrage return enter char whatever, the function just seems to stop and not split anything. I'm not sure why. Is this a bug or something I have to figure out how to work around?

Re: string_split bug

Hi there,

Can you please provide an example of a script that fails, describe exactly how it's failing, and what the expected behavior for the particular script is? That way, I can look into it much faster.

Thank you.

Kind regards,

Philip Bennefall

Re: string_split bug


file game;
string[] name;

void main() {"names.txt","r");
show_game_window("crappy names");
string[] output=string_split(data,"
//There I'm trying to make it so the string splits on an enter. not sure if there's another keyboard command for a carrage return character
for(uint n=0;n<output.length();n++) {
//the for loop should get the names from the file, according to the string_split
speaker.speak_wait(names[1]+", "+names[2]+", "+names[3]);
//this should speak the first 3 names.}

On each line of the names.txt file is a name. in theory, 1 entry in the names array is 1 name in the file. but it doesn't work. it'll just set entry 0 of the array to every single name. It's probably not a bug I'm just not sure how else to do it

4 (edited by ClaudioSaez 2011-07-13 13:41:00)

Re: string_split bug

this is a bit strange point, but  you cant include the new line between quotes as you did.
try your code changing the line where you use string_split for this one:
string[] output=string_split(data,"\r\n",true);
that \r\n is what you have to use for new lines.
There are some special characters, difficult to include between quotes, so they are replaced by escape sequences. to read about them, open the help, language tutorial and inside that subject press control f and  look for the symbol \
Hope this helps

Re: string_split bug

thanks been trying to figure that out for ages