.sch file -- what does it mean? 
Author Message
 .sch file -- what does it mean?

I notice that when exporting from PdoxWin 5.0 to comma-delimited ASCII, a
file with a .sch extension is created.  I have also determined that it
seems to be necessary for this file to be present for delphi to
successfully import a file using a TBatchMove component in Copy mode.

The problem is that the contents of a LongInt field are being placed in
the field after the longint if they are four or less characters in
length.  (Zero-padding the short numbers fixes the problem; however the
file is not available in this format.)

Can anyone explain to me what the last three parameters of the field
parameters in the .sch file mean, and is there a way of using the
TBatchMove to import without the .sch file?  Any other suggestions you
may have for a way to resolve this problem within Delphi would be
appreciated.

TIA.

a.j.
--
--------------------------------------------------------
Developer / Trainer:  Delphi / Pdoxwin



Sat, 07 Mar 1998 03:00:00 GMT  
 .sch file -- what does it mean?
: I notice that when exporting from PdoxWin 5.0 to comma-delimited ASCII, a
: file with a .sch extension is created.  I have also determined that it
: seems to be necessary for this file to be present for Delphi to
: successfully import a file using a TBatchMove component in Copy mode.

: The problem is that the contents of a LongInt field are being placed in
: the field after the longint if they are four or less characters in
: length.  (Zero-padding the short numbers fixes the problem; however the
: file is not available in this format.)

: Can anyone explain to me what the last three parameters of the field
: parameters in the .sch file mean, and is there a way of using the
: TBatchMove to import without the .sch file?  Any other suggestions you
: may have for a way to resolve this problem within Delphi would be
: appreciated.

I have included with this response a technical article I wrote on comma-
delimited ASCII tables. This article supplements the description of schema
files found in the text file ASCIIDRV.TXT, which can be found in the dir-
ectory \DELPHI\DOC.

I have not seen or heard of the specific problem you described. Consider
posting (here in the newsgroup) an example of the data that causes this
effect and the schema file.

Technical article follows...

Delphi (and the BDE) has the capability to use ASCII files to a limited
degree as tables. The ASCII driver has the capability to translate the
data values in an ASCII fixed-length field or a comma-delimted file into
fields and values that can be displayed through a TTable component. How
this translation of the ASCII file takes place depends on an accompanying
schema file. The schema file for an ASCII data file defines various attri-
butes necessary for parsing the ASCII data file into individual field
values. The field definitions for an ASCII fixed-length field file is
relatively straightforward, the offsets of various fields in the ASCII
file being consistent across all rows in the file. However, for comma-
delimited files, this process is slightly more complicated due to the
fact that not all data values in such a file may be the same length for
all rows in the file. This article, then, concentrates on this more
difficult task of reading data from comma-delimited, or varying-length
field, files.

The Schema File
===============

