Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!swrinde!mips!apple!claris!UUCP!peirce From: peirce@outpost.UUCP (Michael Peirce) Newsgroups: comp.sys.mac.programmer Subject: Re: writing a text file Message-ID: <0B010004.dliboeb@outpost.UUCP> Date: 25 Apr 91 02:41:40 GMT Reply-To: peirce@outpost.UUCP (Michael Peirce) Organization: Peirce Software Lines: 40 X-Mailer: uAccess - Mac Release: 1.1.b1 In article <1991Apr24.074449.1148@uokmax.ecn.uoknor.edu>, kpmiller@uokmax.ecn.uoknor.edu (Kent P Miller) writes: > > Ok. Here's another one of my patented Stupid Questions (tm). > > I need to pump a few lines of text to a file. So, I'm looking through IM and > it says > FSWrite(refNum:integer; var count:longint; buffPtr:Ptr):OSErr; > > I wouldn't know a buffPtr if it bit me on the butt. What is it, and where can > I go to purchase one? A bufPtr just points to the data you want to write, the count tells it how many bytes to find at that address. For example (off the top of my head): PROCEDURE WriteAString(refNum : integer; theString : str255); VAR howMuch : longint; dataPtr : Ptr; BEGIN howMuch := LENGTH(theString); dataPtr := Ptr(LONGINT(@theString)+1); IF FSWrite(refNum,howMuch,dataPtr) <> noErr THEN ReportError; END; Notice that you have to point one beyond the string's address to skip over the pascal length byte. Also, count is a VAR parameter because it returns the number of bytes that were actually written to the file. You also might want to send CR's out after each string... -- michael -- Michael Peirce -- outpost!peirce@claris.com -- Peirce Software -- Suite 301, 719 Hibiscus Place -- Macintosh Programming -- San Jose, California 95117 -- & Consulting -- (408) 244-6554, AppleLink: PEIRCE