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?
- To: <imagepro-users[at]lists.mediacy.com> (Image-Pro Plus Users Email List)
- Subject: ImagePro>Re: Can a IPBasic macro call a Macro made with the SDK?
- From: Stan Voynick <svoynick[at]selmar.com>
- Date: Fri, 16 Nov 2001 09:20:09 -0800
- List-Archive: <http://lists.mediacy.com:80/Lists/imagepro-users/List.html>
- List-Unsubscribe: <mailto:imagepro-users-off@lists.mediacy.com>
- Reply-To: <imagepro-users[at]lists.mediacy.com> (Image-Pro Plus Users Email List)
- Sender: <imagepro-users[at]lists.mediacy.com> (Image-Pro Plus Users Email List)
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