Page 3 of 3

Re: Radio buttons to show/hide group

Posted: Mon Oct 13, 2014 3:44 am
by dunbarx
Hermann.

I used "Compile-it" in HC for years. Some of the legacy stacks I still run have its XCMD's and XFCN's still resident there. It takes a little practice to shape handlers in order to use it to best advantage, but the speed increase was astounding. It came, of course, on floppy discs. Of course, on a Mac Plus, you still get a floppy drive.

Craig

Re: Radio buttons to show/hide group

Posted: Mon Oct 13, 2014 4:31 am
by jacque
[-hh] wrote: Positive Example (wonderful 'shortcut'):
get target = do ("get" && the target) = get the text of the target

True?
LOL. Yes, it's true. :)

Re: Radio buttons to show/hide group

Posted: Mon Oct 13, 2014 5:32 am
by Kevtor
Hey Guys,

I needed to use the second example because I have many groups I don't want hidden so I relabeled my groups to headData1, headData2 etc. and tried this:

on mouseup
-- repeat with x = 2 to the number of grps of this cd -- start with grp 2 since grp 1 is the radiobuttons
-- hide grp x
-- end repeat
-- put label of target into tNr; show grp (tNr +1)

repeat with y = 1 to the number of groups of this card
hide group "headData" & y
end repeat
end mouseup

I get this error when I hit Apply:

group "screwsRadioButton": compilation error at line 8 (repeat: garbage where a command should be) near "&", char 16

I can't see what's wrong.

I put headData1 etc. into the label, should it go into name instead? I kinda wanted to keep the names more descriptive for readability in the app browser.

Also in the last commented line above there is (tNr +1). Can someone tell me what the +1 is for ?

Re: Radio buttons to show/hide group

Posted: Mon Oct 13, 2014 5:47 am
by dunbarx
Bingo.

The basic referential syntax assumes the name, not the label of the control:

Code: Select all

hide group "headData" & y
may be considered to be (pseudo):

Code: Select all

hide that group who's name is "headData" & y
To use the label property (or any other property), you would have to expand the loop explicitly as follows;

Code: Select all

repeat with y = 1 to the number of groups of this card
if the label of grp y = ("headData" & y) then hide grp y --always good to use parentheses, though not formally required to compile
end repeat
Craig

Re: Radio buttons to show/hide group

Posted: Mon Oct 13, 2014 4:59 pm
by jacque
Another reason to always use "the" with properties just appeared in another thread. Custom properties require its use. The habit of omitting it can carry over to custom properties and in this case the user could not understand why his code was failing.

I'm being pedantic, but maybe with good reason.

Re: Radio buttons to show/hide group

Posted: Mon Oct 13, 2014 6:56 pm
by [-hh]

Code: Select all

on mouseUp
  set pedantic of me to "with good Reason"
  answer the pedantic of me
end mouseUp
It works ;-)

Re: Radio buttons to show/hide group

Posted: Mon Oct 13, 2014 7:04 pm
by dave.kilroy
shouldn't that be "set THE pedantic of me..."? :)

Edit: hmmm maybe Hermann left off the 'the' on purpose and I fell straight into his look-I'm-not-using-a-the-in-this-pseudo-code trap :)

Re: Radio buttons to show/hide group

Posted: Mon Oct 13, 2014 7:45 pm
by [-hh]
Dave, you were too fast, so I couldn't improve my english wording.

Code: Select all

on mouseUp
  set beingPedantic of me to "with good Reason"
  answer the beingPedantic of me
end mouseUp
It works: Even Queens are not always right. I learned from dictionary: "the" is optional with (all kind of) properties ...
This optional usage of "the" is the reason, I believe, that it is impossible for the current engine to use an evaluation as a property name. For example set (word 1 of "") of me to "No I'm not." doesn't work. But this works:

Code: Select all

on mouseUp
  set empty of me to "No I'm not."
  answer the empty of me
end mouseUp
[To avoid misunderstandings. The pudding is presumably me.]

Re: Radio buttons to show/hide group

Posted: Mon Oct 13, 2014 8:36 pm
by dave.kilroy
Let's see if I can improve on what you've done... ah yes how about this:

Code: Select all

on mouseUp;set beingPedantic of me to "with good Reason";answer the beingPedantic of me;end mouseUp
And the hilarious thing is it actually does compile and work :)

Re: Radio buttons to show/hide group

Posted: Mon Oct 13, 2014 10:01 pm
by jacque
Interesting:

http://forums.livecode.com/viewtopic.ph ... 11#p111808

Next time maybe I shouldn't answer from my Android tablet so I can double-check what I read.

Re: Radio buttons to show/hide group

Posted: Tue Oct 14, 2014 12:59 am
by [-hh]
Dave, you won the competition for the best (not the shortest!) one-liner of the day:-)

Re: Radio buttons to show/hide group

Posted: Tue Oct 14, 2014 1:06 am
by dave.kilroy
Hermann - well I should think possibly the most annoying (it is remarkable what the engine will let you get away with) but once Craig realises how many semicolons I've used I may live to regret it :)
[-hh] wrote:Dave, you won the competition for the best (not the shortest!) one-liner of the day:-)

Re: Radio buttons to show/hide group

Posted: Tue Oct 14, 2014 10:27 am
by keram
Kevtor wrote:Also in the last commented line above there is (tNr +1). Can someone tell me what the +1 is for ?
I'm away from the computer and LiveCode for a few weeks but if I remember right tNr when chosing the 1st radio button would be 1 (2nd radio button 2, etc) and so you want to show group 2 because group 1 is the group of the radio buttons. So you want to show group nr 1+1 =2.