Re: What makes AppleScript difficult
Re: What makes AppleScript difficult
- Subject: Re: What makes AppleScript difficult
- From: Doug McNutt <email@hidden>
- Date: Wed, 5 Dec 2007 21:22:03 -0700
At 20:19 -0500 12/5/07, 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.
If you come from a programming background you know about
cat flie_that_exists > file_that_doesn\'t_exist
It works fine and simply creates the file. It has a name that you just gave it and doesn't complain that you didn't create it first. It's an example of why AppleScript is so hard for experienced programmers to understand.
>An 'alias', which implies (by its name) a reference to something else, must,
>therefore, exist before you can call it an 'alias'.
In most shells, even Apple's MPW of the classic era.
alias la "ls -a"
would create a temporary command, la, which performs an ls including all files in a directory. The alias does not exist until the alias command crates it. That was around in the geek world before Apple or Macintosh existed. It is hard for experienced programmers to accept the redefinition when there is the long standing link concept. What's more, Apple has never released the real definition of an alias resource or a Finder alias file. It's magic that sometimes doesn't work, especially when cutting CD-ROM's. OS 7 introduced the File-ID which was assigned to a new file and never changed until a disk was reformatted. That was the basis for an alias but there is a lot more and Apple doesn't tell.
>You are talking about 'strings'. Filenames of files that don't exist are
>just that: strings.
Actually they might be unicode text these days. In AppleScript sometimes one has to be careful about that with the file system accepting UTF-8 while AppleScript uses UTF-16.
>So, you are not experiencing a problem of AppleScript, but a problem of your
>conceptualization of what is a file, what is a string and what is a thing
>that refers to a thing (an alias.)
or a hard or a soft link now that we're in a BSD system. And something that refers to thing is called a reference in AppleScript even though it's a pointer in something simple like C. In a way it's all of the new definitions of programmer jargon that create the confusion.
>'POSIX path' is meant to give a potentially valid posix/unicode string
>version of a (potential) path. It's up to you to know whether or not that
>thing at the end of the path actually exists already.
Does that mean that a string like "Mac HD:Documents:sometinbgnew.txt" is NOT something that might exist in a few microseconds?
>Make sense? ;)
Nope.
>Key Point WRT AppleScript: any time you say 'alias' that thing MUST already exist.
Unless you:
tell application Terminal
do script "alias la 'ls -a' in window 'MySpecial'"
end tell
--
Applescript syntax is like English spelling:
Roughly, though not thoroughly, thought through.
_______________________________________________
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