Select a range of e.g. buttons by script

Anything beyond the basics in using the LiveCode language. Share your handlers, functions and magic here.

Moderators: Klaus, FourthWorld, heatherlaine, kevinmiller, robinmiller

Post Reply
pderks
Posts: 58
Joined: Sat May 14, 2011 4:25 pm

Select a range of e.g. buttons by script

Post by pderks »

Hi,

in card 1 I have a layout of 4 x 25 buttons. In the following cards I need an each different number (1 … 7, 25 … 40, …) of them.

Creating and outfitting buttons on their cards is very time consuming. Is there a scripted option, to select, copy and paste such a range of buttons, fields, … at a single blow ?

Regards and thanks

Peter
Klaus
Posts: 14325
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: Select a range of e.g. buttons by script

Post by Klaus »

Hi Peter,

a clever naming scheme will always help, so you will be able to do something like this:

Code: Select all

...
go cd 1 
# if neccessary
repeat with i = 1 to 7
  set the selected of btn ("button" & i) to TRUE
end repeat
copy
select empty
go cd 2
paste
...
Best

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

Re: Select a range of e.g. buttons by script

Post by dunbarx »

Another way is something like this.

Code: Select all

on mouseUp
   repeat with y = 1 to 3
      copy btn y to card yourDestinationCard
   end repeat
end mouseUp
It is up to you to manage how the buttons are "selected", but the copy command does what you need directly.

Craig Newman
pderks
Posts: 58
Joined: Sat May 14, 2011 4:25 pm

Re: Select a range of e.g. buttons by script

Post by pderks »

@ Klaus
@ Craig

thank you for your really needed (and quick) help.

Peter
Post Reply