1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
|
<!DOCTYPE xbHtml PUBLIC>
<xbHtml>
<TITLE>Xbase DBMS Chapter 12</TITLE>
<BODY BGCOLOR=#FFFFFF>
<H1><p align="center">Database Methods</p></H1>
<p align="center">Chapter Updated 1/30/99</p><hr>
<br>
This chapter lists the database methods and provides links to examples of how
to use them.<br><br><br>
<TABLE BORDER>
<CAPTION ALIGN="TOP"><h3>Xbase Database Method List</h3></CAPTION>
<TR VALIGN="BASELINE">
<TR><TH ALIGN="LEFT">Method<TD>Description
<TR><TH ALIGN="LEFT">xbShort rc AppendRecord()<TD>Append a new record to the end of an open database
<TR><TH ALIGN="LEFT">void AutoLockOn()<TD>Turns on automatic record locking (see locking chapter)
<TR><TH ALIGN="LEFT">void AutoLockOff()<TD>Turns off automatic record locking (see locking chapter)
<TR><TH ALIGN="LEFT">void BlankRecord()<TD>Fill the current record buffer with blanks
<TR><TH ALIGN="LEFT">xbLong csum CalcCheckSum()<TD>Calculate checksum on a data record
<TR><TH ALIGN="LEFT">xbShort rc CloseDatabase()<TD>Close an open database
<TR><TH ALIGN="LEFT">xbShort rc CopyDbfStructure(<br> char * NewFileName,<br>
xbShort OverlaySwitch )<TD>Copies the structure of a xbDbf file to a new file
<TR><TH ALIGN="LEFT">xbShort rc CreateDatabase(<br>char * FileName,
XbSchema *s, xbShort OverlaySwitch )<TD>Close an open database
<TR><TH ALIGN="LEFT">xbULong CurrentRecNo()<TD>Returns the current record number
<TR><TH ALIGN="LEFT">xbShort rc DeleteAllRecords()<TD>Mark all records for deletion
<TR><TH ALIGN="LEFT">xbShort rc DeleteRecord()<TD>Mark a record for deletion
<TR><TH ALIGN="LEFT">xbShort rc DumpHeader(xbShort option)<TD>Display information about a .DBF file header
<TR><TH ALIGN="LEFT">xbShort rc DumpRecord(<br>xbULong RecNo)<TD>Dump a record for a database
<TR><TH ALIGN="LEFT">xbLong cnt FieldCount()<TD>Returns number of fields in database
<TR><TH ALIGN="LEFT">xbLong recno GetCurRecNo()<TD>Returns current record number
<TR><TH ALIGN="LEFT">xbShort rc GetFirstRecord()<TD>Get the first record in the database
<TR><TH ALIGN="LEFT">xbShort rc GetLastRecord()<TD>Get the last record in the database
<TR><TH ALIGN="LEFT">xbShort rc GetNextRecord()<TD>Get the next record in the database
<TR><TH ALIGN="LEFT">xbShort rc GetPrevRecord()<TD>Get the previous record in the database
<TR><TH ALIGN="LEFT">xbShort rc GetRecord(xbLong RecNo)<TD>Get a record by record number from an open database
<TR><TH ALIGN="LEFT">char * buf GetRecordBuf()<TD>Returns a pointer to the record buffer
<TR><TH ALIGN="LEFT">xbLong RecCnt NoOfRecords()<TD>Returns the number of records in an open database
<TR><TH ALIGN="LEFT">xbShort rc OpenDatabase(char * FileName)<TD>Open an existing database
<TR><TH ALIGN="LEFT">xbShort rc PackDatabase(<br>xbShort WaitOption)<TD>Compress file and remove deleted records
<TR><TH ALIGN="LEFT">xbShort rc PutRecord(xbULong RecNo)<TD>Put a record in an open database
<TR><TH ALIGN="LEFT">xbShort rc RebuildAllIndices()<TD>Rebuilds all open indices
<TR><TH ALIGN="LEFT">xbShort dflag RecordDeleted()<TD>Determine if a record has been deleted
<TR><TH ALIGN="LEFT">xbShort version SetVersion(xbShort Ver)<TD>Set version to xbase III+ or IV style xbDbf files
<TR><TH ALIGN="LEFT">xbShort rc UndeleteAllRecords()<TD>Unmark all deleted records
<TR><TH ALIGN="LEFT">xbShort rc UndeleteRecord()<TD>Unmark a deleted record
<TR><TH ALIGN="LEFT">xbShort rc Zap(xbShort WaitOption)<TD>Deletes all records from a database
</TABLE>
<BR><BR><hr>
<h2>Method Definitions</h2>
<hr>
<h3>Method xbShort xbDbf::AppendRecord( void )</h3><br>
This method appends the contents of the database record buffer to the end of
the .DBF file and updates the date and number of records in the header of the
datafile.<br><br>
This method also updates any open indexes associated with the database.<br><br>
<TABLE BORDER>
<CAPTION ALIGN="TOP"><h3>Method Return Codes</h3></CAPTION><br>
<TR VALIGN="BASELINE">
<TR><TH ALIGN="LEFT">Return Code<TD>Description
<TR><TH ALIGN="LEFT">XB_LOCK_FAILED<TD>Write lock not successful
<TR><TH ALIGN="LEFT">XB_NO_ERROR<TD>If there is no error
<TR><TH ALIGN="LEFT">XB_WRITE_ERROR<TD>Unsuccessful write operation
</TABLE>
<h4>Example Program:</h4>
See program <A HREF="/XbaseSamples/sample2.cpp">sample2.cpp</A> for an example
of how to use this method.
<hr>
<h3>Method xbShort xbDbf::BlankRecord( void )</h3><br>
This method overlays the database record buffer with space (0x20)
CHARacters. This method is useful for initializing the record buffer.<br>
<h4>Example Program:</h4>
See program <A HREF="/XbaseSamples/sample2.cpp">sample2.cpp</A> for an example of
how to use this method.
<hr>
<h3>Method xbLong xbDbf::CalcCheckSum( void )</h3><br>
This method calculates the checksum of a database record.
<hr>
<h3>Method xbShort xbDbf::CloseDatabase( void )</h3><br>
This method closes an Xbase (.DBF) file
which was previously opened by CreateDatabase or OpenDatabase
and frees any previously allocated memory which is no LONGer needed.<br><br>
This method automatically closes any open indexes associated with the
database before closing the database.<br><br>
<TABLE BORDER>
<CAPTION ALIGN="TOP"><h3>Method Return Codes</h3></CAPTION><br>
<TR VALIGN="BASELINE">
<TR><TH ALIGN="LEFT">Return Code<TD>Description
<TR><TH ALIGN="LEFT">XB_NO_ERROR<TD>If there is no error
<TR><TH ALIGN="LEFT">XB_NOT_OPEN<TD>If there is no error
</TABLE>
<h4>Example Program:</h4>
See program <A HREF="/XbaseSamples/sample2.cpp">sample2.cpp</A> for an example
of how to use this method.
<hr>
<h3>Method xbShort xbDbf::CopyDbfStructure( char *NewFileName, xbShort OverLay )</h3><br>
This method copies the structure of an Xbase (.DBF) file to file <em>NewFileName</em>.
If there are memo fields, they are included.
<br><br>
The <em>OverLay</em> switch is
used to determine what to do if a xbDbf file with the same name
already exists. If <em>OverLay</em> is set to XB_OVERLAY and the file exists,
the file is overwritten, otherwise an error is returned.<br><br>
<em>Overlay Switch</em> is:<br>
<li>XB_OVERLAY = Overlay file if it exists<br>
<li>XB_DONTOVERLAY = Return with error if file exists<br><br>
<TABLE BORDER>
<CAPTION ALIGN="TOP"><h3>Method Return Codes</h3></CAPTION><br>
<TR VALIGN="BASELINE">
<TR><TH ALIGN="LEFT">Return Code<TD>Description
<TR><TH ALIGN="LEFT">XB_NO_ERROR<TD>If there is no error
<TR><TH ALIGN="LEFT">XB_FILE_EXISTS<TD>If a file exists and OverLay switch = FALSE
<TR><TH ALIGN="LEFT">XB_OPEN_ERROR<TD>Couldn't open the file
<TR><TH ALIGN="LEFT">XB_NO_MEMORY<TD>Memory allocation error
<TR><TH ALIGN="LEFT">XB_WRITE_ERROR<TD>Couldn't write to disk
<TR><TH ALIGN="LEFT">XB_SEEK_ERROR<TD>Seek routine error
</TABLE>
<h4>Example Program:</h4>
See program <A HREF="/XbaseSamples/copydbf.cpp">copydbf.cpp</A> for an example
of how to use this method.
<hr>
<h3>Method: xbShort xbDbf::CreateDatabase( char *FileName,
xbSchema *s, xbShort OverLay )</h3><br>
This method creates an Xbase (.DBF) file with the name
of FileName and builds the header record with the format as
defined in the <em>xbSchema</em> parameter. The <em>OverLay</em> switch is
used to determine what to do if a xbDbf file with the same name
already exists. If <em>OverLay</em> is set to XB_OVERLAY and the file exists,
the file is overwritten, otherwise an error is returned.<br><br>
<em>Overlay Switch</em> is:<br>
<li>XB_OVERLAY = Overlay file if it exists<br>
<li>XB_DONTOVERLAY = Return with error if file exists<br><br>
<em>xbSchema</em> has the following format:<br>
<xmp>
xbSchema MyRecordSchema[] =
{
{ FieldName, Type, FieldLength, NoOfDecimals },
{ FieldName2, Type, FieldLength, NoOfDecimals },
...
{ "",0,0,0 }
};
</xmp>
Where:<br>
<li><em>FieldName</em> is the name of the data field.<br>
<li><em>Type</em><br><br>
<h4>Version 1.7.4 and greater:</h4>
XB_CHAR_FLD or C<br>
XB_DATE_FLD or D<br>
XB_LOGICAL_FLD or L<br>
XB_MEMO_FLD or M<br>
XB_FLOAT_FLD or F<br>
XB_NUMERIC_FLD or N<br><br>
<li><em>FieldLength</em> is the length of the field.<br>
<li><em>NoOfDecimals</em> is the number of decimals for NUMERIC fields.<br>
<br>
The record buffer is automatically set to spaces when this method is called.
<br><br>
<TABLE BORDER>
<CAPTION ALIGN="TOP"><h3>Method Return Codes</h3></CAPTION><br>
<TR VALIGN="BASELINE">
<TR><TH ALIGN="LEFT">Return Code<TD>Description
<TR><TH ALIGN="LEFT">XB_NO_ERROR<TD>If there is no error
<TR><TH ALIGN="LEFT">XB_FILE_EXISTS<TD>If a file exists and OverLay switch = FALSE
<TR><TH ALIGN="LEFT">XB_OPEN_ERROR<TD>Couldn't open the file
<TR><TH ALIGN="LEFT">XB_NO_MEMORY<TD>Memory allocation error
<TR><TH ALIGN="LEFT">XB_WRITE_ERROR<TD>Couldn't write to disk
</TABLE>
<h4>Example Program:</h4>
See program <A HREF="/XbaseSamples/sample1.cpp">sample1.cpp</A> for an example
of how to use this method.
<hr>
<h3>Method xbULong xbDbf::CurrentRecNo( void )</h3><br>
This method returns the current record number.<br><br>
<h4>Example Program:</h4>
See program <A HREF="/XbaseSamples/dumprecs.cpp">dumprecs.cpp</A> for an example
of how to use this method.
<hr>
<h3>Method xbShort xbDbf::DeleteAllRecords( void )</h3><br>
This method marks all unmarked records in the database for deletion.<br><br>
<TABLE BORDER>
<CAPTION ALIGN="TOP"><h3>Method Return Codes</h3></CAPTION><br>
<TR VALIGN="BASELINE">
<TR><TH ALIGN="LEFT">Return Code<TD>Description
<TR><TH ALIGN="LEFT">XB_NO_ERROR<TD>No error encountered
<TR><TH ALIGN="LEFT">XB_INVALID_RECORD<TD>Could not mark record
<TR><TH ALIGN="LEFT">XB_NOT_OPEN<TD>If the file is not open
<TR><TH ALIGN="LEFT">XB_SEEK_ERROR<TD>Seek routine error
<TR><TH ALIGN="LEFT">XB_WRITE_ERROR<TD>Write routine error
</TABLE>
<h4>Example Program:</h4>
See program <A HREF="/XbaseSamples/deletall.cpp">deletall.cpp</A> for an example
of how to use this method.
<hr>
<h3>Method xbShort xbDbf::DeleteRecord( void )</h3><br>
This method marks the current record for deletion in the database.<br><br>
<TABLE BORDER>
<CAPTION ALIGN="TOP"><h3>Method Return Codes</h3></CAPTION><br>
<TR VALIGN="BASELINE">
<TR><TH ALIGN="LEFT">Return Code<TD>Description
<TR><TH ALIGN="LEFT">XB_NO_ERROR<TD>No error encountered
<TR><TH ALIGN="LEFT">XB_INVALID_RECORD<TD>Could not mark record
</TABLE>
<h4>Example Program:</h4>
See program <A HREF="/XbaseSamples/sample4.cpp">sample4.cpp</A> for an example
of how to use this method.
<hr>
<h3>Method xbShort xbDbf::DumpHeader( xbShort Option )</h3><br>
This method displays information about a .DBF file header to stdout.
This method is only available if the DEBUG option is turned on in the
<em>options.h</em> file<br><br>
<TABLE BORDER>
<CAPTION ALIGN="TOP"><h3>Method Options</h3></CAPTION><br>
<TR VALIGN="BASELINE">
<TR><TH ALIGN="LEFT">Option<TD>Action
<TR><TH ALIGN="LEFT">1<TD>Print Header Only
<TR><TH ALIGN="LEFT">2<TD>Field Data Only
<TR><TH ALIGN="LEFT">3<TD>Header and Field Data
</TABLE>
<br>
<TABLE BORDER>
<CAPTION ALIGN="TOP"><h3>Method Return Codes</h3></CAPTION><br>
<TR VALIGN="BASELINE">
<TR><TH ALIGN="LEFT">Return Code<TD>Description
<TR><TH ALIGN="LEFT">XB_INVALID_OPTION<TD>Option must be 1,2 or 3
<TR><TH ALIGN="LEFT">XB_NOT_OPEN<TD>File is not open
<TR><TH ALIGN="LEFT">XB_NO_ERROR<TD>No error encountered
</TABLE>
<br>
<h4>Example Program:</h4>
See program <A HREF="/XbaseSamples/dumphdr.cpp">dumphdr.cpp</A> for an
example of how to use this method.
<hr>
<h3>Method xbShort xbDbf::DumpRecord( xbULong RecNo )</h3><br>
This method dumps record RecNo for the database to stdout.<br><br>
<TABLE BORDER>
<CAPTION ALIGN="TOP"><h3>Method Return Codes</h3></CAPTION><br>
<TR VALIGN="BASELINE">
<TR><TH ALIGN="LEFT">Return Code<TD>Description
<TR><TH ALIGN="LEFT">XB_NO_ERROR<TD>No error encountered
<TR><TH ALIGN="LEFT">XB_INVALID_RECORD<TD>Invalid record for RecNo parameter
</TABLE>
<h4>Example Program:</h4>
See program <A HREF="/XbaseSamples/dumprecs.cpp">dumprecs.cpp</A> for an
example of how to use this method.
<hr>
<h3>Method xbLong xbDbf::FieldCount( void )</h3><br>
This method returns the number of fields defined in the database.
<br><br>
<hr>
<h3>Method xbLong xbDbf::GetCurRecNo( void )</h3><br>
This method returns the current record number of the record in the record buffer.
<br><br>
<h4>Example Program:</h4>
See program <A HREF="/XbaseSamples/sample3.cpp">sample3.cpp</A> for an
example of how to use this method.
<hr>
<h3>Method xbShort xbDbf::GetFirstRecord( void )</h3><br>
This method loads the first record of the file into the record buffer.<br><br>
<TABLE BORDER>
<CAPTION ALIGN="TOP"><h3>Method Return Codes</h3></CAPTION><br>
<TR VALIGN="BASELINE">
<TR><TH ALIGN="LEFT">Return Code<TD>Description
<TR><TH ALIGN="LEFT">XB_NO_ERROR<TD>If there is no error
<TR><TH ALIGN="LEFT">XB_INVALID_RECORD<TD>Invalid record number
<TR><TH ALIGN="LEFT">XB_LOCK_FAILED<TD>Unsuccessful lock operation
<TR><TH ALIGN="LEFT">XB_NOT_OPEN<TD>If the file is not open
<TR><TH ALIGN="LEFT">XB_SEEK_ERROR<TD>Seek routine error
<TR><TH ALIGN="LEFT">XB_WRITE_ERROR<TD>Write routine error
</TABLE>
<h4>Example Program:</h4>
See program <A HREF="/XbaseSamples/sample3.cpp">sample3.cpp</A> for an
example of how to use this method.
<hr>
<h3>Method xbShort xbDbf::GetLastRecord( void )</h3><br>
This method loads the last record of the file into the record buffer.<br><br>
<TABLE BORDER>
<CAPTION ALIGN="TOP"><h3>Method Return Codes</h3></CAPTION><br>
<TR VALIGN="BASELINE">
<TR><TH ALIGN="LEFT">Return Code<TD>Description
<TR><TH ALIGN="LEFT">XB_LOCK_FAILED<TD>Read lock not successful
<TR><TH ALIGN="LEFT">XB_NO_ERROR<TD>If there is no error
<TR><TH ALIGN="LEFT">XB_EOF<TD>At end of file
<TR><TH ALIGN="LEFT">XB_NOT_OPEN<TD>If the file is not open
<TR><TH ALIGN="LEFT">XB_INVALID_RECORD<TD>Invalid record number
<TR><TH ALIGN="LEFT">XB_SEEK_ERROR<TD>Seek routine error
<TR><TH ALIGN="LEFT">XB_WRITE_ERROR<TD>Write routine error
</TABLE>
<h4>Example Program:</h4>
See program <A HREF="/XbaseSamples/sample3.cpp">sample3.cpp</A> for an example
of how to use this method.
<hr>
<h3>Method xbShort xbDbf::GetNextRecord( void )</h3><br>
This method loads the next record of the file into the record buffer.<br><br>
<TABLE BORDER>
<CAPTION ALIGN="TOP"><h3>Method Return Codes</h3></CAPTION><br>
<TR VALIGN="BASELINE">
<TR><TH ALIGN="LEFT">Return Code<TD>Description
<TR><TH ALIGN="LEFT">XB_LOCK_FAILED<TD>Read lock not successful
<TR><TH ALIGN="LEFT">XB_NO_ERROR<TD>If there is no error
<TR><TH ALIGN="LEFT">XB_EOF<TD>At end of file
<TR><TH ALIGN="LEFT">XB_NOT_OPEN<TD>If the file is not open
<TR><TH ALIGN="LEFT">XB_INVALID_RECORD<TD>Invalid record number
<TR><TH ALIGN="LEFT">XB_SEEK_ERROR<TD>Seek routine error
<TR><TH ALIGN="LEFT">XB_WRITE_ERROR<TD>Write routine error
</TABLE>
</TABLE>
<h4>Example Program:</h4>
See program <A HREF="/XbaseSamples/sample3.cpp">sample3.cpp</A> for an
example of how to use this method.
<hr>
<h3>Method xbShort xbDbf::GetPrevRecord( void )</h3><br>
This method loads the previous record of the file into the record buffer.<br><br>
<TABLE BORDER>
<CAPTION ALIGN="TOP"><h3>Method Return Codes</h3></CAPTION><br>
<TR VALIGN="BASELINE">
<TR><TH ALIGN="LEFT">Return Code<TD>Description
<TR><TH ALIGN="LEFT">XB_LOCK_FAILED<TD>Read lock not successful
<TR><TH ALIGN="LEFT">XB_NO_ERROR<TD>If there is no error
<TR><TH ALIGN="LEFT">XB_BOF<TD>At beginning of file
<TR><TH ALIGN="LEFT">XB_NOT_OPEN<TD>If the file is not open
<TR><TH ALIGN="LEFT">XB_INVALID_RECORD<TD>Invalid record number
<TR><TH ALIGN="LEFT">XB_SEEK_ERROR<TD>Seek routine error
<TR><TH ALIGN="LEFT">XB_WRITE_ERROR<TD>Write routine error
</TABLE>
<h4>Example Program:</h4>
See program <A HREF="/XbaseSamples/sample3.cpp">sample3.cpp</A> for an
example of how to use this method.
<hr>
<h3>Method xbShort xbDbf::GetRecord( xbLong RecNo )</h3><br>
This method retrieves record RecNo from the database into the record buffer.
<br><br>
This method will call the PutRec method and flush all updates to disk if
necessary before moving to the specified record. If PutRecord is not
successful, this method will return the return code from PutRecord.<br><br>
<TABLE BORDER>
<CAPTION ALIGN="TOP"><h3>Method Return Codes</h3></CAPTION><br>
<TR VALIGN="BASELINE">
<TR><TH ALIGN="LEFT">Return Code<TD>Description
<TR><TH ALIGN="LEFT">XB_LOCK_FAILED<TD>Read lock not successful
<TR><TH ALIGN="LEFT">XB_NO_ERROR<TD>If there is no error
<TR><TH ALIGN="LEFT">XB_NOT_OPEN<TD>If the file is not open
<TR><TH ALIGN="LEFT">XB_INVALID_RECORD<TD>Invalid record number
<TR><TH ALIGN="LEFT">XB_SEEK_ERROR<TD>Seek routine error
<TR><TH ALIGN="LEFT">XB_WRITE_ERROR<TD>Write routine error
</TABLE>
<h4>Example Program:</h4>
See program <A HREF="/XbaseSamples/sample3.cpp">sample3.cpp</A> for an
example of how to use this method.
<hr>
<h3>Method char * xbDbf::GetRecordBuf( void )</h3><br>
This method returns a pointer to the record buffer.
<br><br>
<h4>Example Program:</h4>
See program <A HREF="/XbaseSamples/sample3.cpp">sample3.cpp</A> for an
example of how to use this method.
<hr>
<h3>Method xbLong xbDbf::NoOfRecords( void )</h3><br>
This method returns the number of records in the file.<br><br>
<h4>Example Program:</h4>
See program <A HREF="/XbaseSamples/sample3.cpp">sample3.cpp</A> for an
example of how to use this method.
<hr>
<h3>Method xbShort xbDbf::OpenDatabase( char * FileName )</h3><br>
This method opens an Xbase (.DBF) file with the name
of FileName. <em>FileName</em> must a valid filename which can include
drives identifier, directory, filename and extension. <br><br>
The OpenDatabase method does not position to any any particular
data record. After opening a database, use GetRecord, GetFirstRecord
or GetLastRecord to position to a particular data record and load
a data record into the record buffer.<br><br>
The record buffer is automatically set to spaces when this method is called.
<br><br>
<TABLE BORDER>
<CAPTION ALIGN="TOP"><h3>Method Return Codes</h3></CAPTION><br>
<TR VALIGN="BASELINE">
<TR><TH ALIGN="LEFT">Return Code<TD>Description
<TR><TH ALIGN="LEFT">XB_NO_ERROR<TD>If there is no error
<TR><TH ALIGN="LEFT">XB_OPEN_ERROR<TD>Couldn't open the file
<TR><TH ALIGN="LEFT">XB_NO_MEMORY<TD>Memory allocation error
<TR><TH ALIGN="LEFT">XB_NOT_XBASE<TD>Not an xbXBase type file
</TABLE>
<h4>Example Program:</h4>
See program <A HREF="/XbaseSamples/sample2.cpp">sample2.cpp</A> for an
example of how to use this method.
<hr>
<h3>Method xbShort xbDbf::PackDatabase( xbShort WaitOption )</h3><br>
This method removes all records marked for deletion from an Xbase (.DBF) file
and reindexes any open index files. This method also reorganizes any memo
fields stored in a .DBT memo file.
<br><br>
<em>WaitOption</em> is one of:<br><br>
<li>F_SETLK - returns if the xbDbf file can not be exclusively locked
<li>F_SETLKW - will wait to execute until it can exclusively lock the file
<br><br>
<TABLE BORDER>
<CAPTION ALIGN="TOP"><h3>Method Return Codes</h3></CAPTION><br>
<TR VALIGN="BASELINE">
<TR><TH ALIGN="LEFT">Return Code<TD>Description
<TR><TH ALIGN="LEFT">XB_NO_ERROR<TD>If there is no error
<TR><TH ALIGN="LEFT">XB_CLOSE_ERROR<TD>If intermediate work file can not be closed
<TR><TH ALIGN="LEFT">XB_OPEN_ERROR<TD>Could not open file
<TR><TH ALIGN="LEFT">XB_NO_MEMORY<TD>Memory allocation error
<TR><TH ALIGN="LEFT">XB_WRITE_ERROR<TD>Error writing to file
<TR><TH ALIGN="LEFT">XB_SEEK_ERROR<TD>Seek error encountered
<TR><TH ALIGN="LEFT">XB_LOCK_FAILED<TD>Can not lock file or index
</TABLE>
<h4>Example Program:</h4>
See program <A HREF="/XbaseSamples/packdbf.cpp">packdbf.cpp</A> for an
example of how to use this method.
<hr>
<h3>Method xbShort xbDbf::PutRecord( xbLong RecNo )</h3><br>
This method copies the record buffer into record <em>RecNo</em> in the database.
This method can be used for updating records which were retrieved by
the GetRecord method.<br><br>
This method updates any open index files.<br><br>
<TABLE BORDER>
<CAPTION ALIGN="TOP"><h3>Method Return Codes</h3></CAPTION><br>
<TR VALIGN="BASELINE">
<TR><TH ALIGN="LEFT">Return Code<TD>Description
<TR><TH ALIGN="LEFT">XB_LOCK_FAILED<TD>Write lock not successful
<TR><TH ALIGN="LEFT">XB_NO_ERROR<TD>If there is no error
<TR><TH ALIGN="LEFT">XB_NOT_OPEN<TD>Database is not open
<TR><TH ALIGN="LEFT">XB_INVALID_RECORD<TD>Invalid record number
<TR><TH ALIGN="LEFT">XB_SEEK_ERROR<TD>Seek operation failed
<TR><TH ALIGN="LEFT">XB_WRITE_ERROR<TD>Write operation failed
</TABLE>
<h4>Example Program:</h4>
See program <A HREF="/XbaseSamples/sample3.cpp">sample3.cpp</A> for an
example of how to use this method.
<hr>
<h3>Method xbShort xbDbf::RebuildAllIndicis( void )</h3><br>
This method rebuilds all opened indicis for the database file.<br><br>
<TABLE BORDER>
<CAPTION ALIGN="TOP"><h3>Method Return Codes</h3></CAPTION><br>
<TR VALIGN="BASELINE">
<TR><TH ALIGN="LEFT">Return Code<TD>Description
<TR><TH ALIGN="LEFT">XB_NO_ERROR<TD>If there is no error
<TR><TH ALIGN="LEFT">XB_WRITE_ERROR<TD>Error writing data
<TR><TH ALIGN="LEFT">XB_CLOSE_ERROR<TD>Error closing work file
</TABLE>
<h4>Example Program:</h4>
See program <A HREF="/XbaseSamples/reindex.cpp">reindex.cpp</A> for an
example of how to use this method.
<hr>
<h3>Method xbShort xbDbf::RecordDeleted( void )</h3><br>
This method returns TRUE (or 1) if a record is marked for deletion and
returns FALSE (or 0) if the record is not marked for deletion. <br><br>
<TABLE BORDER>
<CAPTION ALIGN="TOP"><h3>Method Return Codes</h3></CAPTION><br>
<TR VALIGN="BASELINE">
<TR><TH ALIGN="LEFT">Return Code<TD>Description
<TR><TH ALIGN="LEFT">TRUE (1)<TD>Record is marked for deletion
<TR><TH ALIGN="LEFT">FALSE (0)<TD>Record is not marked for deletion
</TABLE>
<h4>Example Program:</h4>
See program <A HREF="/XbaseSamples/sample4.cpp">sample4.cpp</A> for an
example of how to use this method.
<hr>
<h3>Method xbShort xbDbf::SetVersion( xbShort Vswitch )</h3><br>
This method sets the version of xbDbf and DBT database files and memo files
to be created using the CreateDatabase method. The default setting is
3 - dBASE III+ version files. It can be set to 4 - for dBASE IV style
files.<br><br>
Vswitch is one of:<br>
0 - return current setting<br>
3 - Set to create version III files (default)<br>
4 - Set to create version IV files<br><br>
<TABLE BORDER>
<CAPTION ALIGN="TOP"><h3>Method Return Codes</h3></CAPTION><br>
<TR VALIGN="BASELINE">
<TR><TH ALIGN="LEFT">Return Code<TD>Description
<TR><TH ALIGN="LEFT">XB_NO_ERROR<TD>Setting updated
<TR><TH ALIGN="LEFT">3 or 4<TD>If Vswitch = 0, it returns current version setting
<TR><TH ALIGN="LEFT">XB_INVALID_OPTION<TD>Vswictch not one of 0,3 or 4
</TABLE>
<h4>Example Program:</h4>
See program <A HREF="/XbaseSamples/sample1.cpp">sample1.cpp</A> for an
example of how to use this method.
<hr>
<h3>Method xbShort xbDbf::UndeleteAllRecords( void )</h3><br>
This method unmarks all marked for deletion records in the database.<br><br>
<TABLE BORDER>
<CAPTION ALIGN="TOP"><h3>Method Return Codes</h3></CAPTION><br>
<TR VALIGN="BASELINE">
<TR><TH ALIGN="LEFT">Return Code<TD>Description
<TR><TH ALIGN="LEFT">XB_NO_ERROR<TD>No error encountered
<TR><TH ALIGN="LEFT">XB_INVALID_RECORD<TD>Could not mark record
<TR><TH ALIGN="LEFT">XB_NOT_OPEN<TD>If the file is not open
<TR><TH ALIGN="LEFT">XB_SEEK_ERROR<TD>Seek routine error
<TR><TH ALIGN="LEFT">XB_WRITE_ERROR<TD>Write routine error
</TABLE>
<h4>Example Program:</h4>
See program <A HREF="/XbaseSamples/undelall.cpp">undelall.cpp</A> for an example
of how to use this method.
<hr>
<h3>Method xbShort xbDbf::UndeleteRecord( void )</h3><br>
This method removes the mark for deletion on the current record in the
database.<br><br>
<TABLE BORDER>
<CAPTION ALIGN="TOP"><h3>Method Return Codes</h3></CAPTION><br>
<TR VALIGN="BASELINE">
<TR><TH ALIGN="LEFT">Return Code<TD>Description
<TR><TH ALIGN="LEFT">XB_NO_ERROR<TD>No error encountered
<TR><TH ALIGN="LEFT">XB_INVALID_RECORD<TD>Could not unmark record
</TABLE>
<h4>Example Program:</h4>
See program <A HREF="/XbaseSamples/sample4.cpp">sample4.cpp</A> for an
example of how to use this method.
<hr>
<h3>Method xbShort xbDbf::Zap( xbShort WaitOption )</h3><br>
This method removes all records from a database and any open indices.
<br><br>
<em>WaitOption</em> is one of:<br><br>
<li>F_SETLK - returns if the xbDbf file can not be exclusively locked
<li>F_SETLKW - will wait to execute until it can exclusively lock the file
<br><br>
<TABLE BORDER>
<TABLE BORDER>
<CAPTION ALIGN="TOP"><h3>Method Return Codes</h3></CAPTION><br>
<TR VALIGN="BASELINE">
<TR><TH ALIGN="LEFT">Return Code<TD>Description
<TR><TH ALIGN="LEFT">XB_NO_ERROR<TD>No error encountered
<TR><TH ALIGN="LEFT">XB_LOCK_FAILED<TD>Could not lock file
<TR><TH ALIGN="LEFT">XB_WRITE_ERROR<TD>Could not write to file
<TR><TH ALIGN="LEFT">XB_OPEN_ERROR<TD>Could not open temp database
</TABLE>
<h4>Example Program:</h4>
See program <A HREF="/XbaseSamples/zap.cpp">zap.cpp</A> for an
example of how to use this method.
<hr>
<p><img src="xbase.jpg"><br><hr>
</BODY>
</xbHtml>
|