Article View: comp.sys.mac
Article #18793File I/O in HyperTalk
From: Dan Winkler
Date: Fri, 04 Sep 1987 08:11
Date: Fri, 04 Sep 1987 08:11
44 lines
1796 bytes
1796 bytes
Here is an example of file I/O in HyperTalk that imports and exports
text. The open file command does not use the documents search path --
it simply passes the name you gave, which could include a path, to
FSOpen. If the file does not exist, HyperTalk automatically creates it
and then opens it.
on mouseUp
-- export text
put the short name of this stack & " text" into fileName
ask "Export text to what file?" with fileName
if it is empty then exit mouseUp
put it into fileName
open file fileName
go to first card
repeat for the number of cards
repeat with i = 1 to the number of fields
write field i to file fileName
write tab to file fileName
end repeat
go to next card
end repeat
close file fileName
end mouseUp
on mouseUp
-- import text
ask "Import text from what file?"
if it is empty then exit mouseUp
put it into fileName
open file fileName
repeat
doMenu "New Card"
repeat with i = 1 to the number of fields
read from file fileName until tab
if it is empty then -- end of file
if i = 1 then doMenu "Delete Card"
close file fileName
exit mouseUp
end if
delete last char of it -- kill tab
put it into field i
end repeat
end repeat
end mouseUp
Technical Details
Message-ID:
<6145@apple.UUCP>Path:
arc1-ca.pugleaf.net!utzoo!mnetor!uunet!husc6!uwvax!rutgers!labrea!decwrl!pyramid!voder!apple!winklerShow Full Headers
Complete Article Headers
Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: arc1-ca.pugleaf.net!utzoo!mnetor!uunet!husc6!uwvax!rutgers!labrea!decwrl!pyramid!voder!apple!winkler From: winkler@apple.UUCP (Dan Winkler) Newsgroups: comp.sys.mac Subject: File I/O in HyperTalk Message-ID: <6145@apple.UUCP> Date: Fri, 4-Sep-87 04:11:15 EDT Article-I.D.: apple.6145 Posted: Fri Sep 4 04:11:15 1987 Date-Received: Sun, 6-Sep-87 06:21:42 EDT Organization: Apple Computer, Inc., Cupertino, USA Lines: 44