Page 1 of 1

PostPosted: Thu Feb 13, 2003 6:47 am
by Red_as_blood
Here is my question:

In Pocket C can i use a string to call a function?


on a text file i have these lines:


I made a function that reads a text file but i cant figure out how to use the lines i wrote on to it.

My idea is that it reads a single line of text and put it in a string variable so after it execute the line readed as a normal function.

Is this possible????????

PostPosted: Thu Feb 13, 2003 9:35 am
by MaxS
You can't do it directly..
You need a function that parse your string
and operates consequently.. something like
a virtual machine (as pocketC shell does).

An alternative may be a program that opens
your file (containing your functions) and then
pass it to pocketC editor with the build option
(but I don't remember parameters...Guy?).
In this case your file must contain a complete
pocketC program...

It don't seems useful...

Hope this help

PostPosted: Thu Feb 13, 2003 10:20 am
by Red_as_blood
It seems to be complicated....

Maybe i didn't explane my self...

So, i am making a little program to draw lines circles, text and other things on the screen (like a little CAD program), my problem is how do i save the drawing i made?
I could save the screen area with CaptureBmp() function, so after, i have an image, but i don't like this way...

My idea was to save all the figures i draw on the screen o a file, under commands so when i re open the file my program reads all the commands and re draw all the stuff on the screen.

Some thing like this:

cir,100,100,30 //circle,x,y,radius
lin,10,10,50,50 //line,x1,y1,x2,y2
txt,"Hello",60,60 //text,string,x,y

The program should read (for example) cir and then read the other coordinates and draw the component on the screen the same if the reads <lin> or <txt>.

There MUST be a way!!!!

Some body help me!!!!

PostPosted: Thu Feb 13, 2003 10:52 am
by MaxS
the first of my options is the way...

when you draw one of your circles, lines etc
at the same time you can create a string
containing the code that identifies the
drawing function (i.e. "cir" for circles,
"rect" for rectangles and so on)followed by
parameters (coordinates or text string).
Once you have finished append the string
to your text file.

On redrawing you can scan your text file:
when you find one of your drawing codes
read parameters and call the equivalent
pocketC draw function.
An idea can be a switch/case statement

string mydrwfunction;
int x1, x2, y1, y2, radius;
string text;


//here scan your text file

switch (mydrwfunction){
//do the work



your text file should be something similar:

cir,100,100,30,lin,10,10,50,50....and so on

This way can be very complicated if you want to modify
elements in your drawing like ACad does...:twisted:

In this case you must think in a "object way"...:x
..and databases are the choice...

but this is another story;)


PostPosted: Thu Feb 13, 2003 12:51 pm
by Mickle
It idea is used in Windows Metafile format.
If you want to modify elements then IMHO best solution - tag-based file structure.
Read TIFF documentation (look on Adobe web site) for gets some ideas about it.
For example your tag can be:
WORD tag - code of operation (for example: 0x1 - circle(), 0x2 - line()....)
WORD number of arguments
DWORD offset of array of arguments
DWORD offset of next tag
Arguments array:
arg. 1
WORD type (for example 1 - DWORD, 2 - ASCII string, 3 - UNICODE string,....)
WORD length (in bytes)
data bits
arg. 2
arg. 3

PostPosted: Fri Feb 14, 2003 8:50 am
by Red_as_blood
Windows MetaFile? really i dont know what it is....

but for the moment i will use the select case example you made

Another question....

The pocketpc screen is little, so a drawing could be bigger that is resolution...

How do i must use the scrollbars to have a larger drawing area???

You must redraw the screen and struff like that right?

PostPosted: Fri Feb 14, 2003 2:30 pm
by Mickle
If you not use CEAPI library:
1. You must emulate scrollbars (you can't use real scrollbar without CEAPI)
Try to use two "button" + two "static". Or you can create images (*.bmp 8 pictures....) and draw it.
2. Redraw the screen when user click your "scrollbar".
If you use CEAPI:
too many variants of possible rendering...