SA-MP Forums

Go Back   SA-MP Forums > SA-MP Scripting and Plugins > Filterscripts > Includes

Reply
 
Thread Tools Display Modes
Old 16/05/2018, 12:25 PM   #51
Yousha
Banned
 
Join Date: May 2013
Posts: 119
Reputation: 7
Exclamation Re: [INC] strlib v1.3 - Simple string modification (Update: 21/10/09)

I think there's a bug with "explode()" function:

Code:
new source[12] = "123,456,789";
new dest[3][4];

explode(dest, source, ",");
printf("%s %s %s", dest[0][1], dest[0][2], dest[1][2]);
Result:

Quote:
23 3 6

Last edited by Yousha; 16/05/2018 at 12:56 PM.
Yousha is offline   Reply With Quote
Old 16/05/2018, 12:39 PM   #52
ball
Huge Clucker
 
ball's Avatar
 
Join Date: Jul 2012
Location: Poznan, Poland
Posts: 288
Reputation: 33
Default Re: [INC] strlib v1.3 - Simple string modification (Update: 21/10/09)

Code:
printf("%s %s %s", dest[0], dest[1], dest[2]);
ball is offline   Reply With Quote
Old 16/05/2018, 12:46 PM   #53
Yousha
Banned
 
Join Date: May 2013
Posts: 119
Reputation: 7
Lightbulb Re: [INC] strlib v1.3 - Simple string modification (Update: 21/10/09)

Quote:
Originally Posted by ball View Post
Code:
printf("%s %s %s", dest[0], dest[1], dest[2]);
IK that, but PHP's version of same code works fine:

PHP Code:
$source "123,456,789";
$dest explode(","$source);
printf("%s %s %s"$dest[0][1], $dest[0][2], $dest[1][2]); 
Result:

Quote:
2 3 6
So I think there's a bug...
Yousha is offline   Reply With Quote
Old 16/05/2018, 12:52 PM   #54
yugecin
Big Clucker
 
Join Date: Oct 2009
Location: Belgium
Posts: 83
Reputation: 82
Default Re: [INC] strlib v1.3 - Simple string modification (Update: 21/10/09)

Quote:
Originally Posted by Yousha View Post
I think there's a bug with "explode()" function:

Code:
new source[12] = "123,456,789";
new dest[12][12];

explode(dest, source, ",");
printf("%s %s %s", dest[0][1], dest[0][2], dest[1][2]);
Result:
That's just how strings work in PAWN, if you use %s as format specifier it will insert data until the end of the string is reached (the null terminator), so you end up with 23.
It probably works like that in php because dest[0][1] would be a single character, which is then converted to a string. PAWN does not do this.
__________________
robin_be
yugecin is offline   Reply With Quote
Old 16/05/2018, 02:16 PM   #55
Kar
High-roller
 
Kar's Avatar
 
Join Date: May 2010
Location: Black Asylum
Posts: 3,184
Reputation: 506
Default Re: [INC] strlib v1.3 - Simple string modification (Update: 21/10/09)

Quote:
Originally Posted by Yousha View Post
IK that, but PHP's version of same code works fine:

PHP Code:
$source "123,456,789";
$dest explode(","$source);
printf("%s %s %s"$dest[0][1], $dest[0][2], $dest[1][2]); 
Result:



So I think there's a bug...
Does PAWN spell 'PHP'?
Kar is offline   Reply With Quote
Old 17/05/2018, 05:02 PM   #56
Yousha
Banned
 
Join Date: May 2013
Posts: 119
Reputation: 7
Default Re: [INC] strlib v1.3 - Simple string modification (Update: 21/10/09)

Quote:
Originally Posted by Kar View Post
Does PAWN spell 'PHP'?
Get out, spammer.

Quote:
Westie: Missed PHP's excellent string modification functions? Yeah, but that was because it was easy.

Last edited by Yousha; 19/05/2018 at 08:18 AM.
Yousha is offline   Reply With Quote
Old 19/05/2018, 08:18 AM   #57
Yousha
Banned
 
Join Date: May 2013
Posts: 119
Reputation: 7
Default Re: [INC] strlib v1.3 - Simple string modification (Update: 21/10/09)

Quote:
[22:17:28] [debug] Run time error 10: "Native function failed"
[22:17:28] [debug] strins
[22:17:28] [debug] AMX backtrace:
[22:17:28] [debug] #0 00000930 in str_ireplace (sSearch[]=@0031fbb0 ",Test", sReplace[]=@002864f0 "", sSubject[]=@00101d0c "Test,Test,Test,Test,Test,", &iCount=@00316ad8 2) at J:\Desktop\PAWN\SA-MP\X\pawno\include\strlib.inc:124
strlib.inc version: 1.3.0

Code:
#define _strlib_med_string 256

new sTemp[128], sReturn[_strlib_med_string];
// ...
strins(sReturn, sReplace, iIndex, iLengthReplace); // Line #124
Yousha is offline   Reply With Quote
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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Payday Modification SeQualX Help Archive 3 12/07/2010 03:31 PM
[FilterScript] [FS] Drift3r's Simple Vehicle Spawner *0.1b Update* ray8995 Filterscripts 20 15/05/2010 01:22 PM
[Modification] | SAMP Gui - Simple modification of samp Interface (InGame) LuxurioN™ Everything and Nothing 21 15/03/2010 01:55 PM
MOVED: SA-MP Server (EXE) modification - Do you like it? Woet Help Archive 0 02/11/2009 06:43 AM
GTA modification compatibility with SA-MP Lordician General 1 19/08/2009 07:03 PM


All times are GMT. The time now is 01:44 PM.


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2018, Jelsoft Enterprises Ltd.