ImagePro>Re: Can a IPBasic macro call a Macro made with the SDK?


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

ImagePro>Re: Can a IPBasic macro call a Macro made with the SDK?



Stan,

Keep in mind that the better approach to allowing a user to experiment with
your code is to take the trouble to implement macro support.  At that point,
they can write standard AutoPro macros, and call your module in exactly the
same way they call any other module in IPP.

Chris Tully
Senior Technical Services Engineer and Quality Assurance Analyst
Media Cybernetics, Inc. "From Images to Answers"
8484 Georgia Avenue, Suite 200
Silver Spring, MD  20910
Tel: +1 (301) 495-3305 ext. 3            Fax: +1 (301) 495-5964
E-mail: TechSupport@mediacy.com
Media Cybernetics Website: www.mediacy.com
Media Cybernetics Solutions Zone: www.solutions-zone.com


-----Original Message-----
From: Image-Pro Plus Users Email List
[mailto:imagepro-users@lists.mediacy.com]On Behalf Of Stan Voynick
Sent: Friday, November 16, 2001 12:20 PM
To: Image-Pro Plus Users Email List
Subject: ImagePro>Re: Can a IPBasic macro call a Macro made with the
SDK?



Kevin Ryan wrote:
>
> Normally we don't recommend calling macros from C/C++ code. There's
> no guarantee that the appropriate macro is available!

... but there are occasionally cases where it might be useful.  I had coded
an application in a plug-in, but I wanted to give my (relatively
sophisticated) end-user some the ability to reprogram one particular part of
the process, so at the appropriate place in my "C" code, I inserted a call
to a pre-defined script file and macro name.  That kept most of the process
in fast, efficient C-code, but still gave the user the flexibility to
experiment and change the process in the desired way.


#############################################################
##################  "C" code  ###############################

char szScriptFile[_MAX_PATH];
char szNUCMacroFile[512];

// get the existing script file name so it can be restored

::SendMessage(hWndApp, MCM_PLUGIN, PLUGM_GETSCRIPTNAME, (LPARAM) (LPSTR)
szScriptFile);

// we specified that the user-modifiable script must be
// in the IPWin install directory, so we get that and
// append the pre-defined script file name to it

ret = IpAppGet(GETAPPDIR, 0, szNUCMacroFile);
strcat(szNUCMacroFile,"UserScript.scr");

ret = IpMacroRun("UserMacro",szNUCMacroFile);

if ( ret )
{
   sprintf(str,"problem running script; return code %d",ret);
   ::MessageBox(hWndApp,str,"User Macro",MB_OK);
}

// reload previous macro file, to leave things as we found them
ret = IpMacroLoad(szScriptFile);

#############################################################

   In another application, I used the PLUGM_GETMACROCOUNT followed by a loop
of PLUGM_GETMACRONAME calls to enumerate the list of currently available
macros in a certain file.  Then I was able to provide a drop-down list box
in a dialog to let the user pick a macro that he/she wanted to execute at a
particular spot.

   Bottom line: either way, if you do error checking (checking the return
value of IpMacroRun), you can provide a "graceful" failure mode so that
things don't have to crash if a macro is not available.  You could even set
it up so that if the macro is available, it gets run, but if it's not, you
have some section of "default" C-Code that executes instead.  This way, you
can provide for customizability, but it keeps operating transparently if the
user chooses not to provide a customized macro.

Regards,

   - Stan -

--
------------------------------------------------------------------

***********************************************************
Need an Image-Pro macro or driver? Find it at http://www.Solutions-Zone.com
Got an Image-Pro macro or driver? Add it to http://www.Solutions-Zone.com
***********************************************************

This message is sent to you because you are subscribed to
<imagepro-users@lists.mediacy.com>.
To unsubscribe, email to: <imagepro-users-off@lists.mediacy.com>
To switch to the DIGEST mode, email to
<imagepro-users-digest@lists.mediacy.com>
To switch to the INDEX mode, email to
<imagepro-users-index@lists.mediacy.com>
Send administrative queries to  <imagepro-users-request@lists.mediacy.com>
To subscribe or unsubscribe visit
http://www.solutions-zone.com/ipednld/subscriber.asp


***********************************************************
Need an Image-Pro macro or driver? Find it at http://www.Solutions-Zone.com
Got an Image-Pro macro or driver? Add it to http://www.Solutions-Zone.com
***********************************************************

This message is sent to you because you are subscribed to <imagepro-users@lists.mediacy.com>.
To unsubscribe, email to: <imagepro-users-off@lists.mediacy.com>
To switch to the DIGEST mode, email to <imagepro-users-digest@lists.mediacy.com>
To switch to the INDEX mode, email to <imagepro-users-index@lists.mediacy.com>
Send administrative queries to  <imagepro-users-request@lists.mediacy.com>
To subscribe or unsubscribe visit http://www.solutions-zone.com/ipednld/subscriber.asp



Search this Archive