On Monday, July 21, 2003, at 03:29 PM, Lars Brehmer wrote:


1. Is there a way to hide multiple objects without a line for each one in the handler?

Any time you find you are repeating the same bunch of line over and over, you have an opportunity to create a separate custom handler.


For example:

on hidePies
  hide field "Apple"
  hide field "Pumpkin"
  hide field "Cherry"
end hidePies

Break out such code so that the piece (of code, not pie) has meaning to you.

You can even pass parameters, like this:

on changePie showing
  set the visible of field "Apple" to showing
  set the visible of field "Pumpkin" to showing
  set the visible of field "Cherry" to showing
end changePie

It costs little to show when something is already visible. The same applies to hide when it is not visible. If you find that the state of how things are visible can be defined either in one or more global or script local variables, or in handler parameters, then you can have one handler that updates all visibility, even those that don't need to be changed.

on updateVisibilities  kitchenClosed, beforeNoon, bossIsAround
   ...
end updateVisibilities

Use this whenever the visibilities need to change. When you learn about openCard, you may decide to put it into that handler, too.

If I have to have a code line for each object and there are 8 fields and 8 buttons on each card, the stack gets real big real fast.

Hmmm. This looks like a opportunity for sharing code and maybe even objects.


Handlers that are used by all cards (and their objects) can be put into the stack script. If the card is not specified in such handlers, then control references (such as field) apply to those on the current card.

A group can be shared on multiple cards. If you want the text in fields in the shared group to be different on each card, then make sure "share text" is unchecked in the Property Inspector. One way to share is to remove the group (not delete!) and then place (not paste) it on each card it should be on. Do not delete a shared group unless you really want to get rid of all uses. The script of the group is available to all objects in the group.

Wherever you find a lot of repetition, you might find a solution that shares handlers or objects. Think about what all those cards have in common. ...about what all those fields have in common. Ask the list with details if you need more info. There are ways to share handlers and objects in other ways.

Dar Scott






************************************************************************ ****
Dar Scott Consulting http://www.swcp.com/dsc/ Programming Services
************************************************************************ ****


_______________________________________________
use-revolution mailing list
[EMAIL PROTECTED]
http://lists.runrev.com/mailman/listinfo/use-revolution

Reply via email to