Macro command For ... End

<< Click to Display Table of Contents >>

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

Macro command For ... End

Purpose:

Execute a number of macro commands for all objects of a specified type. The objects are one by one temporary stored into a variable.

 

The For-command always occurs together with an End. Between For and End are the repeatedly executable commands. General notation:

For ( ExtendedObject , ObjectVariableName )

End

 

An ExtendedObject can be:

an object (Node, Link, Cable, Line, …), as defined in paragraph 4.1

Branch: general indication of a branch between two nodes (Link, Cable, …)

Element: general indication of an element on a node (Source, SynGen, …)

Object: general indication of a component in the network.

Loadbehaviour: load behaviour

Selection: selection

 

Examples:

Perform an N-1 contingency analyse for all branches:

 Set( sheet, 1 );

 Set( column, 1 );

 Set( row , 1 );

 For( Branch, failingbranch )

         Write( sheet, row , column, failingbranch )

         Set( failingbranch.FirstSwitch, open )

         Loadflow( 0, , true )

         Write( sheet, row, 2, Node('MyNode').upu)

         Set( failingbranch.FirstSwitch, closed )

         Add( row , 1 )

 End

 

Report for all components the name:

 Set( sheet, 1 )

 Set( column, 1 )

 Set( row , 0 )

 For( Object, Component )

         Add( row , 1 )

         Write( sheet, row , column, Component.Name )

 End

 

Other examples:

 For( Loadbehaviour, MyLoadBehaviour )

 For( Selection, MySelection )