Changing background group behavior on one card

LiveCode is the premier environment for creating multi-platform solutions for all major operating systems - Windows, Mac OS X, Linux, the Web, Server environments and Mobile platforms. Brand new to LiveCode? Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
derek
Posts: 17
Joined: Tue Oct 17, 2006 9:39 pm
Location: New Mexico

Changing background group behavior on one card

Post by derek » Fri Jul 20, 2007 3:36 pm

This must be a common problem, but I haven't found information on how to deal with it. I have a quiz stack with different substacks for each section of the quiz. Each card within a substack shares three different background groups. For the most part, this works well. If I add a card to a substack, it matches the other cards. If I modify the layout for one of the groups in a substack, all the cards reflect the changes, and remain consistent.

My problem is dealing with the final card of each substack. It needs slightly different behavior from the other cards. In my stack, the only difference needed is to have my "nextCard" button jump to a different substack, instead of the next card in the current substack. I just need to modify a single line of a single script. However, I can imagine needing more complex variations on the last card of a substack.

Is there a way to modify, on a single card, the behavior of a background group, or of an object within a background group? Is there a better way to approach this?

The only thing that I have figured out so far is to remove all the groups from the last card, then create similar-looking objects that are not grouped, and copy all the scripts from the grouped objects into them. Then I modify the script for my "nextCard" button. Not only is this very tedious to do even once, but every subsequent change to the substack groups requires separate modification of the final card. And if I want to add an additional card to the stack after my current, ungrouped last card, then I have another round of manual editing to do.

There has got to be a better way. I'm using Revolution Studio 2.7.4 no Mac OS 10.4.9. What do you suggest?

Derek
Derek Roff
Language Learning Center
University of New Mexico

Klaus
Posts: 13829
Joined: Sat Apr 08, 2006 8:41 am
Location: Germany
Contact:

Post by Klaus » Fri Jul 20, 2007 3:44 pm

Hi derek,

does a simple:

Code: Select all

...
if the num of this cd = the num of cds then
   ## now you are on the LAST card of the stack!
    go stack "name of substack here"
    ## or whatever...
  else
   ## there IS a next card in the stack...
   go next cd
end if
...
in the script of that namely button work for you? :-)
This way you could use the same group on every card and the button still does what you want.

At least that's how I understand your problem...


Regards

Klaus

derek
Posts: 17
Joined: Tue Oct 17, 2006 9:39 pm
Location: New Mexico

Post by derek » Fri Jul 20, 2007 4:11 pm

Thanks, Klaus. Your suggestion will solve my current problem, and is much easier than anything I had thought of.

Is there a good way to tackle the more general problem of single-card modifications to group behaviors? In a more complex situation, it seems like I might have half a dozen "if statements" in different scripts, all evaluating "last card" status on every card, just to affect the behavior of a single card.

And if I also want to modify the group behavior on another card or two in a stack, which aren't the last card, then my "if statements" become increasingly complex. Probably Revolution doesn't address this directly.

Derek
Derek Roff
Language Learning Center
University of New Mexico

xApple
Posts: 113
Joined: Wed Nov 29, 2006 10:21 pm
Location: Geneva

Post by xApple » Sat Jul 21, 2007 10:29 pm

derek wrote: "if statements" become increasingly complex.
I'm sure you will handle the small increase in complexity ;) Note that it's better to use a switch control structure in this case.

Code: Select all

on mouseUp
switch the name of this card
case "SpecialBehaviour1"
 -- behviour for a special card
break
case "SpecialBehaviour2"
 -- behviour for another special card
break
case "LastCard"
 -- behviour for last card
break
default
 -- behviour in all other cards of the group
end switch
end mouseUp

Post Reply

Return to “Getting Started with LiveCode - Experienced Developers”