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

lpav.InsertMenu - Insert a contextual menu option

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 

result = lpav.InsertMenu(type, caption, parameters);

Description

Add an option into the contextual menu of a graphical Active View object. The new menu option is inserted at the end of the contextual menu.

Graphical object contextual menu
menu option creation

Remark

The menu option are stored under their name in the Active View file

object menu 17 "Select all" "D:\v4-net\bin\config\script\SELECT~1.LUA defip"
object menu 17 "Clear All selected" "D:\v4-net\bin\config\script\CLEARA~1.LUA defip"
object menu 17 "Put internetwork map" "D:\v4-net\bin\config\script\new\LPAVIN~2.LUA defip"
object menu 17 "Unselect G" "D:\v4-net\bin\config\script\clean.lua defip"
object menu 17 "Delete All Selected" "D:\v4-net\bin\config\script\DELETE~1.LUA defip"

They can be easily converted and inserted in a script

lpav.InsertMenu(LPAV_ACTION_RUN_SCRIPT_LUA,"Select all","D:\v4-net\bin\config\script\SELECT~1.LUA defip");
lpav.InsertMenu(LPAV_ACTION_RUN_SCRIPT_LUA,"Clear All selected","D:\v4-net\bin\config\script\CLEARA~1.LUA defip");
lpav.InsertMenu(LPAV_ACTION_RUN_SCRIPT_LUA,"Put internetwork map","D:\v4-net\bin\config\script\new\LPAVIN~2.LUA defip");
lpav.InsertMenu(LPAV_ACTION_RUN_SCRIPT_LUA,"Unselect G","D:\v4-net\bin\config\script\clean.lua defip");
lpav.InsertMenu(LPAV_ACTION_RUN_SCRIPT_LUA,"Delete All Selected","D:\v4-net\bin\config\script\DELETE~1.LUA defip");

Parameters

type - The type of action to perform. The list of available paramleters is stored in the file loriotinit.lua

dofile(lp.GetPath().."/config/script/loriotinit.lua");


type parameter
LPAV_ACTION_NONE
LPAV_ACTION_LOADMAP
LPAV_ACTION_WINEXEC
LPAV_ACTION_SHELLEXEC
LPAV_ACTION_PLUGIN
LPAV_ACTION_TABLE
LPAV_ACTION_SCRIPT_REP
LPAV_ACTION_SCI
LPAV_ACTION_FOUND_INDIR
LPAV_ACTION_MODAL_MAP
LPAV_ACTION_SET_OID
LPAV_ACTION_CLEAR_EVENTREF
LPAV_ACTION_CLEAR_EVENTFILTER
LPAV_ACTION_CLEAR_TRAPFILTER
LPAV_ACTION_CLEAR_EVENTGENERATED
LPAV_ACTION_CLEAR_TRAPGENERATED
LPAV_ACTION_CLEAR_TRAPREF
LPAV_ACTION_RUN_SCRIPT_LUA

Caption - The option name at it appears in the contextual menu

parameter - The parameters link to this action. It is a character string that can be created from the graphical user interface. We recommend to use the user interface to create such command line parameters.

Return Values

Result=1 if ok, nil if error

Example


lp_value = 0;
lp_buffer ="error";

dofile(lp.GetPath().."/config/script/loriotinit.lua");

zz=LPAV_OBJ_ANALOGIC_METER_01;

k=0;
for i=0,20 do
lpav.Insert(10*i,1,9,9,zz);
if (k==0) then lpav.SetRef(1,"r"); k=1; else lpav.SetRef(1,"s"); k=0; end
lpav.SetBrush(0,255,0);
lpav.SetFontName("Mistral");
lpav.SetName(i);
lpav.SetClipart( lp.GetPath().."/card/vumeters/vumeter8.emf");

lpav.InsertMenu(LPAV_ACTION_RUN_SCRIPT_LUA,"Select all","D:\v4-net\bin\config\script\SELECT~1.LUA defip");
lpav.InsertMenu(LPAV_ACTION_RUN_SCRIPT_LUA,"Clear All selected","D:\v4-net\bin\config\script\CLEARA~1.LUA defip");
lpav.InsertMenu(LPAV_ACTION_RUN_SCRIPT_LUA,"Put internetwork map","D:\v4-net\bin\config\script\new\LPAVIN~2.LUA defip");
lpav.InsertMenu(LPAV_ACTION_RUN_SCRIPT_LUA,"Unselect G","D:\v4-net\bin\config\script\clean.lua defip");
lpav.InsertMenu(LPAV_ACTION_RUN_SCRIPT_LUA,"Delete All Selected","D:\v4-net\bin\config\script\DELETE~1.LUA defip");

lpav.SetOption(LPAV_UNIT,"%");
end
lp.Trace("fin");
lpav.RefreshMap();

 


www.loriotpro.com