E
erfg12
Guest
GM Version: 1.4 & 2
Target Platform: ALL
Download: N/A
Links: N/A
Summary:
Typically you can explode a string by a delimiter. A good example might be C# or PHP. You can say, explode this string by a comma and place the pieces into an array. I couldn't find a good example in GML, so I wrote one.
Tutorial:
Target Platform: ALL
Download: N/A
Links: N/A
Summary:
Typically you can explode a string by a delimiter. A good example might be C# or PHP. You can say, explode this string by a comma and place the pieces into an array. I couldn't find a good example in GML, so I wrote one.
Tutorial:
Code:
// Iterate through a string, explode by commas.
text = argument0;
char_string = 0;
if string_pos(",", text) != 0
{
var cc = string_count(",",text);
for (i = 0; i <= cc; i += 1) {
if (i < cc) {
char_string[i] = string_copy(text, 0, string_pos(",", text)-1 ); // get the piece exploded off
text = string_copy(text, string_pos(",", text)+1, string_length(text) ); // re-write text var to be what remains
}
else
char_string[i] = text;
}
return char_string;
}
else
return text