LCB variable assignment and evaluation confusion
Posted: Mon Apr 02, 2018 1:56 pm
I have been trying to get a chance to look into LCB again and thought I'd have a go at examining the clock widget to get used to manipulating the canvas and paths.
I have just had a hard disk problem so a new Windows 10 setup of LC 9-rc1 is being used, no older editions clogging things up.
Several things are making it hard to get to grips with again, I thought I had made great steps with the previous task of interfacing with foreign dll handlers for the Velleman experiment board, but so much of the basics is tripping me up here.
Firstly when testing, making any changes is not necessarily being reflected in the test, for instance, if I setinstead of 200 x 200 then mostly the test widget doesn't change size. Occasionally there is something that happens and the size follows the new preference, but then if I make a change again, it sticks to the 300 x 300 size until another seemingly random thing happens to obey the setting. I know it's not just a cache thing because some of the other programmatical changes to the widget ARE taking effect.
Mainly though my thoughts are concerned with how to evaluate variables right now.
In the clock .lcb the updateGeometry() handler containsIf I try to copy that mCentre value to another variable, by various means, they all fail.When I mention "fails" above, I mean that no error is generated, but the script silently ignores the values supposedly put into the mNewVar list. What gives? How can I understand these evaluations and assignments?
I have just had a hard disk problem so a new Windows 10 setup of LC 9-rc1 is being used, no older editions clogging things up.
Several things are making it hard to get to grips with again, I thought I had made great steps with the previous task of interfacing with foreign dll handlers for the Velleman experiment board, but so much of the basics is tripping me up here.
Firstly when testing, making any changes is not necessarily being reflected in the test, for instance, if I set
Code: Select all
metadata preferredSize is "300,300"
Mainly though my thoughts are concerned with how to evaluate variables right now.
In the clock .lcb the updateGeometry() handler contains
Code: Select all
put [my width / 2, my height / 2] into mCentre
Code: Select all
put [my width / 2, my height / 2] into mCentre
put [(my width / 2) + 30, (my height / 2) + 30] into mNewVar -- fails
put [my width / 2, my height / 2] into mNewVar -- fails, even though a literal cut and paste of the valid line but with mCentre edited to mNewVar
put mCentre into mNewVar -- fails (sure beats me why)
/* this fails
variable tX as Number
variable tY as Number
put mCentre[1] into tX
put mCentre[2] into tY
add 90 to tX
add 90 to tY
put the empty list into mNewVar
push tY onto mNewVar
push tX onto mNewVar
*/
/* this fails
put the empty list into mNewVar
push mCentre[2] onto mNewVar
push mCentre[1] onto mNewVar
*/
put [90,90] into mNewVar -- works to put the hard coded values into the variable