<< Click to Display Table of Contents >> Navigation: Macros > Macro commands and parameters > Macro procedures |
User defined procedures enable the execution of frequently used sets of macro commands, for example calculations or reporting actions.
Definition of a procedure:
Procedure ( procedure_name )
...
...
End
Using a procedure:
Call ( procedure_name )
The procedures do not have parameters and use only global variables. The definitions may not be nested. However, a previously defined procedure may be called in a next procedure definition. It is allowed to recursively call procedures.
Example:
procedure(calculate_deviation)
// calculate (U-Uref) / Uref * 100%
set(x,U)
subtract(x,Uref)
divide(x,Uref)
multiply(x,100)
end
procedure(print_voltages)
text(U:6:2,' kV ',Uref:6:2,' kV ',x:6:2,' %')
end
loadflow(0,,true)
if(Network.Result,=,'LF')
text('Voltage Reference Deviation')
text('======= ========= =========')
set(Uref,node('MS-Station').U)
forselection(node('MS-net'),MyNode)
set(U,MyNode.U)
call(calculate_deviation)
call(print_voltages)
end
else
text('no loadflow')
end
On the demo network this macro results in:
Voltage Reference Deviation
======= ========= =========
10,36 kV 10,36 kV 0,00 %
10,08 kV 10,36 kV -2,75 %
10,31 kV 10,36 kV -0,48 %
9,93 kV 10,36 kV -4,16 %
10,37 kV 10,36 kV 0,09 %
9,93 kV 10,36 kV -4,16 %