home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!dtix!darwin.sura.net!zaphod.mps.ohio-state.edu!mane.cgrg.ohio-state.edu!spencer
- From: spencer@cgrg.ohio-state.edu (Stephen N. Spencer)
- Newsgroups: comp.sys.mac.programmer
- Subject: Re: Help w/files needed...
- Message-ID: <1992Aug20.153053.26419@cgrg.ohio-state.edu>
- Date: 20 Aug 92 15:30:53 GMT
- References: <l-hyzaq@rpi.edu>
- Distribution: usa
- Organization: OSU Advanced Computing Center for the Arts and Design
- Lines: 40
-
- In article <l-hyzaq@rpi.edu> raffuj@aix.rpi.edu (Jose A. Raffucci) writes:
- >I need to open a file, write to it using standard text i/o stuff, and
- >close it up again. I figure fopen() and fclose() work ok since they're
- >in the standard library, but how can I use them with the standard filre
- >requestors?
- >
-
- Here is an article posted by Bill Coderre in late 1990 that does what you want:
-
- ---
- Here is a fragment of Think C that allows Think's <stdio> lib and Mac's
- Standard File dialogs to be intermixed:
-
- /* Open the input file. */
- MyTypes[0] = 'TEXT';
- SFGetFile(SFGWhere,NIL,NIL,1,MyTypes,NIL,&reply);
- if (!reply.good) return;
- SetVol(0L, reply.vRefNum);
- strcpy(inFileName,reply.fName);
- PtoCstr(inFileName);
- inp = fopen(inFileName,"r");
- if (inp == NULL)
- {
- strcpy(&sTemp,"Can't seem to open input file: ");
- strcat(&sTemp,inFileName);
- ParamText(CtoPstr(sTemp),"\p","\p","\p");
- A_Lose();
- return;
- };
-
- The function A_Lose puts up an "uh-oh" alert and effectively aborts the
- program. Primitive but functional errorchecking.
-
- I got this idea and almost all the code itself by calling Think C's tech
- support people. Thanks guys.
- ---
- --
- Stephen N. Spencer, Graphics Research Specialist ,__o ,__o
- spencer@cgrg.ohio-state.edu (or spencer@siggraph.org) _-\_<, _-\_<,
- (614) 292-3416 (*)/'(*) (*)/'(*)
-