Page 1 of 1

PostPosted: Sat Feb 01, 2003 8:47 pm
by Giancarlo Italy
unfortunately I am not a good programmer. I have read the function library of pocketC and I tried to write strings in a file and it was quite easy to do it. The nightmare for me was to read information from the file created...[:p]

Do someone in this forum have small some examples of files creation, writing and reading?

Any help appreciated,

bye Giancarlo (Italy)


PostPosted: Sun Feb 02, 2003 7:43 am
by wolfgang
The following works with ASCII files (small changes required for Unicode if you need that). There is one or more other threads where Guy (Sprackland) has posted much more advanced code, the code below is very basic and thus not extremely fast.


// opening a file for writing in ASCII mode
// then constant are declared in pcheader.h

#include "/PocketC/pcheader.h"
int i_fh;
i_fh = fileopen ("my_file.txt", 0, FILE_CREATE | FILE_WRITE);

// opening a file for reading in ASCII mode
int i_fh;
i_fh = fileopen ("my_file.txt", 0, FILE_READ);

// write a string to a file, terminate it with a newline
filewrite_nl (int i_fh, string s_string)
return (filewrite (i_fh, s_string + "\n", strlen (s_string) + 1));

// read an single line of text (terminated by a newline)
fileread_nl (int i_fh)
int i;
char c;
string s;

i = 0;

while (((c = readbyte (i_fh)) != '\n') && (i++ < 1000))
s = s + c;

return (s);

Composing music on the PocketPC! -

PostPosted: Sun Feb 02, 2003 1:49 pm
by Giancarlo Italy
Hello Wolfgang,
your example is very clear. Do you know where I can find more examples on using PocketC? I surfed in the ORbworks links but it seems that most of them do not exist any more...

Thank you very much for your help,

bye Giancarlo


PostPosted: Sun Feb 02, 2003 11:09 pm
by KOU
Unfortunatly, I dont know any other sites talking about PocketC.

Reading past posts in this and general boards helped for me.
(Knowledge base too.)
Many ANSI C examples work with little modification.

If you are going to use CEAPI made by guy, regular books about Windows API should help you.


PostPosted: Tue Feb 04, 2003 5:46 am
by wolfgang
Hi Giancarlo,

I have a beginner's tutorial on my website ( - go to the Programming section, it's the ABC = Absolute Beginner's Corner). It covers the basics; unfortunately I never found the time for planned "advanced stuff" like GUI, files, graphics, or databases.

On the bottom of the main page of my site you find links to the PocketC webring - have a look, some of the sites in the ring have (had?) very useful information.



Composing music on the PocketPC! -

PostPosted: Tue Feb 04, 2003 11:34 am
by Giancarlo Italy
Hello Wolfgang and Kou,
thank you for the information provided. I started from the docs in the pdamisucian site (without it I couldn't even start) and I found it very useful. I always carry it with my 720.

I also checked the old forum messages and I found previous questions and answers related to file read and write.

I'll 'study' these pieces of code next weekend,

bye Giancarlo


PostPosted: Sun Jun 22, 2003 11:27 pm
by Marty
Your suggestion on how to program as Giancarlo requested is appreciated by me as well.
I would appreciate any help also on how to get rid of quotation
marks as well.