Custom Property Display

Got a LiveCode personal license? Are you a beginner, hobbyist or educator that's new to LiveCode? This forum is the place to go for help getting started. Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller

Post Reply
bqsbarbqGAnC5Z
Posts: 77
Joined: Thu Dec 08, 2011 12:19 pm

Custom Property Display

Post by bqsbarbqGAnC5Z » Mon Jan 21, 2013 9:10 pm

Hi Everyone,

I have a seemingly simple problem that I just can't seem to solve. I want to display a custom property that I have already defined in a field. I have tried the following as well as several iterations, but I just can't seem to get it to work.

Code: Select all

on preOpenCard
    put cProperty into field "property"
end preOpenCard
If you could offer any help, that'd be greatly appreciated! Thank you!

sturgis
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 1685
Joined: Sat Feb 28, 2009 11:49 pm

Re: Custom Property Display

Post by sturgis » Mon Jan 21, 2013 9:13 pm

First, you designate properties by using the keyword "the

the cwhateverproperty

And you have to tell the system where the property is located

put the cWhateverProtery of field "whateverfield" into.....

If the property is in the same object that contains the script, you can use "me" to locate the property

So if you have a button with a property, and you have a script in the same button to show the property you can do something like

put the cProperty of me into field "fieldname"

or if the property is in the current card or stack..

put the cProperty of this stack into field "fieldname"

bqsbarbqGAnC5Z
Posts: 77
Joined: Thu Dec 08, 2011 12:19 pm

Re: Custom Property Display

Post by bqsbarbqGAnC5Z » Mon Jan 21, 2013 9:24 pm

Wow that worked perfectly! Thanks for your help Sturgis!

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

Re: Custom Property Display

Post by dunbarx » Tue Jan 22, 2013 3:05 am

What Sturgis said.

You are probably familiar with and have already used native properties, no? Like "the textFont", "the backgroundColor" or "the loc"? Same thing with custom.

Look at your original construction: put cProperty into field "property"

Do you see this is identical to putting the contents of a variable (cproperty) into that field? There has to be a way for LC to tell the difference. The dictionary gives the syntax.

In that vein, you likely never actually set the property in the first place, since you have to do so explicitly with the word "set". Play around with these, though, as custom properties have enormous power, are fun, and can be used almost everywhere.

Craig Newman

Post Reply