Creating a customkey from a variable

Mark Schonewille m.schonewille at economy-x-talk.com
Wed Apr 27 13:23:00 EDT 2011


Hi Glen,

One of the problems is that testname and testname[student] are different variables. First it is a simple variable, but next it is an array. When you turn testname into an array, the variable is cleared and as soon as it is cleared testname is parsed as plane text and hence as a property name.

You might use the "do" variable:

put 10 into score
put "math" into myVarName
put "set the" && myVarName & "[" & quote & myStudent & quote & "] of this stack to myScore" into myScript
do myScript

But why would you do this? It is much easier to use a straightforward array structure by writing the following...

put the cStudentScores of me into myStudentScoresArray
put "math" into mySubject
put "John" into myStudent
put 10 into myScore
put myScore into myStudentScoresArray[mySubject][myStudent]
set the cStudentScores of me to myStudentScoresArray

--
Best regards,

Mark Schonewille

Economy-x-Talk Consulting and Software Engineering
Homepage: http://economy-x-talk.com
Twitter: http://twitter.com/xtalkprogrammer
KvK: 50277553

New: Download the Installer Maker Plugin 1.6 for LiveCode here http://qery.us/ce

On 27 apr 2011, at 18:27, Glen Bojsza wrote:

> Hello,
> 
> Hopefully someone is still looking at the list while the conference is going
> on...
> 
> I want to create a customkey from a variable.
> 
> on mouseup
> put "Math" into testname
> set the testname[student] of this stack to score
> end mouseup
> 
> this doesn't create the customkey or properties for me but if I don't use a
> variable it will work?
> 
> on mouseup
> set the Math[student] of this stack to score
> end mouseup
> 
> I really would like to use a variable so I can automatically create the
> customkeys on the fly.
> 
> Any suggestions?
> 
> regards,
> 
> Glen
> _______________________________________________
> use-livecode mailing list
> use-livecode at lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode





More information about the use-livecode mailing list