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

Re: dynamic variables


  • Subject: Re: dynamic variables
  • From: "jay" <email@hidden>
  • Date: Thu, 24 Jul 2003 10:55:19 -0400

Thanks for your reply jj.

I'm not sure if that is what I am looking for. It could be better described with an example: My program is going to get 100 numbers while it is running (say from the user). I need to save all 100 numbers. Instead of defining 100 variables outright I want my script to create a new variable every time it receives a new number. Thus my program would start with 0 number variables and end with 100 variable numbers.

Any insight is appreciated,
-j









> is there any way to create variables dynamically in applescript?
>
> thanks,
> -j

Do you mean using a string created on-the-fly?
You can, but it is not a recomendable practice, unless you need it so bad...
In this sample, you can see that I assign an integer value to the new var;
there are not problems, since I can coerce an integer to string, and build
the entire "script" string to "run". But for a list or record, I should
write some extra lines to "stringize" such list or record...

Here, the sample:

#########################################
--> get hard disk name, eg, to build a variable
set varName to text 1 thru -2 of ("/" as POSIX file as string)
set varValue to varName's length --> create also a value on-the-fly

--> enclose varName within "|", to avoid blank spaces and special chars
set myVar to run script "set my parent's |" & varName & "| to " & varValue

whatever * 2 --> test it! My disk is called "whatever", so this returns 16
#########################################

jj




________________________________________________________________
Sent via the WebMail system at 1st.net
_______________________________________________
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: dynamic variables
      • From: Emmanuel <email@hidden>
    • Re: dynamic variables
      • From: "Steven D. Majewski" <email@hidden>
  • Prev by Date: Re: Run scripts from contextual menu
  • Next by Date: Re: Why is AS so poorly documented?
  • Previous by thread: Re: dynamic variables
  • Next by thread: Re: dynamic variables
  • Index(es):
    • Date
    • Thread