Articles & Documents

Close Tutorials

To receive news about this website, consider subscribing to our Newsletter.
22 Subscribers

Friends News


   visitors online

Webmaster - Infos
forum.gifForum - ppCompiler - Topic #6

Forum - Forum
ppCompiler - ppCompiler

active  Topic # 6  saving text files

08/02/2009 @ 17:56
by simoninmarch



I seem to be having difficulty saving a text file, and was wondering if it might be a problem with my Tungsten Tx, or simply me missing something.

When I try the following code, I find that only the first word is saved to the text file:

   f : file of string;

   rewrite(f, 'myfile.txt');
   write(f, 'hello ', 'this ', 'is', 'me.');

I have also tried using

f^ := 'hello;

... and so on with 'this', 'is', 'me', but still only the first word is written to the text file. However, if I concatenate the strings, and use write(f, 'hello ' + 'this ' + 'is ' + 'me'), all of the words are written. It seems that only the first reference to a file of string is written.

I was going to try and close the file and then open and append the 2nd, 3rd and 4th words, but pp does not seem to support the append command. My second question, then, is how can I append text to a file?

Thank you.

Write to simoninmarch   Post an answer  Top
Answer n° 1
08/02/2009 @ 21:08
by Philippe


All the strings are written on the file by the program, not only the first one, but it cannot be read with a standard doc reader.
A string is a constant block of 64 characters. You can check how it is written with Bird by openning the "MiFile.txt" database.
The file can be opended for inspection (reset) and you can read all the strings that have been written in another Pascal program.
This file feature has been implemented for compatiblity with the ISO standard. If you want doc files that can be opended with doc reader, I advice to use the PalmOS API. You can have a look on the source code of Piaf for example.
Write to Philippe   Post an answer  Top
Answer n° 2
08/02/2009 @ 22:45
by simoninmarch


Thank you Philippe - that's helpful.e
Write to simoninmarch   Post an answer  Top
active topic active   closed topic closed   Sticky Sticky   New New message   -   Correct Correct message   Close Close topic   Make sticky Make sticky
Forum Topic  Forum 

^ Top ^