Files
TeslaRel410/BORLAND/BDE/EXAMPLES/SNIPIT/INMEMTBL.C
T
CydandClaude Fable 5 63312e07f9 source410: literal 4.10 source reconstruction + BC++ 4.52 fleet toolchain archived
- BORLAND/: Borland C++ 4.52 (chosen over 4.5 by byte-match: CODE/RP/CW32.LIB
  is identical to 4.52's install lib). BCC32/TLINK32/TLIB/MAKE run natively on
  Win11; CODE/BT/OPT.MAK is the shipped BTL4OPT.EXE's exact flag recipe
  (extender = Borland PowerPack DPMI32, not Phar Lap TNT).
- restoration/source410/: the literal 1995-form reconstruction of the missing
  BT game source (never mixed into CODE/). Round 1-3 state:
  * 6 of 10 surviving original TUs COMPILE CLEAN under the period toolchain
    (BTMSSN, BTCNSL, BTSCNRL, BTTEAM, BTL4MODE, BTL4ARND) - first builds
    since 1996.
  * BT_L4/BTL4APP.CPP pilot reconstruction: 12/12 functions, Fail() lands on
    its binary-recorded line 400 exactly.
  * BT/BTCNSL.HPP: console wire IDs recovered from the binary's ctors
    (Killed=9, Damaged=10, ScoreUpdate=13, DeathWithoutHonor=15 [T1];
    TeamScore=12 flagged [T4]).
  * MUNGA/: 8 engine-header backfills back-dated from the BT412 WinTesla tree
    (VDATA numbering decomp-verified; AUDREND's OpenAL-era virtual removed -
    the period compiler is the drift detector).
  * Tooling: backdate.py (WinTesla->1995 header transform), compile410.sh
    (per-TU verification sweep under authentic OPT.MAK flags).
  * README: corrected roadmap - MECH.HPP is the capstone grown with the mech
    TU reconstructions; BTREG.CPP green = the header-family milestone.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-07-19 07:33:26 -05:00

196 lines
6.9 KiB
C++

// BDE - (C) Copyright 1995 by Borland International
// Inmemtbl.C
#include "snipit.h"
static char szTblName[] = "INMEMTBL";
// Field Descriptor used in creating a table.
static SNIPFAR FLDDesc fldDesc[] = {
{ // Field 1 - ALPHA
1, // Field number
"ALPHA", // Field name
fldZSTRING, // Field type
fldUNKNOWN, // Field subtype
10, // Field size
0, // Decimal places ( 0 )
// computed
0, // Offset in record ( 0 )
11, // Length in bytes ( 0 )
0, // For Null bits ( 0 )
fldvNOCHECKS, // Validity checks ( 0 )
fldrREADWRITE // Rights
},
{ // Field 2 - NUMERIC
2, "NUMERIC", fldFLOAT, fldUNKNOWN,
0, 0, 0, 8, 0, fldvNOCHECKS, fldrREADWRITE
},
{ // Field 3 - MONEY
3, "MONEY", fldFLOAT, fldstMONEY,
0, 0, 0, 8, 0, fldvNOCHECKS, fldrREADWRITE
},
{ // Field 4 - DATE
4, "DATE", fldDATE, fldUNKNOWN,
0, 0, 0, 4, 0, fldvNOCHECKS, fldrREADWRITE
},
{ // Field 5 - SHORT
5, "SHORT", fldINT16, fldUNKNOWN,
0, 0, 0, 2, 0, fldvNOCHECKS, fldrREADWRITE
},
{ // Field 6 - TIME
6, "TIME", fldTIME, fldUNKNOWN,
0, 0, 0, 4, 0, fldvNOCHECKS, fldrREADWRITE
},
{ // Field 7 - TIMESTAMP
7, "TIMESTAMP", fldTIMESTAMP, fldUNKNOWN,
0, 0, 0, 8, 0, fldvNOCHECKS, fldrREADWRITE
},
{ // Field 8 - LONG
8, "LONG", fldINT32, fldUNKNOWN,
0, 0, 0, 4, 0, fldvNOCHECKS, fldrREADWRITE
},
{ // Field 9 - BOOL
9, "BOOL", fldBOOL, fldUNKNOWN,
0, 0, 0, 2, 0, fldvNOCHECKS, fldrREADWRITE
},
{ // Field 10 - BYTES
10, "BYTES", fldBYTES, fldUNKNOWN,
20, 0, 0, 20, 0, fldvNOCHECKS, fldrREADWRITE
}
}; // Array of field descriptors.
// The number of fields in the table.
static unsigned uNumFields = sizeof(fldDesc) / sizeof (fldDesc[0]);
static DBIResult FillTable1(hDBICur hCur, DFLOAT NumRecs);
//=====================================================================
// Function:
//
// CreateAndFillInMemoryTbl();
// Description:
// This sample code will create an in-memory table, insert
// 10 records into the table, then close the table.
//
// There are the following limits for In-Memory table:
// Fields: 1024
// Max Rec Size: 16K
// Indexes: 0 (Cannot be indexed)
// Table Size: 512M
//=====================================================================
void
CreateAndFillInMemoryTbl (void)
{
hDBIDb hDb; // Handle to the database
hDBICur hCur; // Handle to the table
UINT16 uDispNumRecs = 10 ; // Number of records to add and
// display
DBIResult rslt; // Return value from IDAPI functions
Screen("*** Create/Open/Fill In-Memory Example ***\r\n");
BREAK_IN_DEBUGGER();
Screen(" Initializing IDAPI...");
if (InitAndConnect(&hDb) != DBIERR_NONE)
{
Screen("\r\n*** End of Example ***");
return;
}
Screen(" Setting the database directory...");
rslt = DbiSetDirectory(hDb, (pCHAR) szTblDirectory);
ChkRslt(rslt, "SetDirectory");
Screen(" Creating the %s in-memory table...", szTblName);
rslt = DbiCreateInMemTable(hDb, szTblName, uNumFields, fldDesc, &hCur);
if (ChkRslt(rslt, "CreateTable") != DBIERR_NONE)
{
CloseDbAndExit(&hDb);
Screen("\r\n*** End of Example ***");
return;
}
Screen(" Fill the %s table with random data...", szTblName);
FillTable1(hCur, uDispNumRecs);
rslt = DbiSetToBegin(hCur);
ChkRslt(rslt, "SetToBegin");
Screen(" Display the %s table which we just created...", szTblName);
DisplayInMemoryTable(hCur, uDispNumRecs);
// You do not need to delete this table. IDAPI will delete the
// table when it is closed.
Screen("\r\n Close the %s table...", szTblName);
rslt = DbiCloseCursor(&hCur);
ChkRslt(rslt, "CloseCursor");
Screen(" Close the database and exit IDAPI...");
CloseDbAndExit(&hDb);
Screen("\r\n*** End of Example ***");
}
//=====================================================================
// Function:
// FillTable1(hCur, NumRecs);
//
// Input: hCur - The table cursor
// NumRecs - The number of records to insert
//
// Return: DBIResult - Success of the opperation
//
// Description:
// This function adds the specified number of records to
// the in-memory table.
//=====================================================================
DBIResult
FillTable1 (hDBICur hCur, DFLOAT NumRecs)
{
DBIResult rslt; // Return value from IDAPI functions
DFLOAT fRecCount; // Loop variable = count of records
UINT16 FldCntr; // Field counter
pBYTE pRecBuf = NULL; // Pointer to the record buffer
CURProps TblProps; // Table descriptor
Screen(" Inserting %.0f records into the table...", NumRecs);
if (hCur)
{
// Allocate a record buffer.
rslt = DbiGetCursorProps(hCur, &TblProps);
ChkRslt(rslt, "GetCursorProps");
pRecBuf = (pBYTE) malloc(TblProps.iRecBufSize);
if (pRecBuf == NULL)
{
Screen(" Error - Out of memory");
return DBIERR_NOMEMORY;
}
// Loop until the specified number of records have been written
// to the table.
for (fRecCount = 0; fRecCount < NumRecs; fRecCount++)
{
// Make sure we're starting with a clean record buffer.
rslt = DbiInitRecord(hCur, pRecBuf);
ChkRslt(rslt, "InitRecord");
for (FldCntr = 0; FldCntr < uNumFields; FldCntr++)
{
// Put field data into the record buffer.
PutFieldSample(hCur, pRecBuf, (FldCntr + 1), &fldDesc[FldCntr]);
}
// Append the record to the table....
rslt = DbiAppendRecord(hCur, pRecBuf);
ChkRslt(rslt, "InsertRecord");
}
free((pCHAR) pRecBuf);
}
return DBIERR_NONE;
}