[EMAIL PROTECTED] wrote:
I am new to Palm programming, how can I place a Text file in the Palm and
read it through my application ? I am trying to make an applicaiton which
could read simple documents ( text files) on the palm.
As someone else said, text files aren't really in the Palm idiom. If
the goal is to create something that works with text files that exist
independently of the Palm, then it's worth pursuing. But if the text
file is only to exist on the Palm, it would be better to use database
records instead of a text file.
Anyway, if you determine that a text file does make sense, then you have
a choice. In the early days, there were no SD Cards, and the only way
to have a file was to encapsulate it in a database. This is called a
FileStream. To the user, it looks like any other PDB, but it has a
structure where you can use FileOpen(), FileRead(), etc. to read and
write it on the Palm. This method will be compatible with all but the
very oldest Palm devices. (I think File Streams were introduced in
version 2.0 or something.)
The other method, now that there are SD Cards, is to assume that the
user does in fact actually own an SD Card, and force them to put the
file on that card. Then you can use VFSFileOpen(), VFSFileRead(),
etc. to read and write it. VFS files have names a bit more like
what you're used to, in that they're in a hierarchical namespace
and all that. (File Streams are in a flat namespace, because they
are really just databases.)
The thing to be aware of with all this is that there is no built-in
set of buffered file I/O routines (like stdio) on the Palm. That means
that if you want routines to, say, read a line from the text file, you
will have to supply them[1]. When I added a feature to one of my apps
to spit out a text file (HTML, actually) summarizing data the user had
entered into the application, I basically ended up writing my own
equivalents of fopen(), fclose(), fputs(), fputc(), putw(), fflush(),
etc. It worked fine and was, surprisingly, not all that painful, but
it did take time...
- Logan
[1] There is such a thing as a Standard IO Application on the
Palm, but changes the entire structure of the app as I
understand it, so you can't just add this on to your
existing app if you need to add the ability to read and
write text files.
--
For information on using the PalmSource Developer Forums, or to unsubscribe,
please see http://www.palmos.com/dev/support/forums/