home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #18 / NN_1992_18.iso / spool / comp / sys / mac / programm / 14274 < prev    next >
Encoding:
Internet Message Format  |  1992-08-20  |  1.8 KB

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