Attributes . . Usage . . Related Topics . . Tag Index . . Home
The MIEVENT tag enables you to temporarily halt the processing of the AppPage to execute application code. Use this tag to perform tasks, such as opening sockets or reading from files, that are more easily accomplished with C code than with AppPage tags. Use the MIEVENT tag in combination with an event-handling function. The processing of the AppPage continues when the event handler exits.
| NAME | Specifies the name that identifies the event. This name is passed to wcSetEventHandler( ) to set up the relationship between the event and the event-handling function. |
The following examples illustrate how to use the MIEVENT tag to execute application code within an AppPage.
In the following AppPage, the MIEVENT tag passes control to the application associated with the name ParseFile. The application parses a file, determines the value of the ParseVar variable, and returns control to the AppPage. Then the MIVAR tag is used to display the value of ParseVar.
<HTML> <BODY> ... <?MIEVENT NAME="ParseFile">; <?MIVAR>The value is: $ParseVar<?/MIVAR> ... </BODY> </HTML>
The following parser( ) function handles the ParseFile event:
/* Declare the event handling function */
int parser(controlHandle)
void *controlHandle;
{
int valOut;
...
/* Code to read a file and calculate a value for valOut */
...
/* Set ParseVar=valOut */
wcSetVariable(controlHandle,"ParseVar", valOut);
}
int requestLoop(controlHandle)
void *controlHandle;
{
char *pageText;
wcConOpen(controlHandle, 0);
/* Associate parser( ) with the "ParseFile" event */
wcSetEventHandler(controlHandle, "ParseFile", parser);
/* Load and explode the AppPage */
wcLoad(controlHandle, "page", &pageText);
WebExplode(controlHandle, pageText, NULL);
wcConClose(controlHandle);
}
The parser( ) function is called when WebExplode( ) encounters the MIEVENT tag in the AppPage.
In the following example, the nameList( ) function runs a query to populate a list box in the AppPage:
/* Declare the event handling function */
int nameList(controlHandle)
void *controlHandle;
{
WebSelectList(cntrlHandle, "select last_name from customers",
"NAME=last&VALUE=selectList1", NULL);
}
int requestLoop(controlHandle)
void *controlHandle;
{
char *pageText;
wcConOpen(controlHandle, 0);
/* Associate nameList( ) with the "List" event */
wcSetEventHandler(controlHandle, "List", nameList);
/* Load and explode the AppPage */
wcLoad(controlHandle, "page", &pageText);
WebExplode(controlHandle, pageText, NULL);
wcConClose(controlHandle);
}
The nameList( ) function is called when WebExplode( ) encounters the following tag in the AppPage:
<HTML> <BODY> ... <?MIEVENT NAME="List">; ... </BODY> </HTML>
You can set up to 30 different event names within a single Universal Web Connect application. You can also call wcSetEventHandler( ) and reuse the same event name, but register a new event handler for an event.
wcCallEventHandler()
wcSetEventHandler()
For information about how to escape special characters (", { , }, and
$) so that they are interpreted literally, see Special
Characters in AppPage Tags.