Function NextBusByName

 

Function NextBusByName( ByRef nBusHandle& ) As Long

Purpose: Get handle of next bus in a bus list which has been sorted by bus name and nominal kV.

Works in:      OneLiner and Power Flow.

Parameters:     

nBusHandle   [in/out] bus  handle

Return value:

1               success

-1              already at last bus

0               failure

Remarks: To get the first bus in the list, call this function with nBusHandle = 0

Example:

 

   ‘ Print bus list shorted by name and kV

   nBusHnd& = 0

   While NextBusByName( nBusHnd& ) > 0

      ' Print bus info

      If GetData( nBusHnd&, BUS_sName, sVal1$ ) = 0 Then GoTo HasError

      If GetData( nBusHnd&, BUS_dKVnorminal, dVal1# ) = 0 Then GoTo HasError

      If GetData( nBusHnd&, BUS_nNumber, nVal1& ) = 0 Then GoTo HasError

      If GetData( nBusHnd&, BUS_nArea, nVal2& ) = 0 Then GoTo HasError

      If GetData( nBusHnd&, BUS_nZone, nVal3& ) = 0 Then GoTo HasError

      Print #1, "BUS    ";  FullBusName( nBusHnd& );"  AREA=";nVal2&;"  ZONE="; nVal3&

   Wend