Raised This Month: $ Target: $400
 0% 

Substr, strmid


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Clauu
Senior Member
Join Date: Feb 2008
Location: RO
Old 07-27-2011 , 08:23   Substr, strmid
Reply With Quote #1

Hi again, is there any stand-ins for substr and strmid? Or why these functions are not included by default? Those are important functions..
Clauu is offline
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 07-27-2011 , 09:48   Re: Substr, strmid
Reply With Quote #2

You need to add your own error trapping. Untested

PHP Code:
strmid( const szSrc[] , iStart iLength szDest[] )
{
    return 
copyszDest iLength szSrciStart ] );

__________________

Last edited by Bugsy; 07-27-2011 at 09:54.
Bugsy is offline
Clauu
Senior Member
Join Date: Feb 2008
Location: RO
Old 07-27-2011 , 10:57   Re: Substr, strmid
Reply With Quote #3

Yep it's ok, thanks. I have done something similar
Code:
strmid( const source[], dest[], start, end) {
     for(new i=start;i<end;i++)
     dest[i-start] = source[i]; }
Also why dest[i] = '\0' isn't valid here in amxx?

Last edited by Clauu; 07-27-2011 at 11:00.
Clauu is offline
Exolent[jNr]
Veteran Member
Join Date: Feb 2007
Location: Tennessee
Old 07-27-2011 , 10:59   Re: Substr, strmid
Reply With Quote #4

Default escape character is ^ not \
You can change it using:
Code:
#pragma ctrlchar '\'
__________________
No private work or selling mods.
Quote:
Originally Posted by xPaw View Post
I love you exolent!
Exolent[jNr] is offline
Clauu
Senior Member
Join Date: Feb 2008
Location: RO
Old 07-27-2011 , 11:04   Re: Substr, strmid
Reply With Quote #5

I didn't know that, thanks.
Clauu is offline
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 07-27-2011 , 11:20   Re: Substr, strmid
Reply With Quote #6

Use the EOS (End Of String) constant to terminate strings.

String[ 5 ] = EOS;
__________________
Bugsy is offline
Clauu
Senior Member
Join Date: Feb 2008
Location: RO
Old 07-27-2011 , 11:27   Re: Substr, strmid
Reply With Quote #7

Yes, same thing.
Clauu is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 07-27-2011 , 17:34   Re: Substr, strmid
Reply With Quote #8

Quote:
Originally Posted by Clauu View Post
Yes, same thing.
Yes but it's escape character independent!
__________________
fysiks 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 01:08.


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