• 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: creating temp files??
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: creating temp files??


  • Subject: Re: creating temp files??
  • From: Paul Berkowitz <email@hidden>
  • Date: Thu, 12 Jun 2003 01:03:55 -0700

On 6/11/03 10:46 PM, "Andrew Oliver" <email@hidden> wrote:

> Actually, Paul, I am correct, if you follow the entire code.
>
> I build tempFilename as a string and only a string. As the variable name
> implies it is the name of the tempfile, not the tempfile itself.
>
> The difference with your code is you convert the "path to temporary items"
> to a string in line one,

No. It's not "converted" nor coerced: 'path to [folder] as string' is not a
coercion. [as type class] is a parameter whose default happens to be 'as
alias', but 'as string' is just as native and valid.

> whereas I convert the pathname to a string when I
> concatenate the filename to it in line 2.

There's a coercion.

>
> Me:
>
> set tempDir to path to temporary items
--> alias "Macintosh HD:private:tmp:501:Temporary Items:"

> set tempFilename to tempDir & "tempfile2"
--> {alias "Macintosh HD:private:tmp:501:Temporary Items:", "tempfile2" }
-- (a list)

result as string -- a coercion
> --> "Macintosh HD:private:tmp:501:Temporary Items:tempfile2"
>
> You:
>
> set tempDir to path to temporary items as string
> set tempFilename to tempDir & "tempfile"
> --> "Macintosh HD:private:tmp:501:Temporary Items:tempfile2"
>
> Either code works. I can't see that it makes one iota of difference either
> way, except that I still stand by my code. :)

Nigel Garvey once tested this exhaustively and found that using the 'as
string' parameter of 'path to':

path to temporary items as string

is faster than the coercion of alias to string:

(path to temporary items) as string
>

It will be be true also for coercing a list consisting of an alias and a
string to a string. Entirely trivial here, of course, but there might be
other circumstances where a coercion might not work as expected:

set AppleScript's text item delimiters to {"/"}
set tempDir to path to temporary items
set tempFilename to tempDir & "tempfile2" as string
--> OS X HD:private:tmp:501:Temporary Items:/tempfile2


It just seems better to use the parameter. Not a big deal.


--
Paul Berkowitz
_______________________________________________
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.

References: 
 >Re: creating temp files?? (From: Andrew Oliver <email@hidden>)

  • Prev by Date: Applescript and Desktop Printer Manager in MacOS 9.2.2
  • Next by Date: Re: concat
  • Previous by thread: Re: creating temp files??
  • Next by thread: Re: creating temp files??
  • Index(es):
    • Date
    • Thread