• 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: What makes AppleScript difficult
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: What makes AppleScript difficult


  • Subject: Re: What makes AppleScript difficult
  • From: Philip Aker <email@hidden>
  • Date: Wed, 05 Dec 2007 21:10:42 -0800

On 2007-12-05, at 17:19, Gary (Lists) wrote:

"Skeeve" wrote:

I still don't know how to conveniently handle filenames of files that don't yet exist

That's a red herring.  Or a black hole.  Or a white elephant.

If a file doesn't exist, then it can't possibly have a name.

Hold on a sec Gary (Lists),

Skeeve does have a faire complainte.

In previous systems, the support underlying files was FSSpec/AliasHandle. And it was possible to instantiate those items with non-existent file paths. See FSMakeFSSpec() in Files.h for instance. FSSpec has a 'name' field. An FSSpec or old-style AliasHandle could refer to a non-existent file. This had of practical value because as an object, a file can still have useful properties even if it's 'name' field is missing or refers to a file which doesn't exist.

In OS X, URLs (known as CFURLRef or NSURL in the system frameworks), although they don't have a 'name' field specifically, have a 'last path component' (see CFURLCreateCopyAppendingPathComponent() in CFURL.h for instance). And it is possible to create valid URLs with non-existent files. But AppleScript doesn't have much support for URLs even though they are more or less the global standard. Only, as you mention, for strings. 

So let's speculate about this 'fs object' for a bit. It will have all the property fields that one observes with:

tell application "System Events"
properties of (file 1 of (path to desktop) whose name extension is "scpt")
end tell

plus 'data' and 'metadata' properties.

So:

set fsobj to make new fs object with properties {parent:path to desktop folder, data:"some text", type identifier:"public.text"}, name:"some.txt"}
write fsobj
set data of fsobj to "other text"
write fsobj

The critical criteria here being that 'parent' should be valid for the write calls but not necessarily for using an fs object as a virtual file container in a script.


So, you are not experiencing a problem of AppleScript, but a problem of your conceptualization of what is a file,

I think rather it's a problem with the AppleScript implementation of a useful 'fs object'.


Philip Aker
echo email@hidden@nl | tr a-z@. p-za-o.@

 _______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users

This email sent to email@hidden

References: 
 >Re: What makes AppleScript difficult (From: "Gary (Lists)" <email@hidden>)

  • Prev by Date: Re: AppleScript4programmers
  • Next by Date: Re: AppleScript4programmers
  • Previous by thread: Re: What makes AppleScript difficult
  • Next by thread: Re: What makes AppleScript difficult
  • Index(es):
    • Date
    • Thread