Jump to content
Sign in to follow this  
Cuervo

If True Then Else

Recommended Posts

Cuervo

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

Share this post


Link to post
Share on other sites
FlyinRiz

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

Share this post


Link to post
Share on other sites
Cuervo

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

Share this post


Link to post
Share on other sites
PsaltyDS

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

Share this post


Link to post
Share on other sites
Cuervo

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 by Cuervo

-Tim

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  

×