Contents - Index


$CopyToLookup

 

The $CopyToLookup directive provides a simple way of moving selected variables in the main program or in Functions, Procedures, or Subprograms to a specified column in a specified Lookup table.  This directive provides a simpler and faster alternative to using the Lookup command on the left side of an equation in a Function or Procedure as explained in the use of the Lookup function.  However, the $CopyToLookup directive is only implemented in the Professional license. 

 

The format of the $CopyToLookup Directive is 

 

$CopyToLookup  /T  /C  /R    'TableName',  'ColumnName', StartRow,  Var1, Var2, Var3[1..N]

 

'Tablename' is the name of the Lookup table that the data will be written to.  'Tablename' can be a string constant surrounded by single quotes as shown or a string variable that has been previously defined.

 

'ColumnName' is the name of the column in the Lookup table that the data will be written to.  'ColumnName' can be a string constant surrounded by single quotes as shown or a string variable that has been previously defined.  In addition, the units for the column can be specified by following the column name with a backslash (\) and then the units.

 

StartRow is the row for which the first data item will be written.  Each data item is written in a successive row.  StartRow can be an integer value (e.g., 1)  or a previously defined EES variable.

 

Var1, Var2, Var3[1..N] are EES variables that appear in the main program, Function, Procedure, or Subprogram that the $CopyToLookup directive is located within.  Each variable will appear in a successive row of the specified column.  The variable can be a string variable if the column in the Lookup table is designated to contain strings.  (See Example 2.)  Note that array range notation can be used to specify that a range of array variables.  The limits can be integers or previously defined EES variables, e.g., N.  

 

/T is optional.  If present, it will create a new Lookup table named 'TableName' if there is no existing Lookup table with this name. (Without this option, the Lookup table must already exist.)   If a new table is created, it will initially have 50 rows.

 

/C is optional.  If present, it will add a column named 'ColumnName' to the Lookup table named 'TableName' if a column with this name does not already exist.

 

/R is optional.  If present, this option will add rows to the Lookup table as needed in increments of 20 to ensure that all of the data specified data are included in the Lookup table.

 

The $CopyToLookup directive can be placed anywhere in the Equations Window, including within Functions, Procedures, and Subprograms.  Multiple $CopyToLookup directives are permitted.

 

Example 1:

"Start EES and enter the following equations: A Lookup table will be created automatically with 50 rows."

x=5

y=6

z=7

N=10

Duplicate i=1,N

x[i]=i^2

End

N$='abc\W/m^2'                  "column name is set to abc with units W/m^2"

X$='my Data'

$CopytoLookup /T /R /C X$  N$   1  X,y,z,x[1..N],N

 

After solving, a lookup table named 'my Data' having one column named 'abc' will be generated and it will contain the data shown in the figure.

 

 

Example 2:

{This example will create a new Lookup table with 1 column titled Strings with 50 rows.  Since string variables are being assigned, the column will automatically be formatted to hold strings.}

N=3

F$[1..N] =['String 1','String 2','String 3']

$Copytolookup /T /C /R 'myLookup Table', 'Strings', 1, F$[1..N]

$ShowWindow Lookup 

 

Note that an error will occur if you attempt to assign non-string variables to a column that is formatted for strings.

 

 

See also:    Lookup