• 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: Using a variable in a property
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

RE: Using a variable in a property


  • Subject: RE: Using a variable in a property
  • From: Joe Kelly <email@hidden>
  • Date: Tue, 11 Dec 2001 17:17:43 -0800

Since destfol is a string, and not an alias or reference to some finder
item, you need to add the specifier 'folder', as in:

make file at folder destfol with properties {....} -- destfol is a string.

OR, you can instead:

set destfol to "Macintosh HD:E-mail:AppleScript list:" as alias -- destfol
is now an alias

OR

set destfol to folder "Macintosh HD:E-mail:AppleScript list:" -- destfol is
now a folder


I prefer to store all my references to file/folder objects as path strings,
hence I use the former, although if I use an object more than once, I make
it into a reference and use that, as I believe it faster than resolving a
path each time.

joe



> -----Original Message-----
> From: William Barnes [mailto:email@hidden]
> Sent: Tuesday, December 11, 2001 5:01 PM
> To: Applescript list
> Subject: Using a variable in a property
>
>
> I'm trying to write my first script, and would like to know if it is
> possible to use a variable in the definition of a property.
> The object of
> the script is to save Emailer messages of the Applescript
> list digest to
> a folder outside of Emailer:
>
> tell application "Claris Emailer"
> activate
> set bodyvar to message 1 of folder "AppleScript list"
> set subjectvar to subject of message 1 of folder
> "AppleScript list"
> end tell
>
> tell application "Finder"
> activate
> set filnam to characters 26 thru 35 of subjectvar
> set destfol to "Macintosh HD:E-mail:AppleScript list:"
> make file at destfol with properties ,
> {name:filnam as string, creator type:"NISI", file type:"TEXT"}
> set filRef to (open for access file filnam with write
> permission)
> write bodyvar to filRef
> save fileRef
> close access filRef
> end tell
>
> The script chokes on the "make file..." line with an error message
> "Invalid key form". I am assuming that this results from my
> trying to use
> the variable 'filnam' for the 'name' property, and it cannot
> be coerced
> into a string. Any suggestions would be greatly appreciated.
>
> William
> _______________________________________________
> 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.


  • Prev by Date: Using a variable in a property
  • Next by Date: Re: Using a variable in a property
  • Previous by thread: Using a variable in a property
  • Next by thread: Re: Using a variable in a property
  • Index(es):
    • Date
    • Thread