Page 1 of 1

[18 May 2010] Boolean trouble

Posted: Sat Jun 13, 2020 5:32 pm
by jap
Note: This is an archived post that was originally sent to the Hollywood mailing list on Tue, 18 May 2010 19:06:17 +0300

Hello,

I have two files test.hws and test2.hws.

test.hws looks like this:

Code: Select all

myTable = { [ "a" ] = True }
@INCLUDE "test2.hws"

p_Testing ()
And test2.hws:

Code: Select all

Function p_Testing ()
Local la = myTable [ "a" ]

If la = True
DebugPrint ( "True" )
Else
DebugPrint ( "False" )
EndIf
EndFunction
When I execute test.hws with Hollywood it works as expected. But when I include the files into my "bigger" program and try to execute it, Hollywood stops at line "If la = True" and gives me this error message: "Attempt to compare a number with a string!".

If I change the line to this

If la = "True"

Hollywood stops complaining about it.

There are several boolean variables in my "bigger" program and some of the If statements work with True and some with "True".

It looks to me that sometimes a statement like myvar = True sets myvar as "True" and not as True. Is there a way to make sure that a variable really gets a boolean value?

-- Janne janne.email-address-removed@nospam.com

[18 May 2010] Re: Boolean trouble

Posted: Sat Jun 13, 2020 5:32 pm
by PEB
Note: This is an archived post that was originally sent to the Hollywood mailing list on Tue, 18 May 2010 20:06:22 -0000
Is there a way to make sure that a variable really gets a boolean value?
You can put your variable through ToNumber(), since True is 1 and False is 0.

[18 May 2010] Re: Boolean trouble

Posted: Sat Jun 13, 2020 5:32 pm
by PEB
Note: This is an archived post that was originally sent to the Hollywood mailing list on Tue, 18 May 2010 20:06:22 -0000
Is there a way to make sure that a variable really gets a boolean value?
You can put your variable through ToNumber(), since True is 1 and False is 0.

[19 May 2010] Re: Re: Boolean trouble

Posted: Sat Jun 13, 2020 5:32 pm
by jap
Note: This is an archived post that was originally sent to the Hollywood mailing list on Wed, 19 May 2010 19:18:23 +0300
You can put your variable through ToNumber(), since True is 1 and False is 0.
Thanks for the tip, I got it working.

-- Janne janne.email-address-removed@nospam.com