Small Changes (Mentioned/added in another post, thought I would put it here too)..
Code:
stock ExplodeString( p_szOutput[][], p_nMax, p_nSize, p_szInput[], p_szDelimiter )
{
new nIdx = 0, l = strlen(p_szInput)
new nLen = (1 + copyc( p_szOutput[nIdx], p_nSize, p_szInput, p_szDelimiter ))
while( (nLen < l) && (++nIdx < p_nMax) )
nLen += (1 + copyc( p_szOutput[nIdx], p_nSize, p_szInput[nLen], p_szDelimiter ))
return nIdx
}
Now returns the number of exploded strings returned in the p_szOutput array.. Useful for looping through results afterwards..
p_nMax & p_nSize correspond to the 2D p_szOutput Array sizes respectively..
Example:
Code:
new LongString[64] = "Some.Long.String.Seperated.by.Periods"
// 10 Strings of Length 16
new ExplodedStrings[10][16]
// Explode By Delimiter: '.' = Period (Dot)
new Count = ExplodeString( ExplodedStrings, 10, 16, LongString, '.' )
// output of Count will be 6
// output of array: ExplodedStrings
//
// ExplodedStrings[0] = "Some"
// ExplodedStrings[1] = "Long"
// ExplodedStrings[2] = "String"
// ExplodedStrings[3] = "Seperated"
// ExplodedStrings[4] = "by"
// ExplodedStrings[5] = "Periods"