RE: Appleworks - resolved
RE: Appleworks - resolved
- Subject: RE: Appleworks - resolved
- From: "Ruby Madraswala" <email@hidden>
- Date: Thu, 21 Oct 2004 12:39:57 -0400
- Thread-topic: Appleworks.
Thanks Malcolm.
This works. I have tried on several files and have worked without any problems. I will incorporate this in my scripts as a handler.
Property hotfolder : "Macintosh HD:ruby:"
Set openname to hotfolder & "test.cwk"
Set newname to hotfolder & "test"
tell application "AppleWorks 6"
open file openname as document type text document
tell document 1
copy it's text to s
close it saving no
end tell
end tell
try
set outfile to open for access file newname with write permission
on error
some message
end try
write s to outfile
close access outfile.
(s is saved ad text Edit file)
Ruby
-----Original Message-----
From: applescript-users-bounces+rubym=email@hidden [mailto:applescript-users-bounces+rubym=email@hidden] On Behalf Of Malcolm Fitzgerald
Sent: Wednesday, October 20, 2004 11:00 PM
To: email@hidden
Subject: Re: Appleworks.
> This from Bruce Robertson - dated 19/10/04 9·21 pm:
>
>
>>Hm, what is the point of this? If it's still a text document it's still a
>>text document. You could just change the creator code if that's all you want
>>to do.
>
>
> ... and this from Malcolm Fitzgerald - dated 20/10/04 1·01 am:
>
>
>>However, if you are saving as text you hardly need to bother with
>>Appleworks. You may use standard additions to read and write text files.
>
Mr Tea wrote:
> Well now, if Ruby needs to use Appleworks, then let it be. I know it's not
> very fashionable at the moment, but it's been around (and scriptable) for a
> long time.... :-)
I regard the suggestions of both Bruce and I as analogous to "Don't put
commands within a tell block unless it is necessary". You may get good
results from AppleWorks but is unreliable in my experience.
In this example I use AppleWorks and standard additions to complete a
task quickly and cleanly. It generates a simple file of text. It is 410
characters long.
-------- example one
tell application "AppleWorks 6"
tell document 1
copy it's text to s -- use this shortly
copy it's name to docName
close it saving no
end tell
end tell
set docPath to path to documents folder from user domain as Unicode text
set fileName to docPath & docName & ".txt"
set fileRef to (open for access file fileName with write permission)
write s to fileRef
close access fileRef
----------
In this example I use AppleWorks to generate the text file and
AppleWorks. On the first attempt it crashed. I ended up with an empty
file in my documents folder. On the second attempt it succeeded.
However, it is not a simple file containing the text of the document. It
is an AppleWorks file saved in text format. Opening it in Text Edit
reveals a huge amount of junk, including an extensive pList. It is 22904
characters long.
It really depends on what Ruby wants the file for. When opened by
AppleWorks it is not visible. The crash does undermine my confidence.
-------- example two
tell application "AppleWorks 6"
tell document 1
copy it's name to docName
end tell
end tell
set docPath to path to documents folder from user domain as Unicode text
set fileName to docPath & docName & ".txt"
tell application "AppleWorks 6"
tell document 1
save it in alias filename as file type TEXT
close it saving no
end tell
end tell
--------
--
Malcolm Fitzgerald phone: 02 9318 0877
Database Manager fax: 02 9318 0530
The Australian Society of Authors <http://www.asauthors.org>
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Applescript-users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Applescript-users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden