Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!sun-barr!olivea!samsung!uakari.primate.wisc.edu!sdd.hp.com!mips!wrdis01!nstn.ns.ca!clyde.concordia.ca!altitude!matrox!uvm-gen!kira!nic!news.cs.brandeis.edu!news!phils From: phils@chaos.cs.brandeis.edu (Phil Shapiro) Newsgroups: comp.sys.mac.programmer Subject: Re: Numbers from TEXT files under Think C ? Message-ID: Date: 26 Apr 91 03:04:33 GMT References: <17150002@hpihoah.cup.hp.com> <4978@cernvax.cern.ch> Sender: usenet@news.cs.brandeis.edu Organization: Symantec Corp. Lines: 39 In-Reply-To: marty@cernvax.cern.ch's message of 22 Apr 91 08:33:47 GMT In article <4978@cernvax.cern.ch> marty@cernvax.cern.ch (hugues marty) writes: In article <17150002@hpihoah.cup.hp.com> cring@hpihoah.cup.hp.com (Craig Ring) writes: >I would like to be able to use SFGetFile() to allow the user to pick the >file they would like to open, but the SFReply doesn't seem to be very useful >to the ANSI C libraries for Think C. One way is to call SFGetFile(), then geting the whole path name for the selected file (for example "HD:folder 1:document") and passing this string to the fopen() function which will return a FILE *. Yikes. How about: #include #include #include #include main() { SFReply reply; FILE *infile; chide(stdout); /* let console library initialize mac toolbox */ SFGetFile(0x00300040, "", 0L, -1, 0L, 0L, &reply); if (reply.good) { /* user didn't press cancel... */ SetVol(0L, reply.vRefNum); /* use vRefNum/wdRefNum in reply */ infile = fopen(PtoCstr((char *)reply.fName), "r"); /* ... */ } } An even easier way would be to use ccommand(), which displays a dialog that you can use to redirect input at runtime. -phil -- Phil Shapiro Technical Support Analyst Language Products Group Symantec Corporation Internet: phils@chaos.cs.brandeis.edu