Sign in to follow this  
Followers 0
jbg1978

Help with data types

10 posts in this topic

I have a question regarding data types. According to a page I found on this site, when a variable = "" (empty string), then it will be considered a boolean type false and have a value of zero. When I perform a logic check against it (if $strVariable = "" then...) it doesn't register as true because $strVariable actually has a value of zero. I can't make the logic check: if $strVariable = 0 then...because the variable may actually legitimately contain a zero for the value. Any thoughts on how to check if the $strVariable simply = an empty string at all? Or, how to have AutoIT explicitly treat the variable as a string?

Thank you,

jbg1978

Share this post


Link to post
Share on other sites

You could try "" = $strVariable.

Share this post


Link to post
Share on other sites

You could try "" = $strVariable.

I tried to set it to empty string, but when I view the output, it's still a zero.

Share this post


Link to post
Share on other sites

It works for me:

$var=""
If $var="" THen MsgBox(0,"","True")

:)


Broken link? PM me and I'll send you the file!

Share this post


Link to post
Share on other sites

I meant to use that as the If comparison. That wasn't an assignment statement.

Share this post


Link to post
Share on other sites

If StringLen($strVariable) = 0 Then


Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Share this post


Link to post
Share on other sites

Thank you all. I'll try these suggestions and post back.

Share this post


Link to post
Share on other sites

I have a question regarding data types. According to a page I found on this site, when a variable = "" (empty string), then it will be considered a boolean type false and have a value of zero. When I perform a logic check against it (if $strVariable = "" then...) it doesn't register as true because $strVariable actually has a value of zero. I can't make the logic check: if $strVariable = 0 then...because the variable may actually legitimately contain a zero for the value. Any thoughts on how to check if the $strVariable simply = an empty string at all? Or, how to have AutoIT explicitly treat the variable as a string?

Thank you,

jbg1978

There are String() and IsString()

$strVariable = String($strVariable)

That's string for sure.


♡♡♡

.

eMyvnE

Share this post


Link to post
Share on other sites

#10 ·  Posted (edited)

I've already tried some of the suggestions before I posted. Like converting to string still updated the recordset with a zero, and logic check if "" = $str still produced false for me. The length($str) did end up being the resolution though. It worked like a charm. Thank you! Thanks to everyone who posted.

Edited by jbg1978

Share this post


Link to post
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
Sign in to follow this  
Followers 0