Interface Functions

Interface functions allow you to link your model to external data sources such as text files, databases, spreadsheets and external applications. With the exception of @FILE, interface functions are valid only in sets and data sections, and may not be used in calc and model sections. The interface functions currently available in LINGO are listed below.

@FILE( 'filename')

The @FILE function allows you to include data from external text files anywhere in your model, where filename is the name of the file to include text form. This is particularly useful for incorporating data stored in text files in your sets and data sections.

When this function is encountered in a model, LINGO will continue to take text from this file until it encounters either the end-of-file or a LINGO end-of-record mark (~). For subsequent @FILE references in the same model that use the same file name, LINGO resumes taking input from the file at the point where it left off. Nesting of @FILE function calls (embedding an @FILE in a file which is itself called by @FILE) is not allowed.

For more information on use of the @FILE function, refer to Interfacing with External Files.

@ODBC( ['data_source'[, 'table_name'[, 'col_1'[, 'col_2' ...]]]])

The @ODBC function is used to open ODBC links between LINGO and databases. You can use @ODBC in the sets section to retrieve set members from a database, or in the data section to import data and/or export solutions.

The data_source is the name of the ODBC data source you registered with the ODBC Administrator. The table_name is the name of the table in  the data_source you want to open a link to. Finally, col_i is the column in the table table_name that you wish to link to.

The @ODBC function is discussed in detail in Interfacing with Databases.

@OLE( 'workbook_file'[, range_name_list])

The @OLE function is used to move data and solutions back and forth from Excel using OLE based transfers. You can use @OLE in the sets section to retrieve set members from Excel, or in the data section to import data and/or export solutions.

OLE transfers are direct memory transfers and do not make use of intermediate files. When using @OLE for exports, LINGO loads Excel, tells Excel to load the desired spreadsheet, and sends ranges of data containing solution values to the sheet. You must have Excel 5, or later, to use the @OLE function. The @OLE function is valid only in data and sets sections. @OLE can export two-dimensional ranges (rectangular ranges that lie on a single worksheet in Excel), but cannot export three-dimensional ranges (ranges which traverse more than one worksheet in Excel) or discontinuous ranges.

The workbook_file argument is the name of the workbook to link to. The range_name_list is the list of named ranges in the sheet to link to.

For more information on use of the @OLE function, refer to Interfacing with Spreadsheets.

@POINTER( N)

This function is strictly for use with the LINGO callable API. @POINTER allows you to transfer data directly through shared memory locations. For more information on the use of the @POINTER function, refer to Interfacing with Other Applications.

@TEXT( [['filename'], ‘a’])

The @TEXT function is used in the data section of a model to export solutions to text files, where filename is the name of the file you want to export the solution to. If filename is omitted, the solution data will be sent to the standard output device (in most cases this corresponds to the screen).  If you specify a file name and you wish to append output to the file instead of overwriting the file, include a second argument of ‘a’.

For additional documentation on the @TEXT function, see Interfacing with External Files.