Contents - Index



The $Import directive provides a simple way of reading selected variables from an ASCII file.  The data could be provided from a file written using the $Export directive or another application. The combination of $Export and $Import directives provides a convenient way to transfer information from one EES program to another or to itself. 


The format of the $Import Directive is 


$Import 'FileName'  /skiplines=10  Var1, Var2, X[1..5], S$...


FileName can be either a string constant (within single quotes) or a string variable containing the name of the file that the values will be read from.  If FileName is specified to be 'CLIPBOARD', the values of the variables will be read from the clipboard in text format.


The /skiplines directive is optional.  It can only be used when the import is from a file and not from the CLIPBOARD.  If used, the  /skiplines must be followed by an = sign and then with either an integer or a predefined EES variable that has been set to integer that indicates the number of lines to skip before starting the process of importing data from the specified file.


Var1, Var2, X[1..5] represent variables that are used in your EES program.  Note that array range notation is supported as are string variables.


The $Import directive can be placed anywhere in the Equations Window but it will be executed before calculations are initiated.  Note that the import process is executed only once, even if the calculations are repeated using a Parametric Table unless the equations are recompiled each run, e.g., with a $Recompile directive.  Multiple $Import directives are permitted, and they will be evaluated in the order that they occur in the Equations Window.   



File text.csv contains the following data:

1.2,  3.4  5

'string 1'  'string 2'  6


$Import 'text.csv'  X[1..3], A$, B$, C


After solving, variables X[1], X[2], X[3], A$, B$, and C will be set to the values in the file.


One possible application of the $Import and $Export directive occurs for 'harmonic steady-state' problems in which it is necessary to initialize variables at time zero to the values they have at some final time.  The values of these variables would be determined by solving one or more differential equations.  Use the $Export directive to write the final values to the clipboard.  Use the $Import directive to read the initial values from the clipboard.  Repeated executions should identify the harmonic steady-state if the problem converges with this successive substitution strategy.


Also see $ImportText$Export and Directives