Raised This Month: $32 Target: $400
 8% 

ExplodeString( p_szOutput[][], p_nMax, p_nSize, p_szInput[], p_szDelimiter )


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Podunk
Senior Member
Join Date: Nov 2005
Location: Florida
Old 09-26-2007 , 22:38   ExplodeString( p_szOutput[][], p_nMax, p_nSize, p_szInput[], p_szDelimiter )
Reply With Quote #1

// Function by xeroblood
Code:
stock ExplodeString( p_szOutput[][], p_nMax, p_nSize, p_szInput[], p_szDelimiter ) { // Function by xeroblood
    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
}
__________________
Check out my website at http://matthewmiller.info
Podunk is offline
Send a message via MSN to Podunk
purple_pixie
Veteran Member
Join Date: Jun 2007
Location: Winchester, England
Old 09-27-2007 , 05:11   Re: ExplodeString( p_szOutput[][], p_nMax, p_nSize, p_szInput[], p_szDelimiter )
Reply With Quote #2

Not a bad function, if it does what it seems to from the source/name.

Not sure if I need it right atm, strtok() usually does it for me, but for de-concatenating strings for Vault / SQL storage it would be useful.
purple_pixie is offline
Podunk
Senior Member
Join Date: Nov 2005
Location: Florida
Old 09-27-2007 , 22:07   Re: ExplodeString( p_szOutput[][], p_nMax, p_nSize, p_szInput[], p_szDelimiter )
Reply With Quote #3

I love parsing messages with "|" for a delimiter, so this is perfect for my plugins
__________________
Check out my website at http://matthewmiller.info
Podunk is offline
Send a message via MSN to Podunk
purple_pixie
Veteran Member
Join Date: Jun 2007
Location: Winchester, England
Old 09-28-2007 , 06:04   Re: ExplodeString( p_szOutput[][], p_nMax, p_nSize, p_szInput[], p_szDelimiter )
Reply With Quote #4

Well the pipe is the only real delimiter, tbh.

I just wish there were something as fast and powerful as Caché's $Piece function ... ah, well.

It's pretty handy for me too, but I decided to write my own version instead.
Though without copyc ... I just went for looping through the array comparing cells.

Last edited by purple_pixie; 09-28-2007 at 08:57.
purple_pixie is offline
_Master_
Senior Member
Join Date: Dec 2006
Old 09-30-2007 , 14:32   Re: ExplodeString( p_szOutput[][], p_nMax, p_nSize, p_szInput[], p_szDelimiter )
Reply With Quote #5

This can be done in a single, optimized and incomplete loop rather than in standalone and nested loops.
_Master_ is offline
XxAvalanchexX
Veteran Member
Join Date: Oct 2004
Location: abort73.com
Old 09-30-2007 , 19:02   Re: ExplodeString( p_szOutput[][], p_nMax, p_nSize, p_szInput[], p_szDelimiter )
Reply With Quote #6

So do it.
__________________
No longer around. Thanks your support, everyone! As always:
THIS ONES FOR YOU
3000 PTS
XxAvalanchexX is offline
_Master_
Senior Member
Join Date: Dec 2006
Old 10-01-2007 , 05:40   Re: ExplodeString( p_szOutput[][], p_nMax, p_nSize, p_szInput[], p_szDelimiter )
Reply With Quote #7

Maybe I will... didn't have much use for it before...
_Master_ is offline
Lee
AlliedModders Donor
Join Date: Feb 2006
Old 10-03-2007 , 16:49   Re: ExplodeString( p_szOutput[][], p_nMax, p_nSize, p_szInput[], p_szDelimiter )
Reply With Quote #8

Is Hungarian Notation really necessary for one stock?
Lee is offline
Emp`
AMX Mod X Plugin Approver
Join Date: Aug 2005
Location: Decapod 10
Old 10-04-2007 , 18:45   Re: ExplodeString( p_szOutput[][], p_nMax, p_nSize, p_szInput[], p_szDelimiter )
Reply With Quote #9

Code:
stock ExplodeString( Output[][], Max, Size, Input[], Delimiter )
{
    new Idx, l = strlen(Input), Len;
    do Len += (1 + copyc( Output[Idx], Size, Input[Len], Delimiter ));
    while( (Len < l) && (++Idx < Max) )
    return Idx;
}

Last edited by Emp`; 10-04-2007 at 18:48.
Emp` is offline
Send a message via AIM to Emp` Send a message via MSN to Emp` Send a message via Yahoo to Emp` Send a message via Skype™ to Emp`
Bad_Bud
Senior Member
Join Date: Oct 2006
Location: The internet
Old 11-23-2007 , 03:59   Re: ExplodeString( p_szOutput[][], p_nMax, p_nSize, p_szInput[], p_szDelimiter )
Reply With Quote #10

What a costly function. D:
__________________
Bad_Bud is offline
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 04:05.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode