05.09.2009, 15:35
To fix up the bug with explode, I added a temporary solution.
pawn Код:
/*
explode:
Creates an array of values from 'sSource', where only the exact amount of
values matching sizeof(aExplode) are returned.
Arguments:
aExplode[][] The exploded array
sSource[] Source string.
sDelimiter The string to use as the delimiter.
iVertices Vertices of aExplode, detected automatically.
iLength Length of a string in aExplode, detected automatically.
Returns:
Returns -1 on failure, otherwise success.
*/
stock explode(aExplode[][], sSource[], const sDelimiter[] = " ", iVertices = sizeof aExplode, iLength = sizeof aExplode[])
{
strins(sSource, sDelimiter, strlen(sSource), 28);
new
iNode,
iPointer,
iPrevious = -1,
iDelimiter = strlen(sDelimiter);
while(iNode < iVertices)
{
iPointer = strfind(sSource, sDelimiter, false, iPointer);
if(iPointer == -1)
{
strmid(aExplode[iNode], sSource, iPrevious, iLength, iLength);
break;
}
else
{
strmid(aExplode[iNode], sSource, iPrevious, iPointer, iLength);
}
iPrevious = (iPointer += iDelimiter);
++iNode;
}
return iPrevious;
}

