Contents - Index

$OpenLookup / $SaveLookup


The $OPENLOOKUP directive (available in the Professional version) opens a file having the specified name and reads that file into the Lookup TableThe file can be a .CSV, .TXT, .DAT or .LKT Lookup file formatThe filename should include the filename extension.  The filename may be a string constant (enclosed within single quotes) or a string variable that has been previously assigned to the filename, as in the following examples.


$OPENLOOKUP 'C:\EES32\myTable.lkt'


{­File$ has been previously set to a valid lookup file name}

$OPENLOOKUP FILE$  /FORMAT='myfileFormat.fmt'  /RENAME='MyLookupTable'


When EES encounters this directive, it will first check to see if it has already opened a Lookup table with this filename.  If the Lookup table has already been opened and the time/date information for the disk file has not changed, no action will be taken.  Otherwise the table will be read.


The /FORMAT specification is optional.  If present, EES will look for the specified format file with a .fmt filename specification and it will read the Lookup file according to the format specification.  


The /RENAME specification is optional.  Normally, EES will associate the name on the tab of the Lookup window with the name of the file.  However the /RENAME specification provides the option to change the table name as desired using either a string constant or predefined string variable.


If a single question mark (?) is provided as a file name, EES will present a Windows open file dialog and then substitute the selected file name for the ? after opening the file.  The file name will be enclosed in single quotes so that file names with embedded spaces may be used.   If two question marks are provided, EES will open the selected file, but not make the substitution so that the open file dialog is presented during every execution. 


The $OpenLookup directive can have an optional second parameter which must be a string variable name.  The name of the Lookup file that is opened is assigned to this variable.  For example:


$OpenLookup ?? myLookupFile$


will bring up a standard file input dialog from which the file name can be selected.  That Lookup file will be opened and copied into the Lookup Table and the string variable myLookupFile$ will be set to the name of the Lookup table that is created.  


The ? or ?? can be appended with a file name extension which may be .LKT, .CSV, .TXT or .DAT.  If the file name extension is provided, the standard file input dialog that appears will only show files with the designated file name extension.  For example,


$OpenLookup ??.csv myLookupFile$


will show the standard file input dialog with a filter for .csv files.


Note that the number of columns and rows in a Lookup table that has been read in can be determined with the NLOOKUPCOLUMNS and NLOOKUPROWS functions. 



The $SAVELOOKUP directive will save a specified Lookup table into a disk file after calculations are completed.  The format is:


$SAVELOOKUP 'LookupTableName'   'C:\EES32\myTable.lkt'


'LookupTableName' is the name of the Lookup Table (as seen on the tabs in the Lookup Table Window) that is to be saved.  'LookupTableName can be a string constant contained in single quotes or a string variable The last parameter is the name of the file.  This name must be a string constant, a string variable that has been set to a valid file name or a ? or ??.  If a ? is provided, EES will display a standard save file dialog from which the name of the file can be selected.  That file name will then overwrite the ? so that the save file dialog does not reappear.  For example,


$SAVELOOKUP 'LookupTableName'   ?


will save the data in the lookup table name 'LookupTableName' into a  file that is selected from the save file dialog.  The ? will be overwritten with the selected filename.  If ?? is provided, it will not be overwritten and the save file dialog will appear after every calculation.


Note that the $SAVETABLE directive is a more general version of the $SAVELOOKUP directive with some additional capabilities.  See  $SAVETABLE for a list of the options available for this directive.


Lookup tables are automatically saved and opened when an EES file is saved and opened.  It is not necessary to use the $OPENLOOKUP and $SAVELOOKUP directives for this purpose.  The directives are useful for chaining EES programs, i.e., when the an EES program writes information into the Lookup Table using the Lookup command in a function or procedure so that a following EES program can use that information. 


The Lookup command can be used to save calculated results in the Lookup Table.  Several EES programs can be chained in sequential operation by saving the Lookup table as a Lookup file in one EES program and loading that Lookup file in the next EES program.  Link buttons on the Diagram window facilitate the chaining process.