Please enable JavaScript to view this site.

Vensim Help

Navigation: Reference Guide > Functions > Data Functions

GET DIRECT SUBSCRIPT('file','tab',firstcell,'lastcell', 'prefix') GET SUBSCRIPT elements DIRECTly from a file

Scroll Prev Top Next More

When used in a subscript equation this populates the subscript with values taken directly from a file. The file can be an Excel format file, or a delimited text file.

Restrictions: Must appear directly following the :  and not be followed by anything other than a mapping.  

GET DIRECT SUBSCRIPT is invoked when a model is checked. This will happen automatically when a .mdl file is open but only in response to an explicit model check (Ctrl+T or Model>Check Model) for .vmf or .vpm files. This function is not invoked as part of the simulation process.

Vensim will need to open the file to read it. This means the file must not be opened in another application. This function supports Microsoft Excel (.xls or .xlsx) files. It also supports text files that contain delimited data. By default Vensim will look for tab delimited data unless the extension on the  file is .csv in which case Vensim will look for comma delimited values. You can specify an alternative delimiting character in the second argument to the function when opening plain text files.

All of the arguments to GET DIRECT SUBSCRIPT must be literals (enclosed in single quotes ') or String Variables. 'file' names a file with complete extension to read from (use '?Tag' to indirectly reference a file and resolve the reference in Model>Settings>XLS Files).  It should be in the same directory as the current mode. 'tab' names the tab that contains the Data for excel files or the delimiter for text files.  'firstcell'  is the location of the first subscript element. 'lastcell' is the location of the last subscript element. Regardless of the file type the standard spreadsheet notation of letter number (up to ZZnnnnn) is used to refer to locations. Values are read across and then down as a list of subscripts, with missing or empty locations simply ignored. You can leave 'lastcell' blank (that is to say just two  single quotes with nothing between them)  to indicate that everything to the right and below 'firstcell' should be included. If 'lastcell' is a letter then all rows in that column will be read (normally the same column as 'firstcell'). If 'lastcell' is a number all columns in that row will be read.

'prefix' is used to modify the contents of the file. This is useful when some entries in th file are numeric and it can prevent the necessity to use quotation marks and it can also be helpful to in insuring that all elements have unique names.


       This function does not open Excel, and may fail if the file is opened in Excel or another application.
Subscript are read before anything else so changes in String Variables from .cin files (or from Venapp Commands) will never be used when determining file, tab, time and cell.
You can substitute named Excel ranges for 'firstcell'.  In this case 'lastcell' is ignored.


Units: Subscripts are not part of units checking.



NOTE On the Macintosh GET XLS SUBSCRIPT and GET DIRECT SUBSCRIPT both open files directly.

Availability:  Professional and DSS only. Models using this will work in the Model Reader but the source file is not required.



Sample model: GET DIRECT SUBSCRIPT.mdl in FunctionExamples