Jump to content
UBot Underground

Comparison not working?


Recommended Posts

Is it just my system (or me) but is there something wrong with the Ubot Comparison function?

 

set(#testvar, 1, "Global")

if($comparison(#testvar, "=", $true)) {
    then {
        alert("Has Value")
    }
    else {
        alert("Does Not Have Value")
    }
}
 

I would expect this simple statement to pop up the Alert with "Has Value" because the variable #testvar has a value of 1 and is true. Instead ubot is telling be this is false and giving me the else Alert.

 

What am I missing here?

Link to post
Share on other sites

for your example, try setting #testvar = $true...

 

or use the comparison to check if #testvar = 1

set(#testvar, 1, "Global")
if($comparison(#testvar, "=", 1)) {
    then {
        alert("Has Value")
    }
    else {
        alert("Does Not Have Value")
    }
}

Link to post
Share on other sites
True is not 1

true = true

1 = 1

 

 

set(#testvar, "true", "Global")

if($comparison(#testvar, "=", $true)) {

    then {

        alert("Has Value")

    }

    else {

        alert("Does Not Have Value")

    }

}

 

Dan
Link to post
Share on other sites

Thanks Steve and Dan,

 

Yes 1=1, and true = $true.  I am trying to see if the variable as a value, any value.  Is $true just for checkboxes? .  Asserting the negative, !=, with $nothing works. 

 

Related, is there a built in way to test a variable type (numeric integer/decimal, text, date, etc.) or do I have test my variable with a regular expression?

Link to post
Share on other sites

Thanks Steve and Dan,

 

Yes 1=1, and true = $true.  I am trying to see if the variable as a value, any value.  Is $true just for checkboxes? .  Asserting the negative, !=, with $nothing works. 

 

Related, is there a built in way to test a variable type (numeric integer/decimal, text, date, etc.) or do I have test my variable with a regular expression?

 

I always use != $nothing if I want to check if a variable has a value.

There are no variable types in ubot. So you can't distinguish between integer or text. 

Maybe with an eval / javascript command. But not with one of the built in functions. As far as I know.

 

Dan

  • Like 1
Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...