Set Variable or CustomProperty Names with and expression

Brahmanathaswami brahma at
Wed Aug 12 13:45:24 EDT 2015

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 

    set the uAllQuotes of  stack "Gurudeva"  to gAllQuotes # line/pipe 
    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() & 

## 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!

Kauai's Hindu Monastery

dunbarx at 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

More information about the Use-livecode mailing list