Page 1 of 2
Initializing Number Fields on Startup
Posted: Mon Oct 14, 2013 8:52 pm
by CodeTRUCKER
How do I initialize various fields when a LC application is executed? Here is what I tried, but I don't get any results...
(open the stack, "stkMain")
(the text box, "groundspeedbox" does not show a "0" like it is supposed to)
Please help.
Re: Initializing Number Fields on Startup
Posted: Mon Oct 14, 2013 9:13 pm
by Simon
Hi CodeTRUCKER,
Welcome to the forums!
put 0 into GroundSpeed
You have not told the engine the container type you want to put it in. Right now it's thinking GroundSpeed is a variable.
Here is a lesson that should help:
http://lessons.runrev.com/s/lessons/m/2 ... rld-3-ways
Simon
Re: Initializing Number Fields on Startup
Posted: Mon Oct 14, 2013 10:25 pm
by CodeTRUCKER
Thank you for the welcome, Simon!
FYI - "GroundSpeed" is a variable. [Calvin scratches head as he makes his way to the lesson...]
Re: Initializing Number Fields on Startup
Posted: Mon Oct 14, 2013 10:30 pm
by Simon
Hi Calvin,
Ahh I see, you haven't made any link between groundspeed and groundspeedBOX
Sorry I read it too quickly the first time.
Simon
Re: Initializing Number Fields on Startup
Posted: Mon Oct 14, 2013 10:40 pm
by CodeTRUCKER
Hi Simon,
Code: Select all
put 0 into GroundSpeed
put GroundSpeed into GroundSpeedBox
Nope, still not working. I have read the page 3 times including reading it last night. I'm just not "getting it."
Take Two!

Re: Initializing Number Fields on Startup
Posted: Mon Oct 14, 2013 10:47 pm
by Simon
OK...
What is groundspeedbox?
Code: Select all
put 0 into GroundSpeed
put GroundSpeed into GroundSpeedBox
You will have to tell liveCode what it is... errr... groundspeed we know is a variable, right now liveCode thinks groundspeedbox is one as well.
Simon
Re: Initializing Number Fields on Startup
Posted: Mon Oct 14, 2013 10:48 pm
by Simon
Re: Initializing Number Fields on Startup
Posted: Mon Oct 14, 2013 10:52 pm
by CodeTRUCKER
Ah! You mean something like...
put 0 into GroundSpeed
put GroundSpeed into textbox(GroundSpeedBox)
I have looked for several hours since last night trying to locate *how* to read and wite into text fields. No joy yet (which is why I posted). It may take a while before I learn how LC does what.
Re: Initializing Number Fields on Startup
Posted: Mon Oct 14, 2013 11:03 pm
by CodeTRUCKER
Hi Simon,
Not a good idea (for me, at least). I get very confused easily if there are numerous things going on at the same time. Please let me continue this subject in this thread, if that is OK?
Re: Initializing Number Fields on Startup
Posted: Mon Oct 14, 2013 11:16 pm
by CodeTRUCKER
Moving on...
Do I have to structure it...
Code: Select all
put 0 into GroundSpeed
put GroundSpeed into GroundSpeedBox
Or can I just code it like this...
Seems like the second one would work?
Re: Initializing Number Fields on Startup
Posted: Mon Oct 14, 2013 11:18 pm
by Simon
Yup. but quote the fields name
Re: Initializing Number Fields on Startup
Posted: Mon Oct 14, 2013 11:29 pm
by CodeTRUCKER
Simon wrote:Yup. but quote the fields name
I tried...
Code: Select all
put "0" into field "GroundSpeedBox"
..., but it still doesn't work. I feel like an idiot.
Re: Initializing Number Fields on Startup
Posted: Mon Oct 14, 2013 11:34 pm
by Simon
Not sure but check very carefully for spaces in the field name
maybe a return?
Simon
Re: Initializing Number Fields on Startup
Posted: Mon Oct 14, 2013 11:40 pm
by CodeTRUCKER
Thanks for letting me keep the thread.
No spaces or returns.
Ok, let me ask you to code the following...
1. You have an app named "Simon's App."
2. When it opens you want a textbox to contain, "123."
How would *you* code it?
Re: Initializing Number Fields on Startup
Posted: Mon Oct 14, 2013 11:51 pm
by Simon
Hi Calvin,
The simple answer is just to save the app with 123 in the field.
But that is not what you are asking I think.
Start with a new stack put 1 button and 1 field on it (really new stack, no cheating)
in the button script put
Code: Select all
on mouseUp
put "123" into fld 1
end mouseUp
note fld is short for field
fld 1 is the lowest "layered" field
That should help you find out what is wrong with GroundSpeedBox naming
more to what you want, in the card script
Code: Select all
on openCard
put "123" into fld 1
end openCard
Simon