SA-MP Forums Archive
Integer == null? - 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)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: Integer == null? (/showthread.php?tid=255395)



Integer == null? - TheXIII - 15.05.2011

How to check if integer has no value? Not 0, or anything. Just null/nil/we?


Re: Integer == null? - Raimis_R - 15.05.2011

You talking about

pawn Код:
new Integer = 0;

if( Integer == 0 )
{
    print( "Integer value is: 0" );
}
else
{
    print( "Integer value isn't 0" );
}
or i wrong understand?


Re: Integer == null? - __ - 15.05.2011

Integers are never null.

You can check if a string is null, the null-terminator is a backslash and then a zero ('\0'), an example of it:

pawn Код:
new str[2];
if(str[1] == '\0' || str[0] == '\0') return print("null");



Re: Integer == null? - Skylar Paul - 15.05.2011

You could probably use:

pawn Код:
new Value;

if( !Value ) {
    print("Null");
}

else {
    print("Not null");
}



Re: Integer == null? - TheXIII - 15.05.2011

Quote:
Originally Posted by Raimis_R
Посмотреть сообщение
You talking about

pawn Код:
new Integer = 0;

if( Integer == 0 )
{
    print( "Integer value is: 0" );
}
else
{
    print( "Integer value isn't 0" );
}
or i wrong understand?
No, I meant something like
pawn Код:
if( integer == null)
If the value is "".
However I made a mistake in my printf function, so I believe this thread is pretty much pointless now.


Re: Integer == null? - __ - 15.05.2011

I just gave you the answer...


Re: Integer == null? - DRIFT_HUNTER - 15.05.2011

Integer's or Floats cannot be null they can be 0 but they cant be null
But strings can be null and they can be a 0 or anything else

It will be nice if you tell us for what you use it and what you want to do with it
You always can use some value as NULL

What i mean is: you can set integer to -1 or 999 or -999 or whatever value you will never use and than if integer have that value next time you check than you can say its a null


Re: Integer == null? - Sinner - 15.05.2011

PAWN automatically sets an integer to '0' when created, theres no NULL state as said before, just confirming