LUALoriotPro WEB site

LoriotPro scripting documentation
Extensions for LUA language

Table of contents Search function

Print the current page Mail this  link UTUBE Channel version française

lp.LoadLibrary - Load a new LUA library

LoriotPro has extended the LUA sripting language by providing its own LUA libraries. The new functions provided are dedicated to the creation of monitoring and SNMP automation application.

Syntax

lib,init=lp.LoadLibrary(“libpath”, “init_function_name”); ;

Description

The lp.LoadLibrary LUA function allow you to load in a script a set of new functions defined in an LUA external library. The LIBRARY should be in the LUA 5.0.2 format. For more informations about the library creation, read the LUA documentation on the www.lua.org.

Remark

Meanwhile this function can be use in a virtual SNMP object we do not recommend to use it. This function can be used in Active View when calling script from menu.

The usage of the lp.FreeLibrary to close the opened library can create instability. In that case it is better to close the calling script and program that close the library.

Parameters

libpath - The path and the name of the library to load.
init_function_name - The name of the initialisation function of the library

Return Values

Lib - A pointer on the library. Can be use to free it
Init - A pointer on the library initialization function

Example

This example display a dialog box on the screen

lp_value = 0;
lp_buffer ="error";

lib,init=lp.LoadLibrary(lp.GetPath().."/lua_wizard.dll","libinit");

if (lib) then
init();
lpwz.MsgBox("test","test");
if lp.FreeLibrary(lib) then
lp_buffer ="ok";
end
end

Warning! The strategy includes a LUA language to load external libraries with the class package and the reserved keyword "require".

If you download the examples on the internet you will certainly find these commands at the beginning of the script. Consult the documentation for LUA www.lua.org for more information.

Here is an example of loading with the library lualdap you can find on the website: http://www.keplerproject.org

require "lualdap" 

ld = assert (lualdap.open_simple ("ldap.server",

                "mydn=manoeljoaquim,ou=people,dc=ldap,dc=world",

                "mysecurepassword"))

 

 

lib,init=lp.LoadLibrary(lp.GetPath().."/lualdap.dll","luaopen_lualdap"); 

if (lib) then

init(); 

ld = assert (lualdap.open_simple ("ldap.server",

                "mydn=manoeljoaquim,ou=people,dc=ldap,dc=world",

                "mysecurepassword"))

end

 

 


www.loriotpro.com