Try rewinding the file?

> -----Original Message-----
> From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]]
> Sent: Thursday, August 05, 1999 5:21 PM
> To: [EMAIL PROTECTED]
> Subject: File Reading & Writing
> 
> 
> I am pulling information from data entry screens and 
> attempting to save them 
> to a file.   The File Open (ReadWrite mode),  File Write, and 
> File close 
> appears to be working correctly (returning a file handle and 
> error code ptr 
> is returning NULL).   I then open the file (Read only mode) 
> and read, but the 
> no# of objects returned is 0 and my buffer is empty.   I 
> enclosed the code - 
> another set of more experienced eyes would be greatly appreciated:
> **************************************************************
> ****************
> ***************
>   FileHand fh;
>   DWord openMode;
>   SWord sResult;
>   Long myRtn; 
>   VoidPtr bufP;
>  
>   Err *errP =0;
>   CharPtr pData;
> 
>   fh = FileOpen (0, "newfile", sysFileTFileStream, 0, openMode, errP);
>   if (fh == NULL) 
>   { 
>     PalmMessageBox (DebugAlertAlert, "Error creating file");
>     return;
>   }     
> 
>   myRtn = FileWrite(fh, "Test Data String" , 16, 1, errP);
>   if (errP != NULL) 
>   {
>          PalmMessageBox(DebugAlertAlert, "Error writing to file");
>          return;
>   }
>     
>   FileClose(fh);
> 
>       
> //
> // Debug Purposes:  Open file and read record to see if file 
> was created
> //                  correctly.
> //
>   openMode = fileModeReadOnly;
> 
>   if ((fh = FileOpen (0, "newfile", sysFileTFileStream, 0, 
> openMode, errP)) 
> == NULL) 
>   { 
>       PalmMessageBox (DebugAlertAlert, "Error opening file 
> for ReadOnly");
>       return;
>   }     
> 
>   
>   myRtn = FileRead(fh, &bufP,16,1, errP);
> 
>   SetFieldText(fldID, bufP, 17, false);
>  
>   FileClose(fh);
> 

Reply via email to