Cuervo Posted August 12, 2010 Share Posted August 12, 2010 Hey everyone, I'm not sure if I have this done correctly but here's what I have. $workIni = @WorkingDir & "\setdata.ini" $Hold = True $Var1 = $ThisValue _readIni() Func _readIni() $ThisValue = IniRead($workIni, "Settings", "CurrentSet", "00") EndFunc Do Afunc() If $Var1 = True then Bfunc() Else Cfunc() EndIf Until $Hold = False And my ini file looks like this. My INI File $workIni [settings] CurrentSet=True My issue is, regardless of CurrentSet=True or False the script always performs Bfunc. What have I done wrong? I'm sure that it's reading the ini. Thanks! -Tim Link to comment Share on other sites More sharing options...
FlyinRiz Posted August 12, 2010 Share Posted August 12, 2010 Hey everyone, I'm not sure if I have this done correctly but here's what I have. $workIni = @WorkingDir & "\setdata.ini" $Hold = True $Var1 = $ThisValue _readIni() Func _readIni() $ThisValue = IniRead($workIni, "Settings", "CurrentSet", "00") EndFunc Do Afunc() If $Var1 = True then Bfunc() Else Cfunc() EndIf Until $Hold = False And my ini file looks like this. My INI File $workIni [settings] CurrentSet=True My issue is, regardless of CurrentSet=True or False the script always performs Bfunc. What have I done wrong? I'm sure that it's reading the ini. Thanks! I think you are trying to use $Var1 as a pointer...$Var1 never gets it's value set. You should just use $ThisValue -Aaron Link to comment Share on other sites More sharing options...
Cuervo Posted August 12, 2010 Author Share Posted August 12, 2010 Well I tried this, but regardles of CurrentSet= status it always performs Bfunc. $workIni = @WorkingDir & "\setdata.ini" $Hold = True $Global $ThisValue _readIni() Func _readIni() $ThisValue = IniRead($workIni, "Settings", "CurrentSet", "00") EndFunc Do Afunc() If $ThisValue = True then Bfunc() Else Cfunc() EndIf Until $Hold = False -Tim Link to comment Share on other sites More sharing options...
PsaltyDS Posted August 12, 2010 Share Posted August 12, 2010 You are mixing variable types. IniRead() always returns a string, but you are comparing it to a Boolean True. A string is Boolean True if it is anything not null. So "" = False, and any other string = True. You might use: If $ThisValue = "True" Note the quotes around "True", treating it as a string instead of Boolean True. Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law Link to comment Share on other sites More sharing options...
Cuervo Posted August 12, 2010 Author Share Posted August 12, 2010 (edited) You are mixing variable types. IniRead() always returns a string, but you are comparing it to a Boolean True. A string is Boolean True if it is anything not null. So "" = False, and any other string = True.You might use: If $ThisValue = "True"Note the quotes around "True", treating it as a string instead of Boolean True.So by default, if CurrentSet=(anything) then it is true when used as a boolean? If that is the case then I understand why the script was doing what it was doing.Thank you.BTW You were correct "True" does infact work correctly for me. Edited August 12, 2010 by Cuervo -Tim 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