Navigation:  Reference > Commands >

Import Records

Print this Topic Previous pageReturn to chapter overviewNext page


This command will import records from a non-TAS file and save them to a TAS Professional file.  Within this single command you can accomplish many tasks that would normally take many more lines of code and more time to execute.


IMPORT fn/v1, fn/v2,..., fn/vx Required - The fields in the record that are being imported to.  These must be real fields and cannot be expressions.  These also means that you shouldn't include array specifiers, so, ABC[1] should be included in the list as ABC.


FROM f/c/e Required - The name of the file you are importing from.  Must include the entire path, if any, and any extension.  The program will use the exact name you enter.


TYPE f/c/e Required - The type of file you are importing from.  The options are:


       D - dBASE III+

       L - delimited

       F - fixed length/SDF

       X - text


       Don't forget:  this option entry needs to be a constant ('L', or 'D', etc.) or a field that contains a single character that matches one of the above.


DLM f/c/e If you choose the delimited ('L') type of file you can also choose a delimiter character.  If you don't specify this value the program will assume commas (,) between each field and alpha fields surrounded with quotes ("xxx").


MEM If you are importing to an array in memory instead of a standard file include this option in the command.


MAXA fn/v If the MEM option is included, then this is required. This is the maximum number of elements in the array to be imported to.


CNTR fn/v This is an I or R type field that will be used for passing the number of records read, and the current array number, to your program.  You can also use this to count the number of records read.


TO file_num Required  - The number/handle of the file to be imported to.  This must be a currently opened file in your program.



       scope - This option may help determine how many records are imported.  The options are:  A (All), F (First), N (Next) and R (Rest).  For more information about the scope specifier please see the general information at the beginning of this chapter.


       f/c/e - If scope is set to N or F this is the number of records to import.


       An example of this would be:


               ... SCOPE A...                //all records in the file.  This is the default scope value.


               ... SCOPE N 20 ...        //the next 20 records in the file


FOR lexpr You would use this option to restrict the records imported in this command.  If the expression did not resolve to .TRUE., the record would not be imported.    In this option, the search continues until the program reaches the end of file and then will quit.  You can also use this to perform the same task if MEM is specified.  Use the counter_field as the array specifier in the expression.


DISPEach time a record is read the program will redisplay the screen fields, if you specify this option.  This will slow down the operation of this command, with the amount of slow-down depending on how many fields are displayed on the screen.


NOTE : As of VER 7.1 Build 6 the buffer for import has been changed from 1022 and is now 2046.






//Example from cashbox pro

define import1_hndl type I

define RecCntr type R

         '@pbRecCount.Min' = 0

         // '@pbRecCount.Max' = 'The total number of record to inport'   

       set_object  get_Form_Name() property 'No_Refresh' value .t.  // this shuts off the sceen updat to help speet it up..

       datafile = GET_FILE('TXT','.\data','Get Wand Data','TXT files only (TXT)|*.TXT')

       if datafile = '' then ret 

       openv 'IMPORT1' fnum import1_hndl lock N type c

       import TEMP_MAC,TEMP_BOXOLD,TEMP_NEWBOX,TEMP_DATE from datafile type 'L' to @import1_hndl for ChkFilter() cntr  RecCntr 

        set_object  get_Form_Name() property 'No_Refresh' value .f.



func ChkFilter

 '@pbRecCount.Position' = RecCntr   // This updates my progress bar

    RET .t.


The above code was used to import data in this format.

     1234,12345,1101,dateand time string
     1234,12345,1101,dateand time string

     1234,12345,1101,dateand time string






Page url: