Previous Topic: Return ValuesNext Topic: Parse a Single Varbind into Multiple Event Variables


Examples of Procedures in Event Disposition Files

The following examples show how procedures can be used in event maps to implement event processing. Assume that each procedure is wrapped inside double quotes.

Add together two integer numbers (4 and 16):

Add( { I 16 }, { I 4 } )

Add together a direct value of 4 and the value in event variable 2 in the current event:

Add( { U 4 }, GetEventVariable( { U 2 } ) )

Create event 0xffff0000 for model 0x29c0003:

CreateEvent( { H 0x29c00003 }, { H 0xffff0000 } )

Create event 0xffff0000 if event variable 1 in the current event exceeds 100:

If( Less( { U 100 }, GetEventVariable( { U 1 } ) ),      \
   CreateEvent( { H 0x29c00003 }, { H 0xffff0000 } ),    \
   Nil()                                                 \
)

Create event 0x10002 with a list of event variables. The list will be a copy of the variables in the current event. In the new event, also set event variable 2 to 1965:

CreateEventWithVariables( { H 0x29c00003 },                            \
	{ H 0x10002 },                                                     \
	SetEventVariable( GetEventVariableList( { C CURRENT_EVENT } ),     \
			{ U 2 },                                          \
			{ U 1965 }                                        \
	)                                                                  \
)

Create a list and add several elements. The list will contain the following elements in this order: 5,3,2,1,4,6:

AddTail(                            \
   AddHead(                         \
      AddTail(                      \
         AddHead(                   \
            AddHead(                \
               AddTail(             \
                  CreateList(),     \
                  { U 1 } ),        \
               { U 2 } ),           \
            { U 3 } ),              \
         { U 4 } ),                 \
      { U 5 } ),                    \
   { U 6 } )

Create event 0x10002 for model 0x29c00003 if the model has IP address 191.168.102.25:

If ( HasIPAddress( { H 0x29c00003 }, { A 192.168.102.25 } ),     \
	CreateEvent( { H 0x29c00003 }, { H 0x10002 } ),              \
	Nil()                                                        \
)

Create event 0xffff0000 for model 0x29c00003 if attribute 0xffff0000 of the current model has the same value as event variable 1 in the current event:

If( Equals( ReadAttribute( { C CURRENT_MODEL }, { H 0xffff0000 }),   \
		GetEventVariable( { U 1 } )                             \
	),                                                               \
	CreateEvent( { H 0x29c00003 }, { H 0xffff0000 } ),               \
	Nil()                                                            \
)

Return TRUE if the current time is 8 a.m. or later:

GreaterOrEqual( GetHour( GetCurrentTime() ), { U 8 } )

Retrieve the value of event variable 1 in the current event and write it to attribute 0xffff0001 in the current model:

WriteAttribute( { C CURRENT_MODEL }, { H 0xffff0001 }, GetEventVariable( { U 1 } ) )

Create event 0xffff0000 for model 0x29c00003 if exactly 3 event variables in the current event’s event variable list have a value of 4. The procedure iterates over the list, assigning each element in the list to the loop variable ‘X’ in turn and checking its value. If the value of the element is 4, the return variable ‘ret’ is incremented. After iterating through the list, the return value is checked, and the event is generated if its value is 3:

If( Equals( ForEach( GetEventVariableList(),               \
		{ Variable X },                               \
		{ Variable ret },                             \
		{ U 0 },                                      \
		If( Equals( { Variable X },                   \
			{ U 4 } ),                           \
			Assign( { Variable ret },            \
				Add( { Variable ret },      \
				{ U 1 } )                   \
			),                                   \
			Nil()                                \
		)                                             \
	),                                                     \
	{ U 3 } ),                                             \
	CreateEvent( { H 0x29c00003 }, { H 0xffff0000 } ),     \
	Nil()                                                  \
)