• 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
Setting Variables to List Items
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Setting Variables to List Items


  • Subject: Setting Variables to List Items
  • From: Peter Bunn <email@hidden>
  • Date: Tue, 18 Mar 2003 14:09:50 -0600

Hello:

I'm trying to define (or associate?) a sequence of variables to a list of
individual items... (or at least that's what I _think_ I'm trying to do).
Please see the snippet below.

The list items in the example_string may be none or many. I'd like to
set (and pass) as many variables as there are list items... without
having to explicitly set each and every variable (as I do for variable_1
in the snippet)... and of course, without generating multiple errors if
the list items don't exist.

I can create a sequential list of variables to the count of the list
items, but I can't seem to set them to the list of items such that the
variable itself can be called by name.

Additionally, I'm thinking I might try to load and run another script to
handle all the variables, but if their number is unknown...

I'm not getting very far by just head-banging...

Any/all help is appreciated.

Thanks.

Peter B.

-----

set example_string to "-walk-run-hide-quit"

try

set _Priors_ to AppleScript's text item delimiters
set AppleScript's text item delimiters to "-"
set all_items to text items 2 through -1 of example_string as list
set AppleScript's text item delimiters to _Priors_

on error
set all_items to ""
end try

set variable_1 to item 1 of all_items

variable_1

-->"walk"

-----

tell application "Imaginary"

do variable_1

end tell

-----------------------------------------
_______________________________________________
applescript-users mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/applescript-users
Do not post admin requests to the list. They will be ignored.

  • Follow-Ups:
    • Re: Setting Variables to List Items
      • From: Emmanuel <email@hidden>
    • Re: Setting Variables to List Items
      • From: John Delacour <email@hidden>
  • Prev by Date: Re: moving multiple *selected* messages in Eudora
  • Next by Date: HTML or JavaScript Input to AppleScript
  • Previous by thread: Re: moving multiple *selected* messages in Eudora
  • Next by thread: Re: Setting Variables to List Items
  • Index(es):
    • Date
    • Thread