Set Variable or CustomProperty Names with and expression
Peter Haworth
pete at lcsql.com
Wed Aug 12 14:17:38 EDT 2015
Instead of setting individual cprops, you could store the whole array as a
cprop - "set the uQuoteSets of this stack to aQuoteSets". When you want to
use them, "put the uQuoteSets of this stack into aQuoteSets"
By the way, I entered a QCC report about the ability to use expressions as
custom property names a few months back. Mark Waddingham commented that it
should be fairly easy to implement but it hasn't happened yet.
On Wed, Aug 12, 2015 at 10:45 AM Brahmanathaswami <brahma at hindu.org> wrote:
> Neither of these worked...
>
> I took the cue from Mark and tried arrays
>
> this was incredibly simple... almost.
>
> In the end I was unable to figure out how to pass a variable string as a
> name of a custom property. My head was hurting, so instead of breaking
> it on further attempts to find the algorithm for this... I "man handled
> it" in the end with my usual verbose "baby xTalk"
>
> command getAndDistributeCategories
> set the defaultstack to "Gurudeva"
> put url ("file:/" & localpath()& "data/gurudeva-quotes.txt") into
> gAllQuotes
>
> set the uAllQuotes of stack "Gurudeva" to gAllQuotes # line/pipe
> delimited
> put the uCategories of this stack into tCategories # tab delimited
>
>
> set the linedelimiter to "|"
> set the itemdelimiter to tab
>
> repeat for each line x in gAllQuotes
>
> repeat for each item y in tCategories
> put "t" & y & "Set" into tAggregatedSet
> if (item 6 of x contains y) then put x & "|" after aQuoteSets[y]
> end repeat
>
> end repeat
>
> # get some stats
>
> repeat for each item y in tCategories
> put y & " quotes: " & the number of lines of aQuoteSets[y] & cr
> after tCountCheck
> end repeat
>
> put tCountCheck into url ("file:/"& localpath() &
> "data/quote-spread-stats.txt")
>
> ## LOAD PROPS - which is the target goal of this handler ##
>
> # I "give up" on a more efficient method.. this works but
> # has the downside of being hard-wired... so if we change the category
> names
> # we have to manually massage this code... there must be a better way:
> # you cannot do anything like
> # set the ("u" & y & "Set") of this stack... the compiler complains this
> is illegal
>
> set the uKarmaQuotes of this stack to aQuoteSets["Karma"]
> set the uHinduismQuotes of this stack to aQuoteSets["Hinduism"]
> set the uSivaQuotes of this stack to aQuoteSets["Siva"]
> set the uWisdomQuotes of this stack to aQuoteSets["Wisdom"]
> set the uLifeQuotes of this stack to aQuoteSets["Life"]
> set the uGuruQuotes of this stack to aQuoteSets["Guru"]
> set the uSelfQuotes of this stack to aQuoteSets["Self"]
> set the uGodsQuotes of this stack to aQuoteSets["Gods"]
> set the uHumorQuotes of this stack to aQuoteSets["Humor"]
> set the uMeditationQuotes of this stack to aQuoteSets["Meditation"]
> set the uSadhanaQuotes of this stack to aQuoteSets["Sadhana"]
> set the uWorshipQuotes of this stack to aQuoteSets["Worship"]
>
> end getAndDistributeCategories
>
> So this is the same issue: setting variable name or CustomProp name with
> an expression.
>
> Swasti Astu, Be Well!
> Brahmanathaswami
>
> Kauai's Hindu Monastery
> www.HimalayanAcademy.com
>
>
>
> dunbarx at aol.com wrote:
> > repeat for each item y in tCategories
> > do "if item 6 of"&& x&& "contains"&& y&& "then put"&&
> x&& "&"&& cr& "| after"&& t& y& "set"
> > end repeat
> >
> >
> > or:
> >
> >
> > repeat for each item y in tCategories
> > get ("t"& y& "set")
> > if item 6 of x contains y then put x& cr& "|" after it
> > end repeat
>
>
> _______________________________________________
> 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