Retrieve custom properties with variable

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: Klaus, FourthWorld, heatherlaine, kevinmiller

Post Reply
geo
Posts: 18
Joined: Sun Aug 04, 2019 7:28 pm

Retrieve custom properties with variable

Post by geo » Fri Jan 10, 2020 1:01 am

Hello

I'm trying to retreive a value from the custom properties of a button

Code: Select all

put the cZNR["Mass"] of button "btnRegistration" into tMass
this works fine

Now I need to store more data in the custom properties and would like to call it like:

Code: Select all

put the pItemname["Mass"] of button "btnRegistration" into tMass
where cZNR is in the variable pItemname.

That doesn't work

Thanks for your help

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 6467
Joined: Wed May 06, 2009 2:28 pm
Location: New York, NY

Re: Retrieve custom properties with variable

Post by dunbarx » Fri Jan 10, 2020 2:16 am

Hi.

Not sure what you want.

Is pItemName, typically a parameter when selecting a menuItem from a menu style button, what you are talking about? If so, is “mass” the selected menu item?

I would not use that particular name that way, assuming you are referencing a custom property that way.

Anyway, why try to store a custom property inside another custom property?

Craig

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 6467
Joined: Wed May 06, 2009 2:28 pm
Location: New York, NY

Re: Retrieve custom properties with variable

Post by dunbarx » Fri Jan 10, 2020 5:12 am

Hmmm. Is it that you just want to extract a particular custom property by selecting the property name from a menu?

I am away from my computer for a while so someone else will have to see if LC can resolve that parameter as you want But if it can’t, then I will bet a “do” construction will probably, er, do it.

Craig

FourthWorld
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 7299
Joined: Sat Apr 08, 2006 7:05 am
Location: Los Angeles
Contact:

Re: Retrieve custom properties with variable

Post by FourthWorld » Fri Jan 10, 2020 7:01 am

There are a couple different ways to go, but help me catch up with what you're envisioning: what is the benefit of binding the data to a specific object?
Richard Gaskin
Community volunteer LiveCode Community Liaison

LiveCode development, training, and consulting services: Fourth World Systems: http://FourthWorld.com
LiveCode User Group on Facebook : http://FaceBook.com/groups/LiveCodeUsers/

geo
Posts: 18
Joined: Sun Aug 04, 2019 7:28 pm

Re: Retrieve custom properties with variable

Post by geo » Fri Jan 10, 2020 7:42 am

Hello,

I have about 20 fields where the user can change the value. Each field has a custom property stored which is use for a calculation:

Fieldvalue * constant

For this one field the user has to select a value per dropdownmenu from a different button which is then inserted in the field plus the constant has to get changed according to the user input.


With a repeat function I can loop through the fields for all calculations

mrcoollion
Posts: 450
Joined: Thu Sep 11, 2014 1:49 pm
Location: The Netherlands

Re: Retrieve custom properties with variable

Post by mrcoollion » Fri Jan 10, 2020 12:00 pm

geo wrote:
Fri Jan 10, 2020 1:01 am
I need to store more data in the custom properties
Place data in variable tData into a custom property CustompropertyName

Code: Select all

set the CustompropertyName of button "btnRegistration" to tData

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

Re: Retrieve custom properties with variable

Post by Klaus » Fri Jan 10, 2020 12:07 pm

Hi Geom

you are dealing with custom property sets, right? At least the syntax looks like.
Then you could do it in two steps:

Code: Select all

on menupick pItemName
   set the custompropertyset of btn "btnRegistration" to pItemName
   put the Mass of btn "btnRegistration" into tMass
end menupick
Tested and works! :-)


Best

Klaus

geo
Posts: 18
Joined: Sun Aug 04, 2019 7:28 pm

Re: Retrieve custom properties with variable

Post by geo » Fri Jan 10, 2020 9:50 pm

Hi Klaus

Thanks, works perfect

Any Idea why it doesn't work when I have the name of the custom property set in the variable like i described in my post?

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

Re: Retrieve custom properties with variable

Post by Klaus » Fri Jan 10, 2020 10:15 pm

Sorry, no idea...

Post Reply

Return to “Getting Started with LiveCode - Complete Beginners”