jbg1978 Posted September 9, 2008 Posted September 9, 2008 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
jbg1978 Posted September 9, 2008 Author Posted September 9, 2008 You could try "" = $strVariable.I tried to set it to empty string, but when I view the output, it's still a zero.
monoceres Posted September 9, 2008 Posted September 9, 2008 It works for me: $var="" If $var="" THen MsgBox(0,"","True") Broken link? PM me and I'll send you the file!
Richard Robertson Posted September 9, 2008 Posted September 9, 2008 I meant to use that as the If comparison. That wasn't an assignment statement.
Moderators SmOke_N Posted September 9, 2008 Moderators Posted September 9, 2008 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.
jbg1978 Posted September 9, 2008 Author Posted September 9, 2008 Thank you all. I'll try these suggestions and post back.
trancexx Posted September 9, 2008 Posted September 9, 2008 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, jbg1978There are String() and IsString() $strVariable = String($strVariable) That's string for sure. ♡♡♡ . eMyvnE
rasim Posted September 10, 2008 Posted September 10, 2008 trancexx There are String() and IsString()Yes $str = "" MsgBox(0, "String", IsString($str) = True) MsgBox(0, "Number", IsNumber($str) = True) $str = 0 MsgBox(0, "String", IsString($str) = True) MsgBox(0, "Number", IsNumber($str) = True)
jbg1978 Posted September 18, 2008 Author Posted September 18, 2008 (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 September 18, 2008 by jbg1978
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now