Jump to content

Welcome to eMastercam

Register now to participate in the forums, access the download area, buy Mastercam training materials, post processors and more. This message will be removed once you have signed in.

Use your display name or email address to sign in:

C-Hook Callback Function Usage


MCHulk
 Share

Recommended Posts

I've compiled the example 1 of chapter24 "CBACKS" with the ch_repaint_function():

code:

extern boolean CH_ENTRY ch_repaint_on=FALSE;

extern void CH_ENTRY ch_repaint_function(void)

{

p_3d pointToDraw;

pointToDraw[0]=pointToDraw[1]=pointToDraw[2]= 0.0;

draw_3d_point(pointToDraw, YELLOW);

}

It compiled without errors, but it didn't work.

I think MC doesn't recognize the ch_repaint_function as the callback-function.

What's wrong?

Please help.

 

Thanks in advance,

MCHulk

 

[ 12-26-2002, 07:39 AM: Message edited by: MCHulk ]

Link to comment
Share on other sites

MCHulk,

 

try setting

extern boolean CH_ENTRY ch_repaint_on=FALSE;

to

extern boolean CH_ENTRY ch_repaint_on=TRUE;

 

I think the FALSE maybe a typo.

 

Or it's iniatialized in the off position, so to speak, and you turn in on (TRUE) OR off (FALSE) in your program as needed.

 

I hope that works.

 

Bryan smile.gif

Link to comment
Share on other sites

MCHulk,

 

Yep have one more;

 

The chook is probably exiting before the call back can be called. Say that ten times fast. smile.gif

 

The following is modification of the dummy yourfile.c in the sdk. I added the include for m_gragh.h for the draw_3d_point but you probably alread have that. Added the callback with the TRUE. The clear text and wait for functions are only there to keep the chook 'active'. Compile, run, and repaint. You should now see a yellow point in the center of the screen. Hitting enter or clicking the screen will return the waitforspace function and exit the chook. Repaint again and the dot disapears.

 

Bryan smile.gif

 

code:

 /* yourfile.c */

 

#include <stdlib.h>

#include <stdio.h>

#include "m_vars.h"

#include "m_ncvars.h"

#include "m_menu.h"

#include "m_io.h"

#include "m_dbm.h"

#include "m_init.h"

 

#include "m_graph.h" // C-Hook header: graphics functions

 

 

extern boolean CH_ENTRY ch_repaint_on=TRUE;

extern void CH_ENTRY ch_repaint_function(void)

{

p_3d pointToDraw;

pointToDraw[0]=pointToDraw[1]=pointToDraw[2]= 0.0;

draw_3d_point(pointToDraw, YELLOW);

}

 

/* replace this with your function */

void your_function(void)

{

cleartextall();

wait_for_space();

 

 

}/* end your function */

 

 

 

 

 

/************************************************/

/* do not delete m_main() */

/* M_MAIN FUNCTION */

/************************************************/

void CH_ENTRY m_main (long *ptrs)

{

if (open_app (ptrs))

if (product_level_1_or_design_enabled())

{

/* put your function here */

 

your_function();

}

close_app (ptrs);

}

/************************************************/

/* do not delete m_main() */

/* END M_MAIN FUNCTION */

/************************************************/

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.

Join us!

eMastercam - your online source for all things Mastercam.

Together, we are the strongest Mastercam community on the web with over 56,000 members, and our online store offers a wide selection of training materials for all applications and skill levels.

Follow us

×
×
  • Create New...