Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!rutgers!mcnc!beguine!Eliot.Henry From: Eliot.Henry@samba.acs.unc.edu (BBS Account) Newsgroups: comp.sys.mac.programmer Subject: simple C Problem Keywords: reading and writing to floppies Message-ID: <1268@beguine.UUCP> Date: 8 Oct 90 20:23:35 GMT Sender: usenet@beguine.UUCP Lines: 92 I have a routine I wrote in pascal that reads and writes blocks from a floppy drive. The problem is that when I converted it to C it doesn't work. Yes, strange but true. It gives an error -50 every so often then consistantly has trouble reading the next 65 or 66 sectors (there is a loop that is writing to the entire disk) This is probably an embaressingly simple problem. Any help would be greatly appreciated here is the code I have: #include #include "DiskDvr.h" main () { OSErr error; ParamBlockRec Param; int i,j,lb; long int buffersize=512; char thebuffer[512]; /* This program will format an Apple Serial Hard Drive (SC20) */ /* Initialize Some Variables */ Param.ioParam.ioPosOffset=512; Param.ioParam.ioPosMode=fsFromStart; Param.ioParam.ioPermssn=fsRdPerm; Param.ioParam.ioReqCount=buffersize; Param.ioParam.ioBuffer=thebuffer; Param.ioParam.ioRefNum=-5; Param.ioParam.ioVRefNum=1; printf ("\n"); error=PBRead(&Param,FALSE); printf ("Read Error= %d\n",error); printf ("Bytes Requested %d\n",Param.ioParam.ioReqCount); printf ("Bytes Read %d \n",Param.ioParam.ioActCount); /* Load the array with 0 bits (ascii character zero) */ for (i=1; i<=512; i++) thebuffer[i]=0; /* Write the 0 bits to the Drive */ printf ("Writing 0s....\n"); for (i=1; i<=800; i++) { Param.ioParam.ioPosOffset=i*512; error=PBWrite (&Param,FALSE); if (error!=noErr) printf ("Write Error: %d\n",error); else printf ("Wrote sector: %d\n",i); } printf ("/n"); /* Verify the 0 bits */ printf("Verifying 0s...\n"); for (i=1; i<=800; i++) { Param.ioParam.ioPosOffset=i*512; error=PBRead(&Param,FALSE); if (error!=noErr) printf ("Read Error verifying sector %d\n",i); else { for (j=1; j<=512; j++); if (thebuffer[j]!=0) printf ("Error in byte %d of sector %d\n",j,i); else printf ("."); } } printf ("\n"); } /* END of the program */ Thanks in advance! --