Don't quite have time to read all that, but is it anything like this stock?
Code:
stock str_piece(const input[],output[][],outputsize,piecelen,&token='|')
{
// takes the string input and puts it into output[]
// each level of output is a "piece" of input, delimeted by token.
// return value is the number of pieces.
// outputsize is the max number of levels to fill ( sizeof output )
// piecelen is the max length of a piece ( sizeof output[] - 1 )
// e.g.
// new array[3][4];
// str_piece("abcdef|ghijkl|mnopqr|stuvw|xyz",array,sizeof array,sizeof array[] - 1,'|')
// returns 3.
// and sets the array as:
// array[0]="abc"
// array[1]="ghi"
// array[2]="mno"
// ( only 3 pieces can be returned, with a max length of 3 )
new i=-1,pieces,len=-1 ;
while ( input[++i] != 0 )
{
if ( input[i] != token )
{
if ( ++len < piecelen )
output[pieces][len] = input[i] ;
}
else
{
output[pieces++][++len] = 0 ;
len = -1 ;
if ( pieces == outputsize )
return pieces ;
}
}
return pieces + 1;
}
(From pixie_stocks, naturally)
EDIT: OK, similar but not quite the same.
Can't see the problem with yours ... does this work?
Code:
stock extractstr(source[],start,end,output[128])
{
new maxlength = strlen(source)
new len
new bool:started
for ( new i ; i < maxlength ; i ++ )
{
if ( started )
{
if ( source[i] == end )
{
output[len] = 0 ;
break ;
}
output[len++]=source[i] ;
if ( len == sizeof output )
{
output[len] = 0 ;
break ;
}
continue ;
}
if ( source[i] == start )
started = true ;
}
trim(output) ;
return ;
}