pffff more problems
#1
Posted 06 April 2012 - 11:08 AM
The split string don't work in HTML5. Works on windows only for me.
Example:
conta_letras = split_string(numero_array_letras, ',','array_letras');
for (i=0; i<conta_letras; i+=1) {
show_message("content:"+array_letras[i]);
}
the problem is that the variable "array_letras" is always 0. I have try other explode scripts from the community but always the same problem. I thing he recognice the variable array_letras as a string.
Please can anyone help me with alternative way to split a string?
#2
Posted 06 April 2012 - 12:16 PM
Do you have an extension perhaps?
#3
Posted 06 April 2012 - 02:42 PM
There isn't a split_string() function in GML, where are you getting that from?
Do you have an extension perhaps?
sorry tou are right.
// Usage: split_string(string_to_split, delimiter, array_name)
// This script takes a string such as "123|456|dog|cat|3.14159" and splits
// it up into an array. The function returns the number of fields.
var i, p, ch, item, len, str, delimiter, array_name;
str = argument0;
delimiter = argument1;
array_name = argument2;
// If no second argument was passed, use the default delimiter (pipe):
if is_real(delimiter) { delimiter = "|" }
// If no third argument was passed, use the default destination array (split_values):
if is_real(array_name) { array_name = "split_values" }
i = 0;
item = "";
str += delimiter;
len = string_length(str);
for (p=1; p<=len; p+=1) {
ch = string_char_at(str, p);
if (ch == delimiter) {
variable_local_array_set(array_name, i, item);
item = "";
i += 1;
}
else {
item += ch;
}
}
return i;
#4
Posted 06 April 2012 - 03:02 PM
#5
Posted 09 April 2012 - 03:38 AM
Usage: string_explode(string, delimiter)
var c, i, j, k, s;
s = "";
i = 0;
k = string_length(argument0);
for (j = 1; j <= k; j += 1)
{
c = string_char_at(argument0, j);
if (c == argument1)
{
ARRAYNAME[i] = s;
s = "";
i += 1;
continue;
}
s = s + c;
}
if (s != "")
ARRAYNAME[i] = s;
#6
Posted 09 April 2012 - 01:25 PM
This will put it in to an array for you and does work in HTML5
Usage: string_explode(string, delimiter) var c, i, j, k, s; s = ""; i = 0; k = string_length(argument0); for (j = 1; j <= k; j += 1) { c = string_char_at(argument0, j); if (c == argument1) { ARRAYNAME[i] = s; s = ""; i += 1; continue; } s = s + c; } if (s != "") ARRAYNAME[i] = s;
GREAT, thanks.
#7
Posted 09 April 2012 - 01:29 PM
I'm pretty sure that's not going to work.
This will put it in to an array for you and does work in HTML5Usage: string_explode(string, delimiter) var c, i, j, k, s; s = ""; i = 0; k = string_length(argument0); for (j = 1; j <= k; j += 1) { c = string_char_at(argument0, j); if (c == argument1) { ARRAYNAME[i] = s; s = ""; i += 1; continue; } s = s + c; } if (s != "") ARRAYNAME[i] = s;
GREAT, thanks.
#8
Posted 10 April 2012 - 03:40 AM
#9
Posted 10 April 2012 - 05:07 AM
Yes but in your code the array name is static. You cannot change the name of the array in realtime. The whole point of using variable_local_array_set() is to use the name of the array given in the argument of the script. It serves the same purpose, however, does the same thing, which I will agree on.Pretty sure its ripped right out of 3 different games that I am using it in in which it does work
#10
Posted 10 April 2012 - 05:22 AM
#11
Posted 10 April 2012 - 12:45 PM
0 user(s) are reading this topic
0 members, 0 guests, 0 anonymous users











