Got a LiveCode personal license? Are you a beginner, hobbyist or educator that's new to LiveCode? This forum is the place to go for help getting started. Welcome!
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller
-
chris25
- Posts: 354
- Joined: Tue Oct 08, 2013 9:32 pm
Post
by chris25 » Sun Dec 08, 2013 12:50 pm
This is a stack I downloaded and went to town on: All comments are mine and would someone be kind enough to critique and let me know that I have understood Every last thing correctly, this is important for me.
The stack consists of two sets of three text entry fields; top three are for numerics, bottom three for text. Both sets grouped on one card, that's it.
Many appreciations
chris
Code: Select all
on myTestRoutine
put long id of the target into tTarget--when you press inside the text field, this is the target
--put path name of clicked field into (tTarget= now the card id) which owns the group called "gNumbers"
put the long id of the owner of tTarget into tOwner --put path of stack id (who owns the card id)
-- into (tOwner=now the stack id)
put the short name of tOwner into tShort ----put the name (found in the properties inspector) which is "name of the stack"
--which is called "callinghierarchy", put this name into the variable tShort.
switch tShort --the variable containig the properties inspector group name (switch=Define altered states of existence)
case "gNumbers" --the name of the group for numbers (Case=Situation/present circumstance)
doCalculations tOwner --tOwner contains the name of the field and therefore the number that is put into it
break --(break=change lanes from within the motorway)
case "gChars" --name of grp for characters (same as above except for characters now)
doChars tOwner
break
end switch
end myTestRoutine
--This bit logical
on doCalculations pOwner
if field 1 of pOwner is a number and field 2 of pOwner is a number then
put field 1 of pOwner + field 2 of pOwner into field 3 of pOwner
else
answer "Information incomplete or not a number"
end if
end doCalculations
on doChars pOwner
put field 1 of pOwner && field 2 of pOwner into field 3 of pOwner
end doChars
Probably good to upload the stack I thought
-
Attachments
-
- callingHierarchy.livecode.zip
- (2.02 KiB) Downloaded 205 times
-
dunbarx
- VIP Livecode Opensource Backer

- Posts: 10331
- Joined: Wed May 06, 2009 2:28 pm
Post
by dunbarx » Sun Dec 08, 2013 6:06 pm
Chris.
You made this stack or downloaded it?
So you see that the use of tags (names in these cases) can be used to isolate functionality. Just a method, but one that can be seen to exploit the best features of LC, and will give a clue to how such things as custom properties can be used similarly
I give you an A.
Homework. Ungainly to have so many "closeField" handlers in each of those fields. Where would just one do?
Craig
-
chris25
- Posts: 354
- Joined: Tue Oct 08, 2013 9:32 pm
Post
by chris25 » Sun Dec 08, 2013 6:19 pm
Hallo Craig, well I just combined the two groups into one group deleted all the handlers and inserted this into the group:
on closefield
myTestRoutine
end closefield
regards
chris
should add that I can see how functionality would be improved, but don't see any clue to the custom properties, maybe that is because I have not yet tackled this in practise. read about them but not written any.
-
dunbarx
- VIP Livecode Opensource Backer

- Posts: 10331
- Joined: Wed May 06, 2009 2:28 pm
Post
by dunbarx » Sun Dec 08, 2013 7:15 pm
Chris.
A-
Better to put it in the card or stack script, so that if you ever add another similar gadget you are covered. I don't see a particular advantage to grouping the two groups, but no harm done either. I know that you used the original group names to partition functionality, and that is perfectly workable. But you got the idea just fine. It is a sense of the hierarchy, and how to use that to advantage that matters.
Craig