![]() ![]() ![]() ![]() | Table Of Contents | Index |
The easiest way to define these fields is to create a comma delimited text file and use ReadAscTextFile('FIELDS.TXT',Fields). This will create the array needed by BtrvCreate. The text file might look as follows:
Name,String,35,Key,DUP,MOD,UPPER,DEC CustomerNumber,Auto,Key From,String,35 Password,String,15 Access,Num Flags,String,10 FirstDate,Date LastDate,Date Calls,Num CallTime,Time Phone,String,15The above example creates a conventional fixed-length database with one key field, the "name" field. Each line in the definition file defines a new field. Each line has at least two parameters. The first parameter is the field name. It is followed by the field type. There are five legal field types. They are:Example:
Var Fields, FieldHandle ReadAscTextFile('FIELDS.TXT',Fields) BtrvCreate('BBSUSER.BTD',Fields) FileHandle = BtrvOpen('BBSUSER.BTD',Fields)
String - Contains alphanumeric strings. String fields have a required third parameter, the maximum length of the string. In the above example the "Name" and "From" fields both have max lengths of 35 characters.USING KEY FIELDSNum - Integer numeric fields. This field type supports storing integer numbers.
Date - Dates fields. The DOS country code is automatically supported to establish date format. If not specified, the default format is "MM/DD/YY".
Time - Time fields. This command also reads the DOS country code to establish the proper format. Otherwise default is "HH:MM:SS".
Auto - Auto increment field. This field is a numeric field that is filled in by Btrieve. If you pass a zero value, Btrieve will fill it in automatically with sequential unique numbers. The first record being one, the second record being two, etc. If records are deleted the numbers are not reused. If you pass a non-zero value that does not match any other record, Btrieve will accept that value. This feature can be used to provide unique record numbers.
Key fields are fields that are have internal lookup indexs automatically defined and maintained by the Btrieve system. If you want to use the indexed lookup `BtrvGet_____' series of commands then the field you reference must be a key field. You define a key field by adding the parameter "KEY" as the third parameter on the field definition line. When specifying a field as a key field you have four optional configuration parameters as seen in the previous example. They are:
DUP - {Duplicates} This permits the field to have duplicate values in multiple records. If this parameter is not specified then no two records may have the same value in the affected field. In reality, you will almost always specify this parameter when defining a key field.USING MARXMENU STYLE DATABASEMOD - {Modifiable} This allows existing existing field records to be modified. If this parameter is not specified then once a record is written, the affected field is set in stone and changes are not permitted.
UPPER- {UpperCase Only} Used in cunjunction with string fields only, this will force all text information to be sorted as UPPERCASE. This feature requires Btrieve 6.0 or later.
DEC - {Descending Order} This caused the key stored in the affected field to be maintained in reverse order.
If you wanted to use a MarxMenu-style database then only the first two lines of the above example need be in the file. This would create a file with two fixed-length key fields and put the rest of the fields in the variable-length section. Using the MarxMenu style you can pass anything you want for the rest of the fields.
Name,String,35,Key,DUP,MOD,UPPER,DEC CustomerNumber,Auto,KeyIn a MarxMenu-style database, you pass data to and from the file using MarxMenu-style array variables. The first fields of the array must match the key fields. But the rest of the fields can be anything you want. They can be multidimensional arrays. The fields do not have to be the same from one record to the next. Record number one can have five fields, where record number two can have twenty. After the key fields you can do anything you want.-------------------------------------- |Name|CustomerNumber|All Other Fields| -------------------------------------- ^ ^ ^ | | | Fixed Length --+----+ +--- Variable Length
Result Codes: 18 - Disk Full 49 - Key Type Error
Category: | Btrieve |
---|
![]() ![]() ![]() ![]() | Table Of Contents | Index |
|