Contents - Index


$ImportText

 

The $ImportText directive provides a simple way of reading string information into EES string variables from an ASCII file.  The data could be provided from a file written using the $Export or $ExportText directive or from another application. The $ImportText directive differs from the $Import directive in that it can only be used to read information into string variables and all of the text on each line in the file is assigned to the string variable.  

 

The format of the $ImportText directive is 

 

$ImportText 'FileName'  /skiplines=10  S1$, S2$, S$[1..4]

 

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 string variables will be read line by line 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 (with no spaces) and then with an integer that indicates the number of lines to skip before starting the process of importing data from the specified file.

 

S1$, S2$, S$[1..4] represent scalar or array string variables that are used in your EES program.  Note that array range notation is supported.

 

The $ImportText 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.  Multiple $ImportText directives are permitted, and they will be evaluated in the order that they occur in the Equations Window.   Note that function NFileRows can be used to determine the number of rows (or lines) in the specified file. 

 

Example: 

 

File C:\temp\data.txt contains the following data:

'test 1'

test 2

test 3

skip next

'  '

test 6

 

T$='C:\temp\data.txt'

N=nfilerows(T$)

$ImportText  T$  S$[1..N]

 

 

After solving, the each element of the S$ string array will contain the information on the corresponding row of the file.  Note that single quotes surrounding the text data, as in line 1, are removed.  

 

 

Also see the $Import directive and the ImportText macro command.