The schema file for an ASCII data file contains information that defines
both the file type (comma-delimited versus fixed-length field), as well as
defining the fields that are represented by the data values in each row of
the ASCII data file. (All of the settings used in a schema file are case
insensitive, so "ascii" is just as valid as "ASCII".) In order that a
schema file be recognized as such, it must have the same filename as the
ASCII data file for which it provides definitions, but with the filename
extension .SCH (for SCHema). The attributes that describe the file are:

  File name: Enclosed in square brackets, this setting specifies the
             name of the ASCII data file (sans the filename extension,
             which must be .TXT).

  Filetype:  Specifies whether the ASCII data file is structured as a
             fixed-length field file (use a setting of FIXED) or a comma-
             delimited file (with data values of potentially varying
             length (use a setting of VARYING).

  Delimiter: Specifies the character that surrounds String type data val-
             ues (typically, the double quotation mark, ASCII decimal 34).

  Separator: Specifies the character that is used to separate individual
             data values (typically, a comma). This character must be a
             visible character, i.e., cannot be a space (ASCII decimal
             32).

  CharSet:   Specifies the language driver (use a setting of ASCII).

Following the file definition settings are field definitions, one for each
data value on each row of the ASCII data file. These field definitions
supply the information Delphi and the BDE will need to create a virtual
field in memory to hold the data value, that virtual field's data type
which will affect how the value is translated after being read from the
ASCII file, and size and positioning attributes. The various settings that
will appear in each field definition are:

  Field:              Virtual field name, will always be "Field" followed
                      by an integer number representing that field's ord-
                      inal position in respect to the other fields in the
                      ASCII data file. E.G., the first field is Field1,
                      the second Field2, and so on.

  Field name:         Specifies the display name for the field, which
                      appears as the column header in a TDBGrid. Naming
                      convention for ASCII table fields follows that for
                      Paradox tables.

  Field type:         Specifies the data tyoe BDE is to use in translating
                      the data value for each field and tells Delphi what
                      type of virtual field to create.

                      Use the setting For values of type
                      --------------- ---------------------
                      CHAR            Character
                      FLOAT           64-bit floating point
                      NUMBER          16-bit integer
                      BOOL            Boolean (T or F)
                      LONGINT         32-bit long integer
                      DATE            Date field.
                      TIME            Time field.
                      TIMESTAMP       Date + Time field.

                      (The actual format for date and time data values
                      will be determined by the current setting in the BDE
                      configuration, Date tab page.)

  Data value length:  Maximum length of a field's corresponding data
                      value. This setting determines the length of the
                      virtual field that Delphi creates to receive values
                      read from the ASCII file.

  Number of decimals: Applicable to FLOAT type fields; specifies the
                      number of digit positions to the right of the deci-
                      mal place to include in the virtual field defini-
                      tion.

  Offset:             Offset from the left that represents the starting
                      position for the field in relation to all of the
                      fields that preceed it.

For example, the field definition below is for the first field in the
ASCII table. It defines a String type data value with a name of "Text",
a maximum data value length of three characters (and the field will
appear as only three characters long in Delphi data-aware components such
as the TDBGrid), no decimal places (a String data value will never have
any decimal places), and an offset of zero (because it is the first field
and there would not be any preceeding fields).

  Field1=Text,Char,3,00,00

Here is an example of a schema file with three fields, the first of String
type and the second and third of type date. This schema file would be
contained in a file named DATES.SCH to provide file and field definitions
for an ASCII data file named DATES.TXT.

  [DATES]
  Filetype=VARYING
  Delimiter="
  Separator=,
  CharSet=ascii
  Field1=Text,Char,3,00,00
  Field2=First Contact,Date,10,00,03
  Field3=Second,Date,10,00,13

This schema defines a comma-delimited field where all String type data
values can be recognized as being surrounded by the double quotation mark
and where distinct data values are separated by commas (excepting any
commas that may appear within the specified delimiter, inside individual
String data values). The character field has a length of three characters,
no decimal places, and an offset of zero. The first date field has a
length of 10, no decimals, and an offset of three. And the second date
field has a length of 10, no decimals, and an offset of 13.

For reading ASCII comma-delimited files, the length and offset parameters
for the field definitions do not apply to data values in the ASCII files
(as is the case for fixed-length field files), but to the virtual fields,
defined in the application, into which the values read will be placed. The
length parameter will need to reflect the maximum length of the data value
for each field -- not counting the delimiting quotation marks or the comma
separators. This is most difficult to estimate for String type data values
as the actual length of such a data value may vary greatly from row to row
in the ASCII data file. The offset parameter for each field will not be
the position of the data value in the ASCII file (as is the case for
fixed-length field files), but the offset as represented by the cumulative
length of all preceding fields (again, the defined fields in memory, not
the data values in the ASCII file.

Here is a data file that would correspond to the schema file described
above, in a file named DATES.TXT:

  "A",08/01/1995,08/11/1995
  "BB",08/02/1995,08/12/1995
  "CCC",08/03/1995,08/13/1995

The maximum length of an actual data value in the first field is three
("CCC"). because this is the first field and there are no preceding
fields, the offset for this field is zero. The length of this first field
(3) is used as the offset for the second field. The length of the second
field, a date value, is 10, reflecting the maximum length of a data value
for that field. The accumulated length of the first and second fields are
then used as the offset for the third field (3 + 10 = 13) .

It is only when the proper length for the data values in the ASCII file
are used and each fields length added to any preceding fields to produce
offset values for succeeding fields that this process will correctly read
the data. If data is misread ...

read more »



Sat, 07 Mar 1998 03:00:00 GMT  
 .sch file -- what does it mean?
I notice that when exporting from PdoxWin 5.0 to comma-delimited ASCII, a
file with a .sch extension is created.  I have also determined that it
seems to be necessary for this file to be present for Delphi to
successfully import a file using a TBatchMove component in Copy mode.

The problem is that the contents of a LongInt field are being placed in
the field after the longint if they are four or less characters in
length.  (Zero-padding the short numbers fixes the problem; however the
file is not available in this format.)

Can anyone explain to me what the last three parameters of the field
parameters in the .sch file mean, and is there a way of using the
TBatchMove to import without the .sch file?  Any other suggestions you
may have for a way to resolve this problem within Delphi would be
appreciated.

TIA.

a.j.
--
--------------------------------------------------------
Developer / Trainer:  Delphi / Pdoxwin

--
--------------------------------------------------------
Developer / Trainer:  Delphi / Pdoxwin



Sat, 07 Mar 1998 03:00:00 GMT  
 .sch file -- what does it mean?

Quote:

>I notice that when exporting from PdoxWin 5.0 to comma-delimited ASCII, a
>file with a .sch extension is created.  I have also determined that it
>seems to be necessary for this file to be present for Delphi to
>successfully import a file using a TBatchMove component in Copy mode.
>The problem is that the contents of a LongInt field are being placed in
>the field after the longint if they are four or less characters in
>length.  (Zero-padding the short numbers fixes the problem; however the
>file is not available in this format.)
>Can anyone explain to me what the last three parameters of the field
>parameters in the .sch file mean, and is there a way of using the
>TBatchMove to import without the .sch file?  Any other suggestions you
>may have for a way to resolve this problem within Delphi would be
>appreciated.

The information that you want is in two places.  There is some brief (and
not very complete) documentation in the file \DELPHI\DOC\ASCII-DRV.TXT
file that was installed with Delphi.  For a more complete explanation
see the technical document TI2844 (by Steve Koterski) available from
Borlands FTP site.  I HAD to have this file to get the ASCII database
driver to work.  As far as importing without the .sch file, I don't
think it's possible.  However, I don't consider myself an expert by any
means.

If you don't have FTP capabilities drop me an line and I'll email it to
you.

Mike Reith
---------------

Quote:
>TIA.
>a.j.
>--
>--------------------------------------------------------
>Developer / Trainer:  Delphi / Pdoxwin



Mon, 09 Mar 1998 03:00:00 GMT  
 .sch file -- what does it mean?

Quote:


>> >: The problem is that the contents of a LongInt field are being placed in
>> >: the field after the longint if they are four or less characters in
>> >: length.  (Zero-padding the short numbers fixes the problem; however the
>> >: file is not available in this format.)
>Could you turn the LongInt into a string in the source file,
>or read it into a string in the destination ?  The bug is caused
>by Delphi worrying about whether a comma is used to divide
>thousands from units or to seperate fields.

Thanks for the suggestion, but this did not work.  There are no commas, by
the way, in the source file, except between fields.
--
--------------------------------------------------------
Developer / Trainer:  Delphi / Pdoxwin


Tue, 10 Mar 1998 03:00:00 GMT  
 .sch file -- what does it mean?

Quote:
>>: The problem is that the contents of a LongInt field are being placed in
>>: the field after the longint if they are four or less characters in
>>: length.  (Zero-padding the short numbers fixes the problem; however the
>>: file is not available in this format.)

-- Snip --

Quote:

>>I have not seen or heard of the specific problem you described. Consider
>>posting (here in the newsgroup) an example of the data that causes this
>>effect and the schema file.

I have been battling a similar problem recently, and finally ended up
doing the import "by hand", which turned out to be pretty easy.  So I
made a component.  The component still needs some debugging, and is not
exactly a masterpiece -- I'm not using the BDE to do it or anything
interesting like that, but it gets the job done.  When I get some of its
rough edges smoothed out, I'll post it here and try to find a web or ftp
site for it somewhere.  Any comments on the subject (what
should a comma-delimited ascii-importing component *do* (other than the
obvious), and what should it not do) would be appreciated...

Maggie ;
--
uses objectPAL
  userDrinkMoreCoffee!(var size ounces)
enduses



Tue, 10 Mar 1998 03:00:00 GMT  
 .sch file -- what does it mean?


: : I notice that when exporting from PdoxWin 5.0 to comma-delimited ASCII, a
: : file with a .sch extension is created.  I have also determined that it
: : seems to be necessary for this file to be present for Delphi to
: : successfully import a file using a TBatchMove component in Copy mode.

[snip]

: I wonder if ANYONE reads the README files included with Delphi?

: The *.SCH files are described in the ASCIIDRV.TXT file, as are all the
: questions raised here.

Perhaps I was a little TOO fast in declaring "all questions" will be
answered, but here is the file in question.  It is found in

X:\DELPHI\DOC\ASCIIDRV.TXT

[include starts]

Using ASCII Tables with Delphi
-------------------------------
Delphi supports using ASCII text files as tables, with limited
functionality.  ASCII tables are intended for exporting
and importing data to and from other formats--in general, they are
not recommended for use as data sources for applications.

Each ASCII table requires a data file (generally with .TXT
extension) and a schema file (with the same base file name
and .SCH extension). The schema file contains information about
the structure of the table and the datatypes of its columns (fields).  

ASCII tables are always opened for exclusive access.  In other
words, no more than one application (session) can access an
ASCII table at one time.  If you have opened an ASCII table at
design time, you must close it before running your application
that opens the table at run time.

Copying a table to ASCII format with Database Desktop or a TBatchmove
component will automatically create a schema file as well as the
ASCII data file.  ASCII tables are always created with FIXED filetype.
When creating an ASCII table with Delphi (for example with BatchMove
or CreateTable methods), you must specify TableType as ttASCII.  You
should not leave TableType as ttDefault.

ASCII tables do not support the following:
* Indexes (and therefore, any methods or functions that require an
  index, such as GoToKey, SetRange, etc.)
* TQuery components (SQL)
* Deleting records
* Inserting records.  Insert always appends the record to the end
  of the table.
* Referential Integrity
* Blob datatypes
* DELIMITED tables do not allow modification (editing) of records

The Schema File
---------------
All information in the schema file is case-insensitive.
Here is a sample of what a schema file looks like:

[CUSTOMER]                      // File name with no extension.
FILETYPE = VARYING              // Format: VARYING or FIXED
CHARSET = ascii                 // Language driver name.
DELIMITER = "                      // Delimiter for char fields.
SEPARATOR = ,                   // Separator character
Field1 = Name,CHAR,12,0,0       // Field information
Field2 = Salary,FLOAT,8,2,12    

The schema file has a format similar to Windows INI files.
The file begins with the name of the table in brackets.
The second line specifies the file format following the
keyword FILETYPE: FIXED or VARYING.
* In a FIXED format file, each field always takes up a fixed
  number of characters in the file, and the data is padded with
  blanks as needed.
* In a VARYING file, each field takes a variable number of characters,
  each character field is enclosed by DELIMITER characters, and the
  fields are separated by a SEPARATOR character.  The DELIMITER and
  SEPARATOR must be specified for a VARYING format file, but
  not for a FIXED format file.

The CHARSET attribute specifies the name of the language
driver to use.  This is the base file name of the .LD
file used for localization purposes.

The remaining lines specify the attributes of the table's
fields (columns). Each line must begin with "Fieldx = ",
where x is the field number (i.e. Field1, Field2, and so on).
Then comes a comma-delimited list specifying:
* Field name - Same restrictions as Paradox field names.
* Datatype - The field data type.  See below.
* Number of characters or units.  Must be <= 20 for numeric
  data types.  Total maximum number of characters for date/time
  datatypes (including / and : separators).
* Number of digits after the decimal (FLOAT only).
* Offset - Number of characters from the beginning of the line
  that the field begins.  Used for FIXED format only.

The following data types are supported:
CHAR - Character
FLOAT - 64-bit floating point
NUMBER - 16-bit integer
BOOL - Boolean (T or F)
LONGINT - 32-bit long integer
DATE - Date field.  Format specified by IDAPI.CFG
TIME - Time field. Format specified by IDAPI.CFG
TIMESTAMP - Date + Time field. Format specified by IDAPI.CFG

NOTE: You can specify Date and time formats in the BDE configuration
utility  

Example 1 - VARYING format file
-------------------------------
CUSTOMER.SCH:

[CUSTOMER]
Filetype=VARYING
Delimiter="
Separator=,
CharSet=ascii
Field1=Customer No,Float,20,04,00
Field2=Name,Char,30,00,20
Field3=Phone,Char,15,00,145
Field4=First Contact,Date,11,00,160

CUSTOMER.TXT:

1221.0000,"Kauai Dive Shoppe","808-555-0269",04/03/1994
1231.0000,"Unisco","809-555-3915",02/28/1994
1351.0000,"Sight Diver","357-6-876708",04/12/1994
1354.0000,"Cayman Divers World Unlimited","809-555-8576",04/17/1994
1356.0000,"Tom Sawyer Diving Centre","809-555-7281",04/20/1994

Example 2 - FIXED format file
-----------------------------
CUSTOMER.SCH:

[CUSTOMER]
Filetype=Fixed
CharSet=ascii
Field1=Customer No,Float,20,04,00
Field2=Name,Char,30,00,20
Field3=Phone,Char,15,00,145
Field4=First Contact,Date,08,00,160

CUSTOMER.TXT:

           1221.0000Kauai Dive Shoppe             808-555-0269   04/03/94
           1231.0000Unisco                        809-555-3915   02/28/94
           1351.0000Sight Diver                   357-6-876708   04/12/94
           1354.0000Cayman Divers World Unlimited 809-555-8576   04/17/94
           1356.0000Tom Sawyer Diving Centre      809-555-7281   04/20/94

--
=========================================================================
Kasey K. S. Chang (a guy)             | Paradox for Windows Programmer

URL> http://userwww.sfsu.edu/~kschang | X-COM Guru   General PC expert
--------------------------------------+----------------------------------
Editor of XCOM and XCOM2 UN-official Strategy Guide -- FREE!  (See URL)



Thu, 12 Mar 1998 03:00:00 GMT  
 
 [ 7 post ] 

 Relevant Pages 

1. Delphi *.hlp files still not done

2. What does it mean

3. What does this BDE-Error mean ???

4. does that mean..

5. cdx indexes, what does the error mean?

6. I need Help (fast) and i mean fast...

7. What do these statements mean?

8. Table level changed... what does this mean

9. Data structure corruption - What does it mean ?

10. i mean get not steal tp 5.5,sorry.

11. WATH DOES "FAQ" MEANS

12. Meaning of ERROR 204.

 

 
Powered by phpBB® Forum Software