Re: New to AppleScript,please help.
Re: New to AppleScript,please help.
- Subject: Re: New to AppleScript,please help.
- From: "Nigel Garvey" <email@hidden>
- Date: Sat, 8 Jan 2011 14:24:40 +0000
Shane Stanley wrote on Sat, 08 Jan 2011 13:07:56 +1100:
>On 6/1/11 12:47 PM, "André Renault" <email@hidden> wrote:
>
>>> open for access requires an HFS path or file/alias, not a POSIX path.
>>
>> But it worked. I tested it and it worked. What else can I saySˇ
>
>Indeed it does. I'm sure it never used to -- the AS team used to be
>sticklers for the mantra that strings are not files. I wonder when it
>changed.
>
>Anyone still running 10.5 care to try?
>
> read "/Path/To/Text/File.txt" -- POSIX path
I think there's still a case to be made for showing those "new to
AppleScript" the right way to do things instead of giving them code
which replies on undocumented behaviour only available with the latest
AppleScript version.
And from an educational point of view, there are other things to
criticise in the script …
>set randomList to {}
>repeat 34 times
> copy (random number from 21 to 29) to the end of randomList
>end repeat
>
>set {AppleScript's text item delimiters, tid} to {"\n", AppleScript's
>text item delimiters}
>set pathToFile to "/Path/To/Text/File.txt"
>set openedFile to open for access pathToFile with write permission
>write (randomList as string) to openedFile
>close access openedFile
… such as the use of 'copy' when 'set' would do, the lack of a 'try'
statement to catch any errors while the file's open for access, the
assumption that the file won't have anything in it already, and the
failure to restore the TIDs from the saved value.
NG
_______________________________________________
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