SA-MP Forums Archive
string.clear(); - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: string.clear(); (/showthread.php?tid=483558)



string.clear(); - Manowar - 26.12.2013

Hello. How to clean a string pawn?

C++
PHP код:
string.clear(); 
How pawn?


Re: string.clear(); - Konstantinos - 26.12.2013

pawn Код:
new
    string[128];

// somewhere you want to reset it:
string[0] = EOS;
// OR:
string[0] = '\0';



Re: string.clear(); - Patrick - 26.12.2013

If you are used to C++, string.clear function, I created a macro for it, so you could use string_clear(string_name); to clear a string

pawn Код:
#define string.clear(%0) \
    %0[0] = '\0'

//or

#define string.clear(%0) \
    %0[0] = EOS
Test Script
pawn Код:
#include <a_samp>

#define string.clear(%0) \
    %0[0] = '\0'
   
/*#define string.clear(%0) \
    %0[0] = EOS*/

       
new string[100] = "Hello, my name is Patrick and I am pds2k12 on san andreas multiplayer forums";

main()
{
    printf("%s", string);
    SetTimer("ClearString", 10000, false);
    return true;
}

forward ClearString();
public ClearString()
{
    string.clear(string);
    return printf("%s", string);
}



Re: string.clear(); - Manowar - 26.12.2013

Thanks