Jump to content

How To handle null values?


Recommended Posts

Friends,

Some of my queries are returning null values

How can i check whether it is null or not?

Is there any keyword called NULL so that i can compare my value with that keyword to determine whether its null or not

Regards

Link to comment
Share on other sites

Friends,

Some of my queries are returning null values

How can i check whether it is null or not?

Is there any keyword called NULL so that i can compare my value with that keyword to determine whether its null or not

Regards

$Var = 0
MsgBox( 0, "Its null!", $Var)

;or

If $Var = 0 Then
    MsgBox( 0, "Its null!", $Var)
    EndIf
Link to comment
Share on other sites

AutoIt has no NULL keyword.

One method I have used is:

If StringLen($value) = 0 Then
    MsgBox( 0, "$value = ", "Null")
Else
    MsgBox( 0, "$value = ", $value)
EndIf

which works for both string and numeric fields

"Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the universe trying to build bigger and better idiots. So far, the universe is winning."- Rick Cook

Link to comment
Share on other sites

In some cases, you should use IsPtr(0). I also asked this question. See this.

What cases for example?

...anyway, if you need to check if something is not nothing then you would probably do it like this:

$iValue = 0
If $iValue Then
    ;...
Else
    ConsoleWrite("! iValue in not" & @CRLF)
EndIf

$sValue = ""
If $sValue Then
    ;...
Else
    ConsoleWrite("! sValue in not" & @CRLF)
EndIf

$fValue = False
If $fValue Then
    ;...
Else
    ConsoleWrite("! fValue in not" & @CRLF)
EndIf

Or maybe:

If Not $iValue ...
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...