Hi Guys,
I am writing an appliation where I am creating a file, writing some text
into it and then reading it.
As far as I see it, the file gets created and none of the functions are
returning or throwing any error but some how I am not able to read/write
to the file.
Following is the code,
UInt16 cardNo = 0;
const Char *nameP= "myfile" ;
UInt32 type =0;
UInt32 crtor = 0;
UInt32 openMode = fileModeReadWrite | fileModeAnyTypeCreator;
Err *errP = errNone;
FileHand fileH;
Int32 Objcts = 0;
const void *dataP = "Hi Keyur";
// Create and open a file
fileH = FileOpen(cardNo, nameP, type,crtor,openMode, errP);
if (fileH && errP==errNone)
FrmCustomAlert(ErrorAlert,"File Opened", NULL, NULL);
// this gets printed
else
FrmCustomAlert(ErrorAlert,"File Open Problem", NULL,
NULL);
// Write to the opened file
errP = errNone;
Objcts = FileWrite(fileH,dataP,50,50,errP);
Char *p,*q =(Char*) MemPtrNew(sizeof(Int32));
p = StrIToA(q,Objcts);
if ((errP == errNone))
FrmCustomAlert(ErrorAlert,p, NULL, NULL); // This
prints 50
else
FrmCustomAlert(ErrorAlert,"File Write Problem", NULL,
NULL);
// Read from the same file
errP = errNone;
Char *bufP = (Char*) MemPtrNew(50*(sizeof(Char)));
bufP = "Bye Keyur";
Char *x,*y =(Char*) MemPtrNew(sizeof(Int32));
x = StrIToA(y,Objcts);
Objcts = FileRead(fileH ,bufP,50,50,errP); // This prints 50
if ((errP == errNone))
FrmCustomAlert(ErrorAlert,x, NULL, NULL);
else
FrmCustomAlert(ErrorAlert,"File Read Problem", NULL,
NULL);
FrmCustomAlert(ErrorAlert,bufP, NULL, NULL); // This prints
"Bye Keyur"
// End of File Handling here
Can anybody please tell me where I am making mistake!
Pleae help........
Keyur Patwa
--
For information on using the Palm Developer Forums, or to unsubscribe, please see
http://www.palmos.com/dev/support/forums/