21.12.2009, 01:42
Hi there,
I'm looking for some way of exploding a regular string into an array of substrings.
Like You would do in PHP:
And it would produce:
I've read the official Pawn Strings manual and didn't find any exact solution.
Tried googling, bugging friendly developers and still there's not much i discovered.
Tried experimenting for myself, but honestly i'm not yet good enough with Pawn to figure:
And then:
But i still get gibberish from that (result[1] is equal to the whole line..)
Any clues?
Additionally i don't even know how to debug such things properly; launching SAMP server & client anytime i want to check if slight changes worked is pretty slow, and somehow Linux samp server doesn't want to print() anything to it's stdout
Thanks in advance for any helpfull clues
I'm looking for some way of exploding a regular string into an array of substrings.
Like You would do in PHP:
Код:
$string = "some|string|separated|with|a|char"; $array = explode('|', $string); print_r($array);
Код:
Array ( [0] => some [1] => string [2] => separated [3] => with [4] => a [5] => char )
Tried googling, bugging friendly developers and still there's not much i discovered.
Tried experimenting for myself, but honestly i'm not yet good enough with Pawn to figure:
Код:
function strexplode(const token[], const string[], stringSize) { new result[256][64]; // some test values new row = 0; for(new i=0; i<stringSize; i++) { // get local char new chr[256]; strmid(chr, string, i, i + 1, sizeof(chr)); // jump to next row if(strcmp(chr, token, true, sizeof(chr)) == 0) row++; else strcat(result[row], chr, sizeof(chr)); } return result; }
Код:
new line[2048] = "some|string|separated|with|a|char"; new result[256][64]; result = strexplode("|", line, sizeof(line)); SendClientMessage(0, 0xFFFFFFAA, result[1]); // some test fields
Any clues?
Additionally i don't even know how to debug such things properly; launching SAMP server & client anytime i want to check if slight changes worked is pretty slow, and somehow Linux samp server doesn't want to print() anything to it's stdout
Thanks in advance for any helpfull clues