Macro command if

<< Click to Display Table of Contents >>

Navigation:  Macros > Macro commands and parameters > Macro conditional commands >

Macro command if

If ... [Else] ... End

 

Purpose:

Executes a number of macro commands dependent on the result of a comparison between two values.

 

The If command is always used together with an End command. There is also an Else available for the case the outcome of the comparison is not true. The If and End lines enclose the part of the macro whose execution depends on fulfilment of the condition. General notation:

If ( value1 , collation character , value2 )

[Else]

End

 

The collation character may be:

= (equals),

<> (does not equal),

< (less than),

<= (less than or equal to),

> (more than),

>= (more than or equal to).

 

Examples:

If the current through cable with name 'MyCable' is larger than 80% of the maximum cable ampacity, lower the load with name 'MyLoad' with 10%:

 If( Cable( 'MyCable' ).Load, >, 80 )

         Multiply( Load( 'MyLoad' ).Pl, 0.9 )

         Multiply( Load( 'MyLoad' ).Ql, 0.9 )

 End

 

Write a text if the transformer with name 'MyTransformer' load is 90% or more:

 If( Transformer( 'MyTransformer' ).Load, >= , 90 )

         Text'Transformer nearly overloaded.' )

 Else

         Text'Transformer not overloaded' )

 End

 

Change the tap changer of transformer with name 'MyTransformer' if not to its limit and if the voltage at node with name 'MyNode' is lower than 95% of its nominal value:

 If( Node( 'MyNode' ).Upu, < , 0.95 )

         If( Transformer( 'MyTransformer' ).Tap, > , 1 )

                 Subtract( Transformer( 'MyTransformer' ).Tap, 1 )

         Else

                 Text‘Transformer tap changer reached limit’)

         End

 End

 

Test the logical function and. The text function prints FALSE and the if-command prints no. Also applicable on or and xor.

 set( a, true )

 set( b, false )

 text( and( a, b ) )

 

 if( xor( a, b ), = , true )

         text'yes' )

 else

         text'no' )

 end