Macro command Read

<< Click to Display Table of Contents >>

Navigation:  Macros > Macro commands and parameters > Macro input commands > Macro read from an Excel file >

Macro command Read

Purpose:

Reading a value from a cell on the worksheet of a spreadsheet.

 

General notation:

Read ( FileIndex , sheet , row , column , Object( ObjectName ).Attribute )

or

Read ( FileIndex , sheet , row , column , Variable )

 

FileIndex is an index pointing to the opened spreadsheet file.

 

In the case that a value of 0 has been assigned to FileIndex, the Read command reads from the spreadsheet file that has been currently written by the Macro Write command.

 

The worksheet cell can be accessed by its row and colum number. The normal Excel notation (identification of a cell by means of a combination of letters and numbers) is not possible because the macro language works on a numeric basis.

 

Example:

Read the results of an n-1 contingency analysis for all branches in sheet 1 of a spreadsheet assigned to FileIndex 1 and present as text:

 Set( row, 3 )

 Loop ( Index , 1 , 8 , 1 )

         Add( row, 1 )

         Read ( 1 , 1 , row, 1, failingbranch )

         Read ( 1 , 1 , row, 2, nodevoltage )

         Text ( 'Branch: ', failingbranch, ' voltage: ', nodevoltage, ' p.u.' )

 End

 

The example above uses the next Excel spreadsheet data :

 

Results N-1 contingency analysis year:

2006



Failing branch:

Voltage (p.u.):

Link

1.0199

Cable MSStat - Stat1 circuit 1

0.9798

Cable MSStat - Stat1 circuit 2

0.9798

Cable MSStat - Stat4 circuit 2

0.9906

Cable MSStat - Stat4 circuit 1

0.9906

Cable Stat4 - Stat3

0.9505

Cable Stat4 - Main bus bar

0.9833

Cable Stat1 - Stat3 circuit 1

0.966

 

See also:

Open

Close

Input

 

Back to input commands.