HP-UX SNAplus2 R7 LUA Programmer's Guide
Designing and Writing LUA Applications
Issuing an LUA Verb
UNIX
#include < lua_c.h>
WINDOWS
#include < winlua.h >
UNIX
2. Set up a callback function that LUA will use to indicate that the verb has completed asynchronously. (For more
information, see Section 2.1, LUA Entry Points for HP-UX Applications.)
void callback(verb)
LUA_VERB_RECORD * verb;
{
.
.
.
}
WINDOWS
If this is the first LUA verb from the application, and the application will be issuing RUI verbs using the WinRUI
call, issue the WinRUIStartup call to initialize the application’s use of LUA. Similarly, if the application will
be issuing SLI verbs using the WinSLI call, issue the WinSLIStartup call to initialize the application’s use
of LUA. (For more information, see Section 2.2, LUA Entry Points for Windows Applications.) This call must
be issued once before the application’s first LUA verb; it must not be repeated before subsequent verbs.
Also issue the RegisterWindowMessage call, to obtain the message identifier that LUA will use when
posting messages to indicate the completion of an LUA verb. (For more information, see Section 2.2, LUA
Entry Points for Windows Applications.) This call must be issued once before the application’s first LUA verb;
there is no need to repeat it before subsequent verbs.
3. Create a variable for the VCB structure.
LUA_VERB_RECORD rui_init;
The LUA_VERB_RECORD structure is declared in the header file /usr/include/sna/lua_c.h (HP-UX
applications) or sdk/winlua.h (Windows applications); for an explanation of the VCB structure, see Chapter
3, LUA VCB Structure.
4. Clear (set to 0) the variables within the VCB.
memset( rui_init, 0, sizeof( rui_init) );
LUA requires that all reserved parameters, and all parameters not required by the particular verb being issued,
must be set to 0 (zero). For details about reserved parameters, see Section 3.1, LUA Verb Control Block (VCB)
Format. The simplest way to do this is to set the entire VCB to zeros before setting the parameters required for
this particular verb.
5. Assign values to the VCB parameters that supply information to LUA.
rui_init.common.lua_verb = LUA_VERB_RUI
rui_init.common.lua_verb_length = sizeof(LUA_COMMON);
rui_init.common.lua_opcode = LUA_OPCODE_RUI_INIT;
memcpy (rui_init.common.lua_luname, "THISLU ", 8);
42