=sinister= Posted October 26, 2008 Share Posted October 26, 2008 Func ConvertVariable($Variable) Local $Return Local $String = StringSplit($Variable, "=") Local $NewString1 = StringReplace($String[2], '"', "") Local $NewString = StringReplace($NewString1, "'", "") Local $Test = 1 If IsInt($Test) Then MsgBox(0, "Test", "Test is = 1... and IsInt() is working") If $NewString = 1 Then MsgBox(0, "TEST", "ok, it IS a freaking Int, why isn't IsInt() working?!") If IsInt($NewString) Then MsgBox(0, "This", "Is Not WORKING") If IsInt($NewString) Then MsgBox(0, "Int", $NewString) $Return = "int " & $String[1] & "=" & $NewString & ";" ElseIf StringInStr($NewString, "true") or StringInStr($NewString, "false") Then;IsBool() didn't seem to work?? =\ If $NewString = "true" Then $Return = "bool " & $String[1] & "=" & "true" & ";" Else $Return = "bool " & $String[1] & "=" & "false" & ";" EndIf ;ElseIf IsString($NewString) Then ; $Return = "char " & $String[1] & "=" & $NewString & ";" EndIf Return $Return EndFunc This is very weird to me. Take a look at this code: Local $Test = 1 If IsInt($Test) Then MsgBox(0, "Test", "Test is = 1... and IsInt() is working") If $NewString = 1 Then MsgBox(0, "TEST", "ok, it IS a freaking Int, why isn't IsInt() working?!") If IsInt($NewString) Then MsgBox(0, "This", "Is Not WORKING") $Test = 1. We confirm this is a int. IsInt($Test) works because $Test = 1. Then we check if $NewString = 1. It is, and I get the messagebox. However, IsInt($NewString) won't do anything? I'm 100000% confused. Also, the parameter for the function is a variable without the $, I have this function used with some other code that trims the $ out. Link to comment Share on other sites More sharing options...
Malkey Posted October 26, 2008 Share Posted October 26, 2008 Func ConvertVariable($Variable) Local $Return Local $String = StringSplit($Variable, "=") Local $NewString1 = StringReplace($String[2], '"', "") Local $NewString = StringReplace($NewString1, "'", "") Local $Test = 1 If IsInt($Test) Then MsgBox(0, "Test", "Test is = 1... and IsInt() is working") If $NewString = 1 Then MsgBox(0, "TEST", "ok, it IS a freaking Int, why isn't IsInt() working?!") If IsInt($NewString) Then MsgBox(0, "This", "Is Not WORKING") If IsInt($NewString) Then MsgBox(0, "Int", $NewString) $Return = "int " & $String[1] & "=" & $NewString & ";" ElseIf StringInStr($NewString, "true") or StringInStr($NewString, "false") Then;IsBool() didn't seem to work?? =\ If $NewString = "true" Then $Return = "bool " & $String[1] & "=" & "true" & ";" Else $Return = "bool " & $String[1] & "=" & "false" & ";" EndIf ;ElseIf IsString($NewString) Then ; $Return = "char " & $String[1] & "=" & $NewString & ";" EndIf Return $Return EndFunc This is very weird to me. Take a look at this code: Local $Test = 1 If IsInt($Test) Then MsgBox(0, "Test", "Test is = 1... and IsInt() is working") If $NewString = 1 Then MsgBox(0, "TEST", "ok, it IS a freaking Int, why isn't IsInt() working?!") If IsInt($NewString) Then MsgBox(0, "This", "Is Not WORKING") $Test = 1. We confirm this is a int. IsInt($Test) works because $Test = 1. Then we check if $NewString = 1. It is, and I get the messagebox. However, IsInt($NewString) won't do anything? I'm 100000% confused. Also, the parameter for the function is a variable without the $, I have this function used with some other code that trims the $ out.If you add these three If statements, it should show what is happening. If IsString($NewString) Then MsgBox(0, "This", "IsString Is WORKING") If IsInt(StringStripWS($NewString,8)) Then MsgBox(0, "This", "IsInt Is Not WORKING") If StringIsInt(StringStripWS($NewString,8)) Then MsgBox(0, "This", "StringIsInt Is WORKING") Link to comment Share on other sites More sharing options...
martin Posted October 26, 2008 Share Posted October 26, 2008 Func ConvertVariable($Variable) Local $Return Local $String = StringSplit($Variable, "=") Local $NewString1 = StringReplace($String[2], '"', "") Local $NewString = StringReplace($NewString1, "'", "") Local $Test = 1 If IsInt($Test) Then MsgBox(0, "Test", "Test is = 1... and IsInt() is working") If $NewString = 1 Then MsgBox(0, "TEST", "ok, it IS a freaking Int, why isn't IsInt() working?!") If IsInt($NewString) Then MsgBox(0, "This", "Is Not WORKING") If IsInt($NewString) Then MsgBox(0, "Int", $NewString) $Return = "int " & $String[1] & "=" & $NewString & ";" ElseIf StringInStr($NewString, "true") or StringInStr($NewString, "false") Then;IsBool() didn't seem to work?? =\ If $NewString = "true" Then $Return = "bool " & $String[1] & "=" & "true" & ";" Else $Return = "bool " & $String[1] & "=" & "false" & ";" EndIf ;ElseIf IsString($NewString) Then ; $Return = "char " & $String[1] & "=" & $NewString & ";" EndIf Return $Return EndFunc This is very weird to me. Take a look at this code: Local $Test = 1 If IsInt($Test) Then MsgBox(0, "Test", "Test is = 1... and IsInt() is working") If $NewString = 1 Then MsgBox(0, "TEST", "ok, it IS a freaking Int, why isn't IsInt() working?!") If IsInt($NewString) Then MsgBox(0, "This", "Is Not WORKING") $Test = 1. We confirm this is a int. IsInt($Test) works because $Test = 1. Then we check if $NewString = 1. It is, and I get the messagebox. However, IsInt($NewString) won't do anything? I'm 100000% confused. Also, the parameter for the function is a variable without the $, I have this function used with some other code that trims the $ out.The problem is that AutoIt is too smart. You have $Test as an integer. You have $NewString as a string. So it will not be an inetegr using IsInt because it's a string type. When you try to compare a string to an int then AutoIt will try to convert the string to an integer while it makes the comparison so you can say If "7" = 7 then ConSoleWrite("AutoIt is too smart" & @CR) but "7" is still a string and 7 is still an integer. Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script. Link to comment Share on other sites More sharing options...
jvanegmond Posted October 26, 2008 Share Posted October 26, 2008 To do any type of If checking in AutoIt, I can recommend using == instead of a single =. The == logic is very straightforward, and easy to understand. github.com/jvanegmond Link to comment Share on other sites More sharing options...
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