Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472
[phpBB Debug] PHP Notice: in file /includes/functions.php on line 3368: Cannot modify header information - headers already sent by (output started at /includes/bbcode.php:472)
[phpBB Debug] PHP Notice: in file /includes/functions.php on line 3370: Cannot modify header information - headers already sent by (output started at /includes/bbcode.php:472)
[phpBB Debug] PHP Notice: in file /includes/functions.php on line 3371: Cannot modify header information - headers already sent by (output started at /includes/bbcode.php:472)
[phpBB Debug] PHP Notice: in file /includes/functions.php on line 3372: Cannot modify header information - headers already sent by (output started at /includes/bbcode.php:472)
OrbWorks Community Forum • View topic - filewrite returns good value but will not write

filewrite returns good value but will not write

Discuss PocketC for CE (including Desktop Edition)

Postby Lauren on Wed Jan 30, 2002 11:53 am

Using the latest version of PocketC directly on the PocketPC, I am working on the following code which is supposed to write string data to an ascii file. The return values for fileopen() and filewrite() show that the functions worked but
really they don't. A file is being created in the indicated directory but the size in bytes in always zero. I've tried lots of things including setting the file size with filesetlen, using another directory, etc., nothing will. The last alert statement below
shows the following values after execution:

8 : 8 : 0 : -1 : /My Documents/PocketA.txt

in order;
dataHandle: 8 (or whatever lenght for the string - this is the filewrite() return value)

savedData: 8 (or whatever is the actual lenght of the data to write - always matches the above)

fileMode: 0 (indicates an ascci file)

fileLength: -1 (the created file is always empty and has 0 byte)

filePath: /My Documents/PocketA.txt


Spent hours trying to figure this out. If anyone can help me that would be great. Thanks. Lauren




C_Button_Click() {

int fileLength;
string fileHandle;
string filePath;
string savedData;
string dataHandle;
string fileMode;

if (cbxget(CTL_B1_SELECTED) == TRUE){

filePath = "/My Documents/PocketA.txt";
savedData = editget(CTL_QUESTION);
fileHandle = fileopen(filePath,0,FILE_CREATE | FILE_WRITE);
dataHandle = filewrite(filePath,savedData,strlen(savedData));
fileMode = filemodeget(filePath);

filesetlen(filePath,dataHandle);
fileLength = filegetlen(filePath);

?Ǭ†if?Ǭ†(fileHandle == -1)?Ǭ†{
?Ǭ† ?Ǭ†alert("Could?Ǭ†not?Ǭ†open: " + filePath);
?Ǭ†}

?Ǭ†if?Ǭ†(dataHandle == -1)?Ǭ†{
?Ǭ† ?Ǭ†alert("Could?Ǭ†not?Ǭ†write: " + savedData);
?Ǭ†}
else {
alert(dataHandle + " : " + strlen(savedData) + " : " + fileMode + " : " + fileLength + " : " + filePath);
}

fileclose(filePath);

}
}
Lauren
 
Posts: 7
Joined: Wed Jan 30, 2002 11:11 am

Postby mister_zed on Wed Jul 10, 2002 1:34 pm

Have you tried to open the file BOTH for read and write at the same time?
mister_zed
 
Posts: 3
Joined: Tue Jul 09, 2002 5:06 pm

Postby wolfgang on Wed Jul 10, 2002 2:59 pm

Try to close the file before accessing it with filegetlen. As long as it is not closed, data might be cached or the file properties not updated. Closing it should do the trick. I modified your code accordingly (below).

Wolfgang


C_Button_Click() {

int fileLength;
string fileHandle;
string filePath;
string savedData;
string dataHandle;
string fileMode;

if (cbxget(CTL_B1_SELECTED) == TRUE){

filePath = "/My Documents/PocketA.txt";
savedData = editget(CTL_QUESTION);
fileHandle = fileopen(filePath,0,FILE_CREATE | FILE_WRITE);
if (fileHandle == -1) {
alert("Could not open: " + filePath);
}

dataHandle = filewrite(filePath,savedData,strlen(savedData));
fileclose(filePath);

fileMode = filemodeget(filePath);
fileLength = filegetlen(filePath);

alert(dataHandle + " : " + strlen(savedData) + " : " + fileMode + " : " + fileLength + " : " + filePath);

}
}


Composing music on the PocketPC! - http://www.pdamusician.com
Composing music on the PocketPC! - http://www.pdamusician.com
wolfgang
 
Posts: 281
Joined: Tue Dec 12, 2000 4:22 am
Location: USA


Return to PocketC for CE

Who is online

Users browsing this forum: No registered users and 1 guest

cron