unable to use console log with a Boolean variable

Microsoft's MakeCode platform for easy blocks-style programming

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
Locked
User avatar
adavid7
 
Posts: 120
Joined: Fri Jul 04, 2014 7:32 pm

unable to use console log with a Boolean variable

Post by adavid7 »

It seems that one cannot use console log with a Boolean variable.

From the error message in the blocks editor (screenshot below), it appears that a Boolean variable can be created by setting the variable to true or false initially. But the console log block with a value will not accept that as a parameter even though the variable declaration appears legal:

Code: Select all

let aBoolean = true
forever(function () {
    console.logValue("aBoolean", aBoolean)
})
I tried this is the beta version of the editor also and it still fails.

Does anyone have any advice? This seems like a bug; wondering where to report that if it is?

Code shared here: https://makecode.com/_UrTR0DKk91Xm
boolah-boolah.png
boolah-boolah.png (43.41 KiB) Viewed 685 times

User avatar
nickine9
 
Posts: 147
Joined: Fri Jan 06, 2017 4:14 am

Re: unable to use console log with a Boolean variable

Post by nickine9 »

I think you can convert boolean to text (if you have a new/spare text variable)

let ttt = ""
let bool = false
basic.forever(function () {
ttt = convertToText(bool)
basic.showString(ttt)
})

User avatar
adavid7
 
Posts: 120
Joined: Fri Jul 04, 2014 7:32 pm

Re: unable to use console log with a Boolean variable

Post by adavid7 »

Right, thanks -- that's a good idea but .. ugh.

I could also just use a numeric variable with one or zero for true or false.

But I'm looking for readability in code as I teach novices.

Locked
Please be positive and constructive with your questions and comments.

Return to “MakeCode”