Raised This Month: $ Target: $400
 0% 

parse string with delimeter


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
-=hunter=-
Senior Member
Join Date: Jul 2008
Old 11-23-2010 , 00:45   Re: parse string with delimeter
Reply With Quote #1

Exolent[jNr] I tried but for me dont works correctly.

PHP Code:
new arg1[51], arg2[51], arg3[51], arg4[51], arg5[51], arg6[51]
new 
text[130] = "Player1;Player2;;Player4;Player5;Player6"
parsetok(text';'1arg150arg250arg3,50arg450,arg550arg650)
server_print("parsed: arg1 = %s, arg2 = %s, arg3 = %s, arg4 = %s, arg5 = %s, arg6 = %s"arg1arg2arg3arg4arg5arg6)

// parsed: arg1 =  , arg2 = Player2, arg3 = Player4, arg4 = Player6, arg5 = , arg6 = 
Found errors. Must be:
new iArgStringIndex = 3;
new iArgLenIndex = 4;
iArgStringIndex += 2;
iArgLenIndex += 2;

Exolent[jNr] Big thanks This way works is a little faster than with strtok

Last edited by -=hunter=-; 11-23-2010 at 03:44.
-=hunter=- is offline
Send a message via ICQ to -=hunter=- Send a message via Skype™ to -=hunter=-
Exolent[jNr]
Veteran Member
Join Date: Feb 2007
Location: Tennessee
Old 11-23-2010 , 01:51   Re: parse string with delimeter
Reply With Quote #2

Quote:
Originally Posted by -=hunter=- View Post
Exolent[jNr] I tried but for me dont works correctly.

PHP Code:
new arg1[51], arg2[51], arg3[51], arg4[51], arg5[51], arg6[51]
new 
text[130] = "Player1;Player2;;Player4;Player5;Player6"
parsetok(text';'1arg150arg250arg3,50arg450,arg550arg650)
server_print("parsed: arg1 = %s, arg2 = %s, arg3 = %s, arg4 = %s, arg5 = %s, arg6 = %s"arg1arg2arg3arg4arg5arg6)

// parsed: arg1 =  , arg2 = Player2, arg3 = Player4, arg4 = Player6, arg5 = , arg6 = 
Found errors. Must be:
new iArgStringIndex = 3;
new iArgLenIndex = 4;
iArgStringIndex += 2;
iArgLenIndex += 2;

Exolent[jNr] Big thanks This way works is a little faster than with strtok

Has noticed that getarg works faster, than strlen in ~4 times
I forgot that arguments start at 0, not 1. And yes, I incremented wrongly.
Code has been fixed.
__________________
No private work or selling mods.
Quote:
Originally Posted by xPaw View Post
I love you exolent!
Exolent[jNr] is offline
Reply



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 11:16.


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