saving properties of a card?

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

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
PoLyGLoT
Posts: 105
Joined: Sat Jan 14, 2012 12:37 am

saving properties of a card?

Post by PoLyGLoT » Sun Aug 25, 2013 5:53 pm

Hi all.

I often have 1 main card I use which contains lots of fields / buttons. Depending on the scenario, I'll hide / show certain fields and hide / show certain buttons. I have a program now that has 7 or so different possibilities, and thus 7 or so different "hide/show" patterns.

Right now, I have it check to see which case we are in (let's say condition = 1), then I have it hide / show the appropriate fields and buttons.

Would it be possible to save each configuration of fields shown / hid and each configuration of buttons shown / hid into a certain custom property or profile? For instance, condition 1 would have a profile called "Condition 1". And instead of having to reference a long list of "show / hide" fields and buttons, I could just say something like if condition = 1 then use configuration Condition 1...

Is this at all possible?

Thx.

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

Re: saving properties of a card?

Post by dunbarx » Sun Aug 25, 2013 7:36 pm

This will be a simple and fun task. Create seven custom properties of the card. Each will contain a list of the desired state of the visible property for each control. In a preOpenCard or closeCard handler (or something local), depending, you can run through all the controls in question and set as needed.

The list for "propA" might be set up as a comma delimited with the name or ID and the associated visibility:

button 1. "true"
button 2, "false"
button 3, "false"

You could use an array as well.

Then when you need to set the states of those controls, you can loop through the list and set as you go. I do not see a way around the need to loop, though this should take only a few microseconds. There are several ways to access the list data. I am not sure if you will need to use a "do" construction to make it work, but you might. Write back if you need more...

Craig Newman

Post Reply