• 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: Incrementing variables
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Incrementing variables


  • Subject: Re: Incrementing variables
  • From: Christopher Nebel <email@hidden>
  • Date: Tue, 19 Jul 2005 16:33:31 -0700

On Jul 19, 2005, at 3:34 PM, Robert Poland wrote:

Is there a way to create variables in Applescript like, X(Y)? Where x is the variable and Y could be another variable.

Do you mean a list?

no...

set selectedPlots  to {1,2,3,4}
repeat with index from 1 to selectedPlots
    set xplot to item index of selectedPlots as integer

    if xplot = 1 then -- lying
        set plotValue(xplot) to theValue(xplot)
        set plotValue(xplot) to theValue(xplot)
        ...
    end if ...

I don't know about everyone else, but that example didn't clarify anything for me. Are you trying to synthesize new variable names at runtime? Could you, for instance, somehow mash the strings "plotValue" and "1" together to access a variable named "plotValue1"? No, you can't do that, but you probably don't need to -- a list (if the "index" is always a number) or an associative array (if it isn't) should serve just as well, if not better.



--Chris Nebel AppleScript and Automator Engineering

P.S.: Yes, I know, AppleScript doesn't have associative arrays built- in. There are packages that will do most of the heavy lifting for you, though.

_______________________________________________
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: 
 >Incrementing variables (From: Robert Poland <email@hidden>)
 >Re: Incrementing variables (From: Michael Ghilissen <email@hidden>)
 >Re: Incrementing variables (From: Robert Poland <email@hidden>)

  • Prev by Date: Re: Choose from list
  • Next by Date: Re: UI scripting: how to click 'OK' in Photo-Paint
  • Previous by thread: Re: Incrementing variables
  • Next by thread: Re: Incrementing variables
  • Index(es):
    • Date
    • Thread