|
Author
|
Message
|
|
Veteran Member
Join Date: Mar 2004
Location: Norway-Europe(GTM+1)
|

06-06-2004
, 00:58
[Requesting Add AMXX] Some Usefull String Functions
|
#1
|
I Think these stocks should be added in teh string.inc
Quote:
|
Originally Posted by Johnny got his gun
Code:
stock trim(stringtotrim[], len, charstotrim, bool:fromleft = true) {
if (charstotrim <= 0)
return
if (fromleft) {
new maxlen = strlen(stringtotrim)
if (charstotrim > maxlen)
charstotrim = maxlen
format(stringtotrim, len, "%s", stringtotrim[charstotrim])
} else {
new maxlen = strlen(stringtotrim) - charstotrim
if (maxlen < 0)
maxlen = 0
format(stringtotrim, maxlen, "%s", stringtotrim)
}
}
|
Quote:
|
Originally Posted by xeroblood
Code:
stock StringMid( oldmsg[], newmsg[], start, end )
{
new len = strlen( oldmsg )
if( start < 0 ) start = 0
if( end <= start || end > len ) end = len
for( new j = 0, i = start; i < end; j++, i++ )
newmsg[j] = oldmsg[i]
return
}
|
Quote:
|
Originally Posted by xeroblood
Code:
stock explode( output[][], input[], delimiter )
{
new nIdx = 0
new nLen = (1 + copyc( output[nIdx], MAX_STR_LEN-1, input, delimiter ))
while( nLen < strlen(input) )
nLen += (1 + copyc( output[++nIdx], MAX_STR_LEN-1, input[nLen], delimiter ))
}
|
__________________
|
|
|
|