Placeholder for boolean data type in format-function
#1

Hey. One simple question:
Is there an easy way to add boolean variables into a string, like:
pawn Код:
new string[25], bool:TrueOrFalse=true;
format(string, sizeof(string), "The statement is %boolean", TrueOrFalse);
'%boolean' should be a pseudo placeholder for boolean variables. Now here is my question: Is there a placeholder that does something similar? And if yes, what is its' name/character?
If not, is there an easy way of adding true/false to a string, without using a mass of if-statements?

#Edit#:

Alright, I made a sollution for this on my own now:
pawn Код:
strbool(string[], bool:var, maxlength=sizeof(string))
{
    switch(var)
    {
        case true: return strcat(string, "true", maxlength);
        case false: return strcat(string, "false", maxlength);
    }
    return -1;
}
It works like strcat, just with a boolean as second value, instead of an string. maxlength is optional.

If there is still another way, please let me know.

Thank you.
Reply


Messages In This Thread
Placeholder for boolean data type in format-function - by DeathOnaStick - 24.12.2010, 13:01
Re: Placeholder for boolean data type in format-function - by iggy1 - 24.12.2010, 13:44

Forum Jump:


Users browsing this thread: 1 Guest(s)