Radio buttons to show/hide group

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

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10317
Joined: Wed May 06, 2009 2:28 pm

Re: Radio buttons to show/hide group

Post by dunbarx » Mon Oct 13, 2014 3:44 am

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

jacque
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 7390
Joined: Sat Apr 08, 2006 8:31 pm
Contact:

Re: Radio buttons to show/hide group

Post by jacque » Mon Oct 13, 2014 4:31 am

[-hh] wrote: Positive Example (wonderful 'shortcut'):
get target = do ("get" && the target) = get the text of the target

True?
LOL. Yes, it's true. :)
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com

Kevtor
Posts: 15
Joined: Tue Jul 02, 2013 11:51 am

Re: Radio buttons to show/hide group

Post by Kevtor » Mon Oct 13, 2014 5:32 am

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 ?

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10317
Joined: Wed May 06, 2009 2:28 pm

Re: Radio buttons to show/hide group

Post by dunbarx » Mon Oct 13, 2014 5:47 am

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

jacque
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 7390
Joined: Sat Apr 08, 2006 8:31 pm
Contact:

Re: Radio buttons to show/hide group

Post by jacque » Mon Oct 13, 2014 4:59 pm

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.
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com

[-hh]
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 2262
Joined: Thu Feb 28, 2013 11:52 pm

Re: Radio buttons to show/hide group

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

Code: Select all

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

dave.kilroy
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 858
Joined: Wed Jun 24, 2009 1:17 pm
Contact:

Re: Radio buttons to show/hide group

Post by dave.kilroy » Mon Oct 13, 2014 7:04 pm

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 :)
"...this is not the code you are looking for..."

[-hh]
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 2262
Joined: Thu Feb 28, 2013 11:52 pm

Re: Radio buttons to show/hide group

Post by [-hh] » Mon Oct 13, 2014 7:45 pm

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.]
shiftLock happens

dave.kilroy
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 858
Joined: Wed Jun 24, 2009 1:17 pm
Contact:

Re: Radio buttons to show/hide group

Post by dave.kilroy » Mon Oct 13, 2014 8:36 pm

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 :)
"...this is not the code you are looking for..."

jacque
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 7390
Joined: Sat Apr 08, 2006 8:31 pm
Contact:

Re: Radio buttons to show/hide group

Post by jacque » Mon Oct 13, 2014 10:01 pm

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.
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com

[-hh]
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 2262
Joined: Thu Feb 28, 2013 11:52 pm

Re: Radio buttons to show/hide group

Post by [-hh] » Tue Oct 14, 2014 12:59 am

Dave, you won the competition for the best (not the shortest!) one-liner of the day:-)
shiftLock happens

dave.kilroy
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 858
Joined: Wed Jun 24, 2009 1:17 pm
Contact:

Re: Radio buttons to show/hide group

Post by dave.kilroy » Tue Oct 14, 2014 1:06 am

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:-)
"...this is not the code you are looking for..."

keram
Posts: 340
Joined: Fri Nov 08, 2013 4:22 am

Re: Radio buttons to show/hide group

Post by keram » Tue Oct 14, 2014 10:27 am

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.
Using the latest stable version of LC Community 6.7.x on Win 7 Home Premium, 64bit

Post Reply