Anything beyond the basics in using the LiveCode language. Share your handlers, functions and magic here.
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller
-
pderks
- Posts: 58
- Joined: Sat May 14, 2011 4:25 pm
Post
by pderks » Sun May 17, 2015 7:33 am
This handler in my central lib stack selects all fields, buttons, … at once.
Message box in: SAO "F"
Message box out: select fld 1 and fld 2 and fld 3 and fld 4
Code: Select all
on SAO BtOrFd
choose Pointer Tool
if BtOrFd = "B"
then
put "btn" into ObD
put the Number of btns into ObC
else
put "fld" into ObD
put the Number of flds into ObC
end if
put "select" into SelCmd
repeat with ii = 1 to ObC
put space & ObD && ii && "and" after SelCmd
end repeat
delete last word of SelCmd
put SelCmd into msg
do SelCmd
end SAO
Peter
-
dave.kilroy
- VIP Livecode Opensource Backer

- Posts: 858
- Joined: Wed Jun 24, 2009 1:17 pm
-
Contact:
Post
by dave.kilroy » Sun May 17, 2015 12:15 pm
That's a nice piece of code Peter - thank you, I'm salting that away for future use

"...this is not the code you are looking for..."
-
Klaus
- Posts: 14208
- Joined: Sat Apr 08, 2006 8:41 am
-
Contact:
Post
by Klaus » Sun May 17, 2015 4:40 pm
Hi guys,
here a slighly shorter way:
Code: Select all
on SAO BtOrFd
choose Pointer Tool
if BtOrFd = "B" then
repeat with i = 1 to the num of btns
set the selected of btn i to TRUE
end repeat
else
repeat with i = 1 to the num of flds
set the selected of fld i to TRUE
end repeat
end if
end SAO
Best
Klaus
-
Klaus
- Posts: 14208
- Joined: Sat Apr 08, 2006 8:41 am
-
Contact:
Post
by Klaus » Sun May 17, 2015 5:00 pm
P.S.
This is also quite handy when you need to group a couple (or all) objects!
No need to mess around with DO!
Code: Select all
command group_all_buttons
repeat with i = 1 to the num of btns
set the selected of btn i to TRUE
end repeat
GROUP
select empty
end group_all_buttons
You get the picture

-
dave.kilroy
- VIP Livecode Opensource Backer

- Posts: 858
- Joined: Wed Jun 24, 2009 1:17 pm
-
Contact:
Post
by dave.kilroy » Sun May 17, 2015 5:06 pm
Yes Klaus your way is much shorter and neater - and leaves 'DO' out of the picture so would be faster. But what I particularly liked about Peter's way was his (new to me) use of 'and' that I at first thought wouldn't compile until I tried it and realised it worked!
And thanks also Klaus for your 'group' handler
"...this is not the code you are looking for..."