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

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

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

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

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

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

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 112
[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 - Draw Object Paradigm

Draw Object Paradigm

Discuss OrbForms Designer and PocketC Architect

Postby MN OrbUser on Sat Feb 18, 2006 3:01 pm

I am having some trouble understanding the draw object paradigm. I am writing a program to draw a fractal.

This involves a recursive function (i.e., it calls itself) which starts at say Level = 3; on successive calls reduces the Level by 1; when Level = 0 it calls another function update() which draws line segment (or should if I get it to work) and then starts over again to get ready to draw the next line segment.

The program uses two popup lists, to let the user set some parameters, and a "Go" button to start the recursive calculation.

I have created a Draw object named Fractal (in program file Fractal3D.oc) and attached it to mainForm in mainForm.onopen() (in program file mainform.oc). In update() I have the following code:

Fractal.begin;
Fractal.line(clrFG, xa, ya, xb, yb); // try to draw the line
Fractal.end;

It compiles, but when I launch the app and tap the Go button I get the following error message:

"Func:update Attempt to draw without calling 'begin/nbegin'".

If I comment out the Fractal.line() code it runs. Also, if I put in a counter to show that the recursion is working and put the text to the screen, it increments - which shows the other code is working.

Any thoughts on where I should be putting the draw statement?
MN OrbUser
 
Posts: 12
Joined: Wed Feb 01, 2006 4:52 pm
Location: USA

Postby tthkbw on Sat Feb 18, 2006 3:52 pm

Well, don't ask me why, but to fix this, you must use the following:

Fractal.begin();
Fractal.line(whatever);
Fractal.end();

Your code doesn't have the ()'s after "begin" and "end". I tried removing these in my code, and although OrbForms doesn't give a compile error, nothing draws.

Seems like a compile error should occur.



Terry Brown
http://www.stickmansoftware.com
tthkbw
 
Posts: 75
Joined: Wed Nov 07, 2001 4:04 pm
Location: USA

Postby nmc on Sat Feb 18, 2006 9:41 pm

"Fractal.begin" is a pointer to that function, while "Fractal.begin()" is a call to that function - at least this is true in C (I actually dont know if orbforms lets you get the pointer to a build in function)
nmc
 
Posts: 197
Joined: Tue May 27, 2003 8:42 pm
Location: Germany

Postby MN OrbUser on Sun Feb 19, 2006 11:04 am

Thanks, I used tthkbw's suggestion and it worked. I also appreciate nmc's insight as to the distinction between Fractal.begin and Fractal.begin().

I had tried a number of things in trying to get the draw to work, and then got sloppy when I saw that the compiler didn't bark when I left the () off.

I know why you want to call a function, but what would be a useful reason to use a pointer to a function? What does a pointer to a function do?
MN OrbUser
 
Posts: 12
Joined: Wed Feb 01, 2006 4:52 pm
Location: USA

Postby nmc on Sun Feb 19, 2006 8:17 pm

> but what would be a useful reason to use a
> pointer to a function? What does a pointer
> to a function do?
Think about changing the behavior of yout app by exchanging a helper function;
instead of using "if (option) doThis(); else doThat();" a hundert time, you could use "(*doIt)() at those places and assign "doIt = doThis;" once.
Function pointers are also very helpfull when needing callback functions; think about implementing a sort function for any type of structs - you will need a comparison function for this (a different one for every struct).
nmc
 
Posts: 197
Joined: Tue May 27, 2003 8:42 pm
Location: Germany

Postby dewey on Tue Feb 21, 2006 3:35 am

To answer nmc's question, yes you can take the address of a builtin function. The compiler generates a wrapper function which calls the builtin, and returns a pointer to the wrapper. The same mechanism allows you to create native objects with virtual methods.
dewey
Site Admin
 
Posts: 749
Joined: Sun Oct 21, 2007 5:12 am


Return to OrbForms Designer and PocketC Architect

Who is online

Users browsing this forum: No registered users and 1 guest