Page 1 of 1

Moving objects between cards

Posted: Fri Feb 04, 2022 2:10 pm
by glenn9
I'm conscious that I've been fairly quiet on the forum over the last few months but I have been busy livecoding and tinkering with my apps in the background...

The problem that I can't seem to solve at the moment is that I'm wanting to programatically move a group from one card to a different a different card.

Assuming the Group is originally in card"A", I've tried various permutations of:

Code: Select all

put group"testGroup" into card"B" 
but these of course don't work!

Grateful for any hints!

Many thanks,

Regards,

Glenn

Re: Moving objects between cards

Posted: Fri Feb 04, 2022 2:26 pm
by Klaus
Hi Glenn,

almost! :-)
If you are on the card with your group, you can:

Code: Select all

...
place grp "testGroup" ONTO cd "B"
...
If you are on card "B" then this will throw an error -> can't find object
But this will do in that case:

Code: Select all

...
place bg "testGroup" ONTO cd "B"
...
put the num of grps -> will return the number of all groups on the current card
put the num of bgs -> will return the number of all groups in the current stack

So groups are counted relative to the card, backgrounds relative to the stack.

The opposite (remove a group) goes this way:

Code: Select all

...
remove grp "testGroup" from cd "B"
...
Best

Klaus

Re: Moving objects between cards

Posted: Fri Feb 04, 2022 2:45 pm
by glenn9
Many thanks Klaus, that was a great help.

Regards,

Glenn

Re: Moving objects between cards

Posted: Fri Feb 04, 2022 2:56 pm
by dunbarx
What Klaus said.

You can also use the "copy" command to the same effect:

Code: Select all

copy group "yourGroup" to card "otherCard"
Craig

Re: Moving objects between cards

Posted: Fri Feb 04, 2022 2:58 pm
by Klaus
dunbarx wrote:
Fri Feb 04, 2022 2:56 pm
...
You can also use the "copy" command to the same effect:

Code: Select all

copy group "yourGroup" to card "otherCard"
Not really, Craig! :D

In that case you end with two identical groups in your stack.
PLACEing will place the SAME group onto another card.

Re: Moving objects between cards

Posted: Fri Feb 04, 2022 3:10 pm
by dunbarx
Klaus.

Certainly. I thought that the OP wanted a copy of the group somewhere else.

@Glenn9. Do you see what Klaus pointed out? If you "place" a group onto another card in the same stack, then that group is an instance of a single group shared among all the cards it resides on. Changing it in one place will change it in all places.

If you "copy" that group, you essentially make a new exact copy, but one that does not share the structure of the original, nor does it "see" any changes to that original. Since you cannot "place" a group onto a different stack, that is how one would proceed if you wanted to make a copy in another stack.

Craig