This is an example of index attributes use written in C++.
#include <stdio.h>
#include <math.h>
#include <stdlib.h>
#include <stdint.h>
static char *btrieveFileName = (char *)"squaresAndSquareRoots.btr";
#ifndef __GNUC__
#define snprintf _snprintf
#endif
#define MIN_X 0
#define MAX_X 255
#pragma pack(1)
typedef struct {
uint8_t x;
uint16_t xSquared;
double xSquareRoot;
char text[1024];
} record_t;
#pragma pack()
{
{
goto leave;
}
{
goto leave;
}
leave:
return status;
}
{
{
goto leave;
}
leave:
return status;
}
{
record_t record;
int i;
for (i = MIN_X; i <= MAX_X; i++)
{
if (i == MIN_X)
{
{
goto leave;
}
}
else
{
{
goto leave;
}
}
printf("record: (%u, %u, %f, %s)\n", record.x, record.xSquared, record.xSquareRoot, record.text);
}
leave:
return status;
}
{
int i;
record_t record;
for (i = MIN_X; i <= MAX_X; i++)
{
record.x = (uint8_t)i;
record.xSquared = (uint16_t)(i * i);
record.xSquareRoot = sqrt((double)i);
snprintf(record.text, sizeof(record.text), "The square of %d is %d and its square root is %f.", record.x, record.xSquared, record.xSquareRoot);
record.text[sizeof(record.text) - 1] = '\0';
{
goto leave;
}
}
leave:
return status;
}
{
{
goto leave;
}
leave:
return status;
}
{
{
goto leave;
}
leave:
return status;
}
{
{
goto leave;
}
{
goto leave;
}
{
goto leave;
}
{
goto leave;
}
{
goto leave;
}
{
goto leave;
}
{
goto leave;
}
{
goto leave;
}
{
goto leave;
}
{
goto leave;
}
leave:
return status;
}
int
main(int argc, char *argv[])
{
static const char *usage = "Usage: %s\n";
if (argc != 1)
{
printf(usage, argv[0]);
goto leave;
}
{
goto leave;
}
{
goto leave;
}
{
goto leave;
}
{
goto leave;
}
{
goto leave;
}
{
goto leave;
}
{
goto leave;
}
leave:
return 0;
return 1;
}
The Btrieve client class.
Definition btrieveCpp.h:1388
Btrieve::StatusCode FileCreate(BtrieveFileAttributes *btrieveFileAttributes, const char *fileName, Btrieve::CreateMode createMode, Btrieve::LocationMode locationMode=Btrieve::LOCATION_MODE_NO_PREFERENCE)
Create a file.
Btrieve::StatusCode FileClose(BtrieveFile *btrieveFile)
Close a file.
Btrieve::StatusCode FileDelete(const char *fileName)
Delete a file.
Btrieve::StatusCode FileOpen(BtrieveFile *btrieveFile, const char *fileName, const char *ownerName, Btrieve::OpenMode openMode, Btrieve::LocationMode locationMode=Btrieve::LOCATION_MODE_NO_PREFERENCE)
Open a file.
The Btrieve file attributes class.
Definition btrieveCpp.h:2448
Btrieve::StatusCode SetFixedRecordLength(int fixedRecordLength)
Set the fixed record length.
The Btrieve file class.
Definition btrieveCpp.h:1729
Btrieve::StatusCode RecordCreate(char *record, int recordLength)
Create a record.
Btrieve::StatusCode IndexCreate(BtrieveIndexAttributes *btrieveIndexAttributes)
Create an index.
int RecordRetrieveNext(char *record, int recordSize, Btrieve::LockMode lockMode=Btrieve::LOCK_MODE_NONE)
Retrieve the next record.
int RecordRetrieveFirst(Btrieve::Index index, char *record, int recordSize, Btrieve::LockMode lockMode=Btrieve::LOCK_MODE_NONE)
Retrieve the first record.
Btrieve::StatusCode GetLastStatusCode()
Get the last status code.
The Btrieve index attributes class.
Definition btrieveCpp.h:3716
Btrieve::StatusCode AddKeySegment(BtrieveKeySegment *btrieveKeySegment)
Add a key segment.
Btrieve::StatusCode SetDuplicateMode(Btrieve::DuplicateMode duplicateMode)
Set the duplicate mode.
Btrieve::StatusCode SetModifiable(bool enableModifiable)
Set modifiable.
Btrieve::StatusCode SetACSName(const char *ACSName)
Set the alternate collation sequence name.
Btrieve::StatusCode SetIndex(Btrieve::Index index)
Set the index.
The Btrieve key segment class.
Definition btrieveCpp.h:3874
Btrieve::StatusCode SetField(int offset, int length, Btrieve::DataType dataType)
Set the field.
Btrieve::StatusCode SetNullValue(int nullValue)
Set the null value.
Btrieve::StatusCode SetNullKeyMode(Btrieve::NullKeyMode nullKeyMode)
Set the null key mode.
Btrieve::StatusCode SetDescendingSortOrder(bool setDescendingSortOrder)
Set descending sort order.
static const char * StatusCodeToString(StatusCode statusCode)
Return a status code as a string.
@ CREATE_MODE_OVERWRITE
Overwrite.
Definition btrieveCpp.h:72
StatusCode
The Btrieve status codes.
Definition btrieveCpp.h:713
@ STATUS_CODE_UNKNOWN
-7 - Unknown.
Definition btrieveCpp.h:1194
@ STATUS_CODE_NO_ERROR
0 - No error.
Definition btrieveCpp.h:715
@ DUPLICATE_MODE_ALLOWED_NONREPEATING
Duplicates allowed, nonrepeating.
Definition btrieveCpp.h:187
@ NULL_KEY_MODE_ANY_SEGMENTS
Any segments.
Definition btrieveCpp.h:595
@ OPEN_MODE_NORMAL
Normal.
Definition btrieveCpp.h:606
static const int MAXIMUM_KEY_LENGTH
The Btrieve maximum key segment length.
Definition btrieveCpp.h:46
@ DATA_TYPE_ZSTRING
Null terminated string.
Definition btrieveCpp.h:201
@ INDEX_119
Index 119.
Definition btrieveCpp.h:547