Import field from file

Command group Flag affected Reversible Execute on client Platform(s)
Importing and Exporting YES NO NO All

Syntax

Import field from file into field-name ([Single character][,Leave in buffer])

Options

Single character If specified, the command reads a single character at a time
Leave in buffer If specified, the command leaves the data it returns in the buffer meaning that the next call to the command will return the same value

Description

This command reads a line of characters from the current import file to the specified field. It lets you read fields from a file without using a window and Import data. Usually the command reads a whole line at a time but there are options which modify this.

The Single character option tells Omnis to read a single character at a time. If the field is a Character or a National field, it is set to have a length of one, containing the single character imported from the file. If the field is a Number field, the field value is set to the ASCII code of the single character imported from the file.

The Leave in buffer option tells Omnis to read the string or single character but not remove it from the buffer. Therefore, the next Import field from file will read exactly the same value.

An error will occur if the import file has not been opened; Omnis clears the flag on reaching the end of the file. Do not mix Import data and Import field from file because they use the input buffer in different ways.

Example

; import from a csv file called myImport.txt in the root of your omnis tree
Calculate lImportPath as con(sys(115),'myImport.txt')
Set import file name {[lImportPath]}
Prepare for import from file {Delimited (commas)}
Repeat
  Import field from file into lImportField
Until lImportField='start data'
Do method ImportData
Close import file