mm@blake.u.washington.edu (Eric Gorr) (12/11/90)
Could someone please make this work? Basically, I am creating a text file
called "Test" and attempting to write "This is a test..." to the file.
The problem with the code (at least I am 99% sure), is when I attempt to
use the Toolbox routines to make,write to, read from and print the data from
the file.
I am using THINK C (Lightspeed C)...
TestAdd ()
{
OSErr Err;
char Name[6], *DataString, *StartPtr, *TheData;
long BTW;
int RefNum;
strcpy (Name, "\pTest");
MoveTo (100,100);
DrawString (Name);
DataString = "\pThis is a test...";
MoveTo (150,150);
DrawString (DataString);
/* I am fairly sure this is where the problem code starts */
Err = Create (Name, vRefNum, 'MACA', 'TEXT');
Err = FSOpen (Name, vRefNum, RefNum);
BTW = sizeof (DataString);
StartPtr = &DataString [0];
Err = FSWrite (RefNum, BTW, StartPtr);
Err = FSClose (RefNum);
Err = FlushVol (Nil_Pointer, vRefNum);
Err = FSOpen (Name, vRefNum, RefNum);
Err = FSRead (RefNum, BTW, TheData);
Err = FSClose (RefNum);
MoveTo (180,180);
DrawString (TheData);
}
Thanx...
------------------------------------------------------------------------------
Mystery_Man ! All warfare is based on deception - Sun Tzu
! Diplomacy is the art of letting someone else have
mm@ ! your war - Danielle Vare'
blake.u.washington.edu! He who knows when he can fight and when he cannot will
! be victorious - Sun Tzu
IBM - I Bought ! Alway mystify, mislead, and surprise the enemy
Macintosh ! - Stonewall Jackson
------------------------------------------------------------------------------
Jim.Lynch@f444.n161.z1.FIDONET.ORG (Jim Lynch) (01/02/91)
> Subj: NEED HELP AGAIN... > From: mm@blake.u.washington.edu (Eric Gorr) > Date: 11 Dec 90 03:26:44 GMT > Organization: University of Washington, Seattle > Message-ID: <12752@milton.u.washington.edu> > Newsgroups: comp.sys.mac.programmer > > > Could someone please make this work? Basically, I am creating a text file > called "Test" and attempting to write "This is a test..." to the file. > The problem with the code (at least I am 99% sure), is when I attempt to > use the Toolbox routines to make,write to, read from and print the data from > the file. > > I am using THINK C (Lightspeed C)... > > TestAdd () > { > OSErr Err; > char Name[6], *DataString, *StartPtr, *TheData; > long BTW; > int RefNum; > > strcpy (Name, "\pTest"); > MoveTo (100,100); > DrawString (Name); > > DataString = "\pThis is a test..."; > MoveTo (150,150); > DrawString (DataString); > > /* I am fairly sure this is where the problem code starts */ > /******************************************************************/ /* and you can find out by looking at the values of your variable */ /* 'Err' after EACH assignment. */ /* -Jim */ /******************************************************************/ > > Err = Create (Name, vRefNum, 'MACA', 'TEXT'); > /*****************************************************************/ /* P.S: You can also do things like this: */ /*****************************************************************/ > > Err = FSOpen (Name, vRefNum, RefNum); > BTW = sizeof (DataString); > StartPtr = &DataString [0]; > Err = FSWrite (RefNum, BTW, StartPtr); > Err = FSClose (RefNum); > > Err = FlushVol (Nil_Pointer, vRefNum); > /**************************/ /* not sure where the */ /* problem is so I'll */ /* split the code in two */ /**************************/ #ifdef DONT_COMPILE > > Err = FSOpen (Name, vRefNum, RefNum); > Err = FSRead (RefNum, BTW, TheData); > Err = FSClose (RefNum); > > MoveTo (180,180); > DrawString (TheData); > #endif /******************************/ /* Now I'll run it and see if */ /* it still crashes... */ /******************************/ > } > /*****************************************************/ /* This technique is old but it works, furthermore */ /* Think C has a debugger which can be used to watch */ /* variables. Good luck! */ /*****************************************************/ > > Thanx... > > --------------------------------------------------------------------------- -- - > Mystery_Man ! All warfare is based on deception - Sun Tzu > ! Diplomacy is the art of letting someone else have > mm@ ! your war - Danielle Vare' > blake.u.washington.edu! He who knows when he can fight and when he cannot will > ! be victorious - Sun Tzu > IBM - I Bought ! Alway mystify, mislead, and surprise the enemy > Macintosh ! - Stonewall Jackson > --------------------------------------------------------------------------- -- - /*********************************************************************/ /* Jim Lynch on BMUG BBS in Berkeley, CA */ /* (415) 849-BMUG */ /* or leave a voice message at: */ /* (415) 521-7367 */ /*********************************************************************/ -- Jim Lynch - via FidoNet node 1:125/777 UUCP: ...!uunet!hoptoad!fidogate!161!444!Jim.Lynch INTERNET: Jim.Lynch@f444.n161.z1.FIDONET.ORG