Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472
[phpBB Debug] PHP Notice: in file /includes/functions.php on line 3368: Cannot modify header information - headers already sent by (output started at /includes/bbcode.php:472)
[phpBB Debug] PHP Notice: in file /includes/functions.php on line 3370: Cannot modify header information - headers already sent by (output started at /includes/bbcode.php:472)
[phpBB Debug] PHP Notice: in file /includes/functions.php on line 3371: Cannot modify header information - headers already sent by (output started at /includes/bbcode.php:472)
[phpBB Debug] PHP Notice: in file /includes/functions.php on line 3372: Cannot modify header information - headers already sent by (output started at /includes/bbcode.php:472)
OrbWorks Community Forum • View topic - strings as functions

strings as functions

Discuss PocketC for CE (including Desktop Edition)

Postby Red_as_blood on Thu Feb 13, 2003 6:47 am

Here is my question:

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

Example

on a text file i have these lines:


circle(50,50,20);
line(10,10,20,20);
rect(30,30,60,60);

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????????
Red_as_blood
 
Posts: 13
Joined: Sat Aug 10, 2002 2:06 pm

Postby MaxS on Thu Feb 13, 2003 9:35 am

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
ciao
max
MaxS
 
Posts: 10
Joined: Thu Jan 30, 2003 10:39 am

Postby Red_as_blood on Thu Feb 13, 2003 10:20 am

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!!!!
Red_as_blood
 
Posts: 13
Joined: Sat Aug 10, 2002 2:06 pm

Postby MaxS on Thu Feb 13, 2003 10:52 am

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
i.e.:


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

...

//here scan your text file

switch (mydrwfunction){
case("cir")
//do the work

case("rect")

....
}

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;)

ciao
max
MaxS
 
Posts: 10
Joined: Thu Jan 30, 2003 10:39 am

Postby Mickle on Thu Feb 13, 2003 12:51 pm

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
..........
..........
Mickle
 
Posts: 48
Joined: Wed Apr 17, 2002 1:22 am
Location: Russia

Postby Red_as_blood on Fri Feb 14, 2003 8:50 am

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?
Red_as_blood
 
Posts: 13
Joined: Sat Aug 10, 2002 2:06 pm

Postby Mickle on Fri Feb 14, 2003 2:30 pm

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...
Mickle
 
Posts: 48
Joined: Wed Apr 17, 2002 1:22 am
Location: Russia


Return to PocketC for CE

Who is online

Users browsing this forum: No registered users and 3 guests

cron