Integer == null?
#1

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

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?
Reply
#3

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");
Reply
#4

You could probably use:

pawn Код:
new Value;

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

else {
    print("Not null");
}
Reply
#5

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.
Reply
#6

I just gave you the answer...
Reply
#7

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
Reply
#8

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


Forum Jump:


Users browsing this thread: 1 Guest(s)