AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Substr, strmid (https://forums.alliedmods.net/showthread.php?t=163153)

Clauu 07-27-2011 08:23

Substr, strmid
 
Hi again, is there any stand-ins for substr and strmid? Or why these functions are not included by default? Those are important functions..

Bugsy 07-27-2011 09:48

Re: Substr, strmid
 
You need to add your own error trapping. Untested

PHP Code:

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



Clauu 07-27-2011 10:57

Re: Substr, strmid
 
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?

Exolent[jNr] 07-27-2011 10:59

Re: Substr, strmid
 
Default escape character is ^ not \
You can change it using:
Code:
#pragma ctrlchar '\'

Clauu 07-27-2011 11:04

Re: Substr, strmid
 
I didn't know that, thanks.

Bugsy 07-27-2011 11:20

Re: Substr, strmid
 
Use the EOS (End Of String) constant to terminate strings.

String[ 5 ] = EOS;

Clauu 07-27-2011 11:27

Re: Substr, strmid
 
Yes, same thing.

fysiks 07-27-2011 17:34

Re: Substr, strmid
 
Quote:

Originally Posted by Clauu (Post 1519697)
Yes, same thing.

Yes but it's escape character independent! :)


All times are GMT -4. The time now is 01:08.

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