Livecode Tuturoal: A Simple Calculator
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller
Livecode Tuturoal: A Simple Calculator
I'm working thru the http://www.live-code.net/livecode-tutor ... #section-7 and the Simple Calculator does not show the mouseUp results when I select a number or symbol. I went back through the code example and what I type many times (even backwards). Then I resorted to looking at the completed Simple Calculator http://live-code.net/examples and compared the code and inspector for each object. No difference. The only subtle difference I see is each of my label content is "grayed" out for some reason. Could that be the culprit? Below is the example for button "1".
Thanks
Keith
Thanks
Keith
Re: Livecode Tuturoal: A Simple Calculator
I think the main problem is that you've set the name of the button to 1, not the label.The Tutorial wrote:Edit the label properties of each button to "1, 2, 3, 4, 5, 6, 7, 8, 9, 0, +, -, *, /, ., =", and arrange them on screen as in this image:
By default, an objects 'name' (the top box in your picture) will be the object name. If there is more than one object of the same type, the name will increment with a space and number, like this:
(new button) name = button
(2nd button) name = button 1
etc.
The label is grayed out because you typed 1 into the name. Using just a bare number or symbol for the name of an object is a bad idea.
The tutorial doesn't change the name of the button, and it is fine to leave (for this case) button, button 1, button 2, etc for the name.
Alternately, you can go back and rename each control. In the case of the buttons, you *could* name them something meaningful, like "keyOne", "keyTwo", "keyDivision", etc.
Re: Livecode Tuturoal: A Simple Calculator
Bogs, That worked. Lesson learned. Thanks Keith
Re: Livecode Tuturoal: A Simple Calculator
Happy to be of some help
Re: Livecode Tuturoal: A Simple Calculator
It will increment the name automatically?!
Re: Livecode Tuturoal: A Simple Calculator
My bad, when I am using Lc, I am rarely past v6.5.2 (and usually much older). A bad habit I picked up was using 'Replicate' when I need more than one thing. When you use replicate, it certainly does name the copies automatically incremented -- Unfortunately for me, I thought this was the default behavior no matter how you introduced extra objects, so good catch and thank you, SparkOut!
Of course, now I wonder why this isn't the default behavior, heh. I know they got rid of replicate but still...
Re: Livecode Tuturoal: A Simple Calculator
By the way, if you miss using the replicate palette, you can restore it in the IDE by copying it from the palettes folder to the plugins folder, where it apparently works just fine.
The path to it on 'nix is ~/.runrev/components/livecodecommunity-9.5.0.x86/Toolset/palettes/revreplicate.rev
The path to it on 'nix is ~/.runrev/components/livecodecommunity-9.5.0.x86/Toolset/palettes/revreplicate.rev
-
- VIP Livecode Opensource Backer
- Posts: 9655
- Joined: Wed May 06, 2009 2:28 pm
- Location: New York, NY
Re: Livecode Tuturoal: A Simple Calculator
Hi.
All good, I see.
But to lock this down, know that there are several ways to refer to a control. One VERY native way is that control's "layer" (1,2,3...). Another is its "name". There is an inherent conflict that will likely cause problems if a number is used as a name.
So if you have three fields, say, Livecode "knows" those fields as they are layered, that is, 1,2 and 3. If, in layer order, they are named "3,2,1", and you ask for "field 1", LC will assume you meant the field with layer 1, NOT the field named "1".
Now then, there is great advantage in referring to a suite of controls by an appended numerical value. Get in the habit of using names like "myField1, myField2..." or whatever, when you do that sort of thing. In the above naming example:
Try the above, and also some of your own experiments. This is fundamental stuff.
Craig
All good, I see.
But to lock this down, know that there are several ways to refer to a control. One VERY native way is that control's "layer" (1,2,3...). Another is its "name". There is an inherent conflict that will likely cause problems if a number is used as a name.
So if you have three fields, say, Livecode "knows" those fields as they are layered, that is, 1,2 and 3. If, in layer order, they are named "3,2,1", and you ask for "field 1", LC will assume you meant the field with layer 1, NOT the field named "1".
Now then, there is great advantage in referring to a suite of controls by an appended numerical value. Get in the habit of using names like "myField1, myField2..." or whatever, when you do that sort of thing. In the above naming example:
Code: Select all
repeat with y = 1 to 3
put y * 10 into field "myField" & y
end repeat
Craig
Re: Livecode Tuturoal: A Simple Calculator
Code: Select all
...
put y * 10 into field ("myField" & y)
...
-
- VIP Livecode Opensource Backer
- Posts: 9655
- Joined: Wed May 06, 2009 2:28 pm
- Location: New York, NY
Re: Livecode Tuturoal: A Simple Calculator
Klaus makes a good point. Don't be sloppy.
Craig
Craig
Re: Livecode Tuturoal: A Simple Calculator
Yes, but by all means be happy
Re: Livecode Tuturoal: A Simple Calculator
Thanks all for the valuable information. Keith