• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: variable names in list
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: variable names in list


  • Subject: Re: variable names in list
  • From: Emmanuel <email@hidden>
  • Date: Mon, 17 Jan 2005 09:29:28 +0100

At 4:40 PM -0600 1/16/05, Dave Bevis wrote:
I have created several lists that I want to search a Filemaker database for the values in the list. I have also created a master list that contains the names of each list. I want to use this master list in a repeat loop that calls each item the master list and then performs a repeat loop on the items in that list.

When I reference an item in the master list, it returns a string which is the name of a list. I want to reference that as a list variable name but I can't figure out how. When I try to count the items in the list it returns the count of characters in the string.

Is there a way to have a list of variable names and when you assign that list item to a variable it can reference the variable?

I can see two fashions of performing what you want to do.

1 - using only builtin AppleScript features. I understand that you have:

set x to {"abc", "def"}
set y to {1, 2, 3}
set MasterList to {"x", "y"}

What you can do is use "run script" to make a string into the corresponding AppleScript thing:

set theListName to contents of item 1 of MasterList -- "x"
set theList to run script theListName -- should execute "x" and return {"abc", "def"}


Unfortunately this way of doing things is made difficult for context reasons: that "run script" runs a stand-alone script made only of "x", and that script ignores the context of the script we imbedded it in.

So you have to use some trick, namely you would have to describe "x" more like "my x" or "my parent's x". I let others more expert than me make that reliable, I don't know much about it, I don't use that.

2 - using a lookup table (or indexed array) structure. p-lists were designed with that kind of purpose in mind: retrieving something being given an index which is a string. Download and install XMLLib osax (it's free), then use the p-list commands.

You would made the plist with:

set pl to PlistNew
PlistNewChild x key "x" at pl
PlistNewChild y key "y" at pl

Then you retrieve the things with:

PlistGet (PlistChild pl key "x")
 -- {"abc", "def"}

See more details at: <http://www.satimage-software.com/en/plist_suite.html>.

Emmanuel
From Satimage-software, the kind developers of XMLLib.
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Applescript-users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


References: 
 >variable names in list (From: Dave Bevis <email@hidden>)

  • Prev by Date: Re: BBEdit Insertion Point Line Number
  • Next by Date: Re: Deep or Bug?
  • Previous by thread: Re: Deep or Bug?
  • Next by thread: Re: Applescript-users Digest, Vol 2, Issue 30
  • Index(es):
    • Date
    • Thread