Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!

AppleScript OS 9 to OS X - Read Write File System
AppleScripts that worked fine in OS9 might not work in OSX. This is one of several postings relating to various problems that I have resolved while transitioning OS9 scripts to OSX. This one is related to:

Open for access file "file" -- from the Standard Additions

To see a walkthrough of what works in OS 9 vs. what works in OS X, read the rest of the article...


SETUP: in SimpleText create a new file. Make sure that it's a plaintext file (Format -> Make Plain Text). Type the following line ... Viva [tab] el [tab] Che then save the file as Che.txt.

To open Che.txt in OS9 and read the results into a list (array), we can do the following:
tell application "Finder"
set workingFileRef to file "Che.txt" of startup disk
set workingFile to (open for access workingFileRef)
set theContents to read workingFile using delimiter {ASCII character 9} as list before {ASCII character 13}
display dialog theContents as string
close access workingFile
end tell
Beautiful! Trying the same lovely script in OSX, however, we see that it fails. The error message is: "Can't make file into a class <<fsrf>>"

Change the following lines and save yourself some pain:
  set workingFileRef to "Mac OS X HD:Users:barrager:Documents:Che.txt" as text
set workingFile to (open for access file workingFileRef)
I suspect that what is going on here is that OS9 AppleScript was more forgiving that OSX AppleScript. Running the OSX AppleScript listed here in OS9 works fine!
    •    
  • Currently 0.00 / 5
  • 1
  • 2
  • 3
  • 4
  • 5
  (0 votes cast)
 
[4,820 views]  

AppleScript OS 9 to OS X - Read Write File | 2 comments | Create New Account
Click here to return to the 'AppleScript OS 9 to OS X - Read Write File' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
transition is a noun; not a verb
Authored by: baba on Nov 14, '01 11:22:22PM

Sorry, but I just had to saying that. ;}



[ Reply to This | # ]
transition is a noun; not a verb
Authored by: Paul Burney on Nov 15, '01 12:36:53PM

Sorry about the off topic post, but....

According to the American Heritage Dictionary, (see reference), it is also an intransitive verb. According to the same source, an intransitive verb is one that doesn't take a direct object (see reference). So I suppose the usage is correct by current american standards.

If that's incorrect, please note that I'm a programmer, not a linguist.



[ Reply to This | # ]