IMPORT TEXT

4D - Documentation   Français   English   German   4th Dimension 2004, Command Theme List   4th Dimension 2004, Command Alphabetical List   4th Dimension 2004, Constant Theme List   Back   Previous   Next

version 3


IMPORT TEXT ({table; }document)

ParameterTypeDescription
tableTableTable into which to import data, or
Default table, if omitted
documentStringText document from which to import data

Description

The IMPORT TEXT command reads data from document, a Windows or Macintosh text document, into the table table by creating new records for that table.

The import operation is performed through the current input form. The import operation reads fields and variables based on the layering of objects in the input form. For this reason, you should be very careful about the front-to-back order of text objects (fields and variables) in the form. The first object into which data will be imported should be in the back of the form, and so on. If the number of fields or variables in the form does not match the number of fields being imported, the extra ones are ignored. An input form used for importing cannot contain any buttons. Subform objects are ignored.

Note: One way to ensure that the data is imported into the correct objects is to select the object into which the first field should be imported and move it to the front. Continue to move fields and variables to the front in order, making sure that you have one field or variable for each field being imported.

An On Validate event is sent to the form method for each record that is imported. If you use variables in the import form, use this event to copy data from variables to fields, .

The document parameter can include a path that contains volume and folder names. If you pass an empty string, the standard Open File dialog box is displayed. If the user cancels this dialog, the import operation is canceled, and the OK system variable is set to 0.

A progress thermometer is displayed during import. The user can cancel the operation by clicking a button labeled Stop. Records that have already been imported will not be removed if the user presses the Stop button. If the import is successfully completed, the OK system variable is set to 1. If an error occurs or the operation was interrupted, the OK variable is set to 0. The thermometer can be hidden with the MESSAGES OFF command.

The import operation is made using the default ASCII map for the platform on which it is executed, unless you change the ASCII map (using the command USE ASCII MAP) prior to the import. An ASCII map can be used to convert the data coming from other platforms that have a different ASCII table.

Using IMPORT TEXT, the default field delimiter is the tab character (ASCII 9). The default record delimiter is the carriage return character (ASCII 13). You can change these defaults by assigning values to the two delimiter system variables: FldDelimit and RecDelimit. The user can change the

defaults in the User environment's Import Data dialog box. Text fields may contain carriage returns, therefore, be careful when using a carriage return as a delimiter if you are importing text fields.

Example

The following example imports data from a text document. The method first sets the input form so that the data will be imported through the correct form, changes the 4D delimiter variables, then performs the import:

   INPUT FORM([People]; "Import")
   FldDelimit:=27 ` Set field delimiter to Escape character
   RecDelimit:=10 ` Set record delimiter to Line Feed character
   IMPORT TEXT([People];"NewPeople") ` Import from "NewPeople" document

See Also

EXPORT TEXT, IMPORT DIF, IMPORT SYLK, USE ASCII MAP.

System Variables and Sets

OK is set to 1 if the import is successfully completed; otherwise, it is set to 0.


4D - Documentation   Français   English   German   4th Dimension 2004, Command Theme List   4th Dimension 2004, Command Alphabetical List   4th Dimension 2004, Constant Theme List   Back   Previous   Next