[18 May 2010] Boolean trouble

Contains all messages from the Hollywood mailing list between 01/2006 and 08/2012
Locked
User avatar
jap
Posts: 61
Joined: Sun Feb 14, 2010 12:24 pm
Contact:

[18 May 2010] Boolean trouble

Post 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
PEB
Posts: 576
Joined: Sun Feb 21, 2010 1:28 am

[18 May 2010] Re: Boolean trouble

Post 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.
PEB
Posts: 576
Joined: Sun Feb 21, 2010 1:28 am

[18 May 2010] Re: Boolean trouble

Post 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.
User avatar
jap
Posts: 61
Joined: Sun Feb 14, 2010 12:24 pm
Contact:

[19 May 2010] Re: Re: Boolean trouble

Post 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
Locked