Sorry - but I'm doing my head in trying to work out how to make an indirect reference to a group on another card.
What I have is a card that stores a set of groups that I MIGHT want to use, and an array that identifies which of those groups I actually want to use this time.
Card "AnimalStore" // Contains one group for each animal that I might want to use
Group "Horse"
Group "Fish"
Group "Cow"
Group "Dog"
Group "Cat"
etc
On PreOpenStack
Put "Fish" into WhatAnimalsToUse[1]["AnimalName"]
Put "Dog" into WhatAnimalsToUse[2]["AnimalName"]
Put "Cat" into WhatAnimalsToUse[3]["AnimalName"]
Repeat with X = 1 to 3
// Clone group WhatAnimalsToUse[X]["AnimalName"] of card "AnimalStore"
Set the name of it to "Animal" & X
// Move the cloned group to the card where I want it
End repeat
End PreOpenStack
I've been trying to use the VALUE function to implement the clone statement, but I can't work out how to handle the quotation marks in Card "AnimalStore". I've been trying to solve this with & quote &, but I can't get it right.
What would be the correct syntax for an indirect reference to a group on another card, where the name of the group was stored in an array on this card?
Any help would be much appreciated.
Indirect reference to a group on another card
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller
Re: Indirect reference to a group on another card
Hi Kim,
I don't think you need to copy or clone any of your groups at all!
Groups can appear on more than one card, yes the SAME groups.
In that case you can use the PLACE command and you need to reference to BACKGROUND XYZ:
...
place bg "Cat" onto cd 2
place bg "Fish" onto card "Friday"
...
I hope I understood your problem correctly!
General hint:
ALWAYS use parens when concatenating strings for use as object names, filepath names, URLs etc:
...
Set the name of it to ("Animal" & X)
...
Best
Klaus
I don't think you need to copy or clone any of your groups at all!
Groups can appear on more than one card, yes the SAME groups.
In that case you can use the PLACE command and you need to reference to BACKGROUND XYZ:
...
place bg "Cat" onto cd 2
place bg "Fish" onto card "Friday"
...
I hope I understood your problem correctly!

General hint:
ALWAYS use parens when concatenating strings for use as object names, filepath names, URLs etc:
...
Set the name of it to ("Animal" & X)
...
Best
Klaus
Re: Indirect reference to a group on another card
Thanks Klaus
It turned out that I had been looking at this problem for too long yesterday - and the one object that I had chosen to use as my test case was a graphic and not a group. Doh! Once I had identified and fixed this mistake, It didn't take me long to get the following to work -
Do "Clone group " & quote & value(WhatAnimalsToUse[X]["AnimalName"]) & quote & " of card " & quote & "AnimalStore" & quote
I've noted your comment about using parens when concatenating strings, and fixed this bit of code. I will also look to see if PLACE gives me some better options than CLONE.
All of this did allow me to find a new favorite LiveCode error message - "Garbage where a command should be"
Thanks again
Kim
It turned out that I had been looking at this problem for too long yesterday - and the one object that I had chosen to use as my test case was a graphic and not a group. Doh! Once I had identified and fixed this mistake, It didn't take me long to get the following to work -
Do "Clone group " & quote & value(WhatAnimalsToUse[X]["AnimalName"]) & quote & " of card " & quote & "AnimalStore" & quote
I've noted your comment about using parens when concatenating strings, and fixed this bit of code. I will also look to see if PLACE gives me some better options than CLONE.
All of this did allow me to find a new favorite LiveCode error message - "Garbage where a command should be"

Thanks again
Kim
Re: Indirect reference to a group on another card
Hi Kim,
Why clone something if you can use the "original" with much less problems
Maybe you want to take look at the "Groups & Backgrounds" stack here:
http://www.hyperactivesw.com/revscriptc ... ences.html
Best
Klaus
yes, please do that, you won't regret!KimD wrote:...I will also look to see if PLACE gives me some better options than CLONE.
Why clone something if you can use the "original" with much less problems

Maybe you want to take look at the "Groups & Backgrounds" stack here:
http://www.hyperactivesw.com/revscriptc ... ences.html
Ah, yes, that's a good one!KimD wrote:All of this did allow me to find a new favorite LiveCode error message - "Garbage where a command should be"

Best
Klaus
Re: Indirect reference to a group on another card
Hmmm. I've discovered that I was making things far more complicated than they needed to be. The following works just as well -
Copy group WhatAnimalsToUse[X]["AnimalName"] of card "AnimalStore" to card "HomeScreen"
No need to use DO, VALUE and QUOTE at all.
Klaus - What I had was a set of groups each made up of graphics. I assumed (don't even say it) that I would be able to rotate a group, but I've since discovered that I can't. So I've now switched from using a set of groups of graphics to using a set of images instead (which I can set the angle on). Because I'm now using images the option of PLACE, instead of CLONE or COPY, is no longer applicable. I have used placed groups elsewhere though; e.g. for my on-screen back button - which looks and behaves exactly the same on numerous cards.
Regards
Kim
Copy group WhatAnimalsToUse[X]["AnimalName"] of card "AnimalStore" to card "HomeScreen"
No need to use DO, VALUE and QUOTE at all.
Klaus - What I had was a set of groups each made up of graphics. I assumed (don't even say it) that I would be able to rotate a group, but I've since discovered that I can't. So I've now switched from using a set of groups of graphics to using a set of images instead (which I can set the angle on). Because I'm now using images the option of PLACE, instead of CLONE or COPY, is no longer applicable. I have used placed groups elsewhere though; e.g. for my on-screen back button - which looks and behaves exactly the same on numerous cards.
Regards
Kim
Re: Indirect reference to a group on another card
Hi Kim,
the same group will always look erm... the same on every card you place it
Best
Klaus
yes, that is how this works, you can have the SAME group on many cards and of courseKimD wrote:I have used placed groups elsewhere though; e.g. for my on-screen
back button - which looks and behaves exactly the same on numerous cards.
the same group will always look erm... the same on every card you place it

Best
Klaus