Contents - Index
Duplicate is not a function but rather an EES command. The Duplicate command is necessary in Modules, Subprograms and the EES main program.
Within Modules, Subprograms and the EES main program, the Duplicate command provides a shorthand way of entering equations into EES. The equations that are to be duplicated are enclosed between the Duplicate and End commands. The lower and upper limits specified for the Duplicate command must be integer number or a variable set to an integer constant ahead of the Duplicate command. In this application, the Duplicate command is only useful when used with array variables, e.g., X[j]. For example, the following statements in a Module, Subprogram or EES main program:
are equivalent to:
The lower and upper loop limits can be any of the following:
i) a numerical quantity or expression
ii) an EES variable that has been set to a value ahead of the Duplicate statement.
iii) an EES variable that is set to a value in the Parametric table
iv) the TableRun# keyword.
EES compiles the equations before execution occurs. That is the reason the index limits must be known before the Duplicate statement is processed. This is one of few situations in which the order of the equations is important.
Note that EES does not allow more than one Duplicate clause to appear within the range of an outer Duplicate clause. The following code, for example, would result in a compilation error.
duplicate k=1,5 "this will not work"
However, the intent of these equations can be entered by placing each inner Duplicate clause within its own other clause, as shown below. These equations will compile with no problems.
In the Main program or in Subprograms, the statements within Duplicate - End blocks are literally duplicated to generate additional equations. This is not necessary within an internal Function or Procedure as assignment statements, rather than equalities, are employed. Duplicate - End blocks within Functions and Procedures are internally rewritten as Repeat-Until blocks which is more efficient and allows the limits of the Duplicate command to be passed as arguments to the Function or Procedure. In effect, the following equations:
are internally written as:
You may prefer to explicitly enter the equations in this manner.
(Note: use a semicolon instead of a comma as the list separator when using the European numerical format)