home *** CD-ROM | disk | FTP | other *** search
/ PC Format Collection 48 / SENT14D.ISO / tech / delphi / disk15 / inttab.pak / ASCIIDRV.TXT next >
Encoding:
Text File  |  1995-08-24  |  5.2 KB  |  133 lines

  1. Using ASCII Tables with Delphi
  2. -------------------------------
  3. Delphi supports using ASCII text files as tables, with limited 
  4. functionality.  ASCII tables are intended for exporting
  5. and importing data to and from other formats--in general, they are 
  6. not recommended for use as data sources for applications.
  7.  
  8. Each ASCII table requires a data file (generally with .TXT 
  9. extension) and a schema file (with the same base file name 
  10. and .SCH extension). The schema file contains information about 
  11. the structure of the table and the datatypes of its columns (fields).  
  12.  
  13. ASCII tables are always opened for exclusive access.  In other
  14. words, no more than one application (session) can access an 
  15. ASCII table at one time.  If you have opened an ASCII table at
  16. design time, you must close it before running your application
  17. that opens the table at run time.
  18.  
  19. Copying a table to ASCII format with Database Desktop or a TBatchmove
  20. component will automatically create a schema file as well as the 
  21. ASCII data file.  ASCII tables are always created with FIXED filetype.
  22. When creating an ASCII table with Delphi (for example with BatchMove 
  23. or CreateTable methods), you must specify TableType as ttASCII.  You 
  24. should not leave TableType as ttDefault.
  25.  
  26. ASCII tables do not support the following:
  27. * Indexes (and therefore, any methods or functions that require an
  28.   index, such as GoToKey, SetRange, etc.)
  29. * TQuery components (SQL)
  30. * Deleting records
  31. * Inserting records.  Insert always appends the record to the end 
  32.   of the table.
  33. * Referential Integrity
  34. * Blob datatypes
  35. * DELIMITED tables do not allow modification (editing) of records
  36.  
  37. The Schema File
  38. ---------------
  39. All information in the schema file is case-insensitive.
  40. Here is a sample of what a schema file looks like:
  41.  
  42. [CUSTOMER]                    // File name with no extension.
  43. FILETYPE = VARYING         // Format: VARYING or FIXED
  44. CHARSET = ascii            // Language driver name.
  45. DELIMITER = "                // Delimiter for char fields.
  46. SEPARATOR = ,                 // Separator character 
  47. Field1 = Name,CHAR,12,0,0    // Field information
  48. Field2 = Salary,FLOAT,8,2,12     
  49.  
  50. The schema file has a format similar to Windows INI files.
  51. The file begins with the name of the table in brackets.
  52. The second line specifies the file format following the 
  53. keyword FILETYPE: FIXED or VARYING.
  54. * In a FIXED format file, each field always takes up a fixed
  55.   number of characters in the file, and the data is padded with
  56.   blanks as needed. 
  57. * In a VARYING file, each field takes a variable number of characters,
  58.   each character field is enclosed by DELIMITER characters, and the 
  59.   fields are separated by a SEPARATOR character.  The DELIMITER and 
  60.   SEPARATOR must be specified for a VARYING format file, but
  61.   not for a FIXED format file.
  62.  
  63. The CHARSET attribute specifies the name of the language
  64. driver to use.  This is the base file name of the .LD
  65. file used for localization purposes.
  66.  
  67. The remaining lines specify the attributes of the table's 
  68. fields (columns). Each line must begin with "Fieldx = ", 
  69. where x is the field number (i.e. Field1, Field2, and so on).
  70. Then comes a comma-delimited list specifying:
  71. * Field name - Same restrictions as Paradox field names.
  72. * Datatype - The field data type.  See below.
  73. * Number of characters or units.  Must be <= 20 for numeric
  74.   data types.  Total maximum number of characters for date/time 
  75.   datatypes (including / and : separators).
  76. * Number of digits after the decimal (FLOAT only).
  77. * Offset - Number of characters from the beginning of the line
  78.   that the field begins.  Used for FIXED format only.
  79.  
  80. The following data types are supported:
  81. CHAR - Character
  82. FLOAT - 64-bit floating point
  83. NUMBER - 16-bit integer
  84. BOOL - Boolean (T or F)
  85. LONGINT - 32-bit long integer
  86. DATE - Date field.  Format specified by IDAPI.CFG
  87. TIME - Time field. Format specified by IDAPI.CFG
  88. TIMESTAMP - Date + Time field. Format specified by IDAPI.CFG
  89.  
  90. NOTE: You can specify Date and time formats in the BDE configuration 
  91. utility  
  92.  
  93. Example 1 - VARYING format file 
  94. -------------------------------
  95. CUSTOMER.SCH:
  96.  
  97. [CUSTOMER]
  98. Filetype=VARYING
  99. Delimiter="
  100. Separator=,
  101. CharSet=ascii
  102. Field1=Customer No,Float,20,04,00
  103. Field2=Name,Char,30,00,20
  104. Field3=Phone,Char,15,00,145
  105. Field4=First Contact,Date,11,00,160
  106.  
  107. CUSTOMER.TXT:
  108.  
  109. 1221.0000,"Kauai Dive Shoppe","808-555-0269",04/03/1994
  110. 1231.0000,"Unisco","809-555-3915",02/28/1994
  111. 1351.0000,"Sight Diver","357-6-876708",04/12/1994
  112. 1354.0000,"Cayman Divers World Unlimited","809-555-8576",04/17/1994
  113. 1356.0000,"Tom Sawyer Diving Centre","809-555-7281",04/20/1994
  114.  
  115. Example 2 - FIXED format file
  116. -----------------------------
  117. CUSTOMER.SCH:
  118.  
  119. [CUSTOMER]
  120. Filetype=Fixed
  121. CharSet=ascii
  122. Field1=Customer No,Float,20,04,00
  123. Field2=Name,Char,30,00,20
  124. Field3=Phone,Char,15,00,145
  125. Field4=First Contact,Date,08,00,160
  126.  
  127. CUSTOMER.TXT:
  128.  
  129.            1221.0000Kauai Dive Shoppe             808-555-0269   04/03/94
  130.            1231.0000Unisco                        809-555-3915   02/28/94
  131.            1351.0000Sight Diver                   357-6-876708   04/12/94
  132.            1354.0000Cayman Divers World Unlimited 809-555-8576   04/17/94
  133.            1356.0000Tom Sawyer Diving Centre      809-555-7281   04/20/94