string data format and other questions

Discuss PocketC for Palm OS (including Desktop Edition)

string data format and other questions

Postby mrstandridge on Mon Oct 22, 2007 6:00 am

Hello, I'm very new to pocketc and have a few questions. The example network.pc uses the expression "sockrecv(s, &index, "s", 1);" to download an entire text file into a string. While the documentation states that sockrecv uses the same format as dbwritex, there is only a mention of "sz" and "s#" in the documentation for dbwritex. I tried using "s" in fileread but no data is being entered into the string and fileread returns 0. fileread should return the quantity of data read, right? Does fileread support "s"? How should I go about reading a text file, into a char array? I would also like to download arbitrary data like jpg or zip and write to a file. Should I just pass sockrecv a pointer to a fileid if I'm only using HTTP/1.0 and don't have to worry about chunked data?
mrstandridge
 
Posts: 2
Joined: Mon Oct 22, 2007 5:40 am

Re: string data format and other questions

Postby dewey on Wed Oct 24, 2007 4:19 pm

The single "s" is shorthand for "sz". fileread does support "s". There was a bug in fileread (or the OrbC equivalent File.read) long ago that would cause something similar to this. I'll have to test this to see if it is still broken. Also, the max size of a string that can be read from a file is 512 bytes. This limit does not exist for sockets, which is limited only by available memory.

You can't pass a fileid to sockrecv, since it doesn't support writing to files directly. You will need to download into a buffer (char[]) and then write that data to the file.
dewey
Site Admin
 
Posts: 749
Joined: Sun Oct 21, 2007 5:12 am

Re: string data format and other questions

Postby dewey on Thu Oct 25, 2007 4:05 am

Yes, this was a bug in File.read that was fixed long ago. However, the same flaw was not fixed in fileread. However, while investigating this, I found another bug which affects both File.read (OrbC) and fileread (legacy PocketC). I will spin up a new build in the next few days with a fix.
dewey
Site Admin
 
Posts: 749
Joined: Sun Oct 21, 2007 5:12 am

Re: string data format and other questions

Postby mrstandridge on Sat Oct 27, 2007 4:26 am

Thanks a bunch for the informative reply!
mrstandridge
 
Posts: 2
Joined: Mon Oct 22, 2007 5:40 am


Return to PocketC for Palm OS

Who is online

Users browsing this forum: No registered users and 6 guests

cron