- 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>
152 lines
4.8 KiB
C++
152 lines
4.8 KiB
C++
// BDE - (C) Copyright 1995 by Borland International
|
|
|
|
// recupdat.c
|
|
#include "snipit.h"
|
|
|
|
static const char szTblName[] = "contacts";
|
|
static const char szTblType[] = szPARADOX;
|
|
|
|
//=====================================================================
|
|
// Function:
|
|
// RecordUpdate();
|
|
//
|
|
// Description:
|
|
// This example shows how to update records in a table.
|
|
//=====================================================================
|
|
void
|
|
RecordUpdate(void)
|
|
{
|
|
DBIResult rslt; // Value returned from IDAPI functions
|
|
hDBIDb hDb; // Handle to the database
|
|
hDBICur hCur; // Handle to the table
|
|
pBYTE pRecBuf; // Pointer to the record buffer
|
|
CURProps curProps; // Properties of the table
|
|
CHAR szLastName[20]; // Last name
|
|
CHAR szFirstName[20]; // First name
|
|
CHAR szCompany[30]; // Company name
|
|
CHAR szPhone[16]; // Phone number
|
|
|
|
Screen("*** Updating Records ***\r\n");
|
|
|
|
BREAK_IN_DEBUGGER();
|
|
|
|
Screen(" Initializing IDAPI...\r\n");
|
|
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(" Opening the \"%s\" table...", szTblName);
|
|
|
|
rslt = DbiOpenTable(hDb, (pCHAR) szTblName, (pCHAR) szTblType,
|
|
NULL, NULL, NULL, dbiREADWRITE, dbiOPENSHARED,
|
|
xltFIELD, FALSE, NULL, &hCur);
|
|
if (ChkRslt(rslt, "OpenTable") != DBIERR_NONE)
|
|
{
|
|
CloseDbAndExit(&hDb);
|
|
Screen("\r\n*** End of Example ***");
|
|
return;
|
|
}
|
|
|
|
// Add a record.
|
|
Screen(" \r\n Determine the size of the record and allocate a"
|
|
" buffer to hold records...");
|
|
|
|
// Allocate memory for the record buffer.
|
|
rslt = DbiGetCursorProps(hCur, &curProps);
|
|
ChkRslt(rslt, "GetCursorProps");
|
|
|
|
pRecBuf = (pBYTE) malloc(curProps.iRecBufSize);
|
|
if (pRecBuf == NULL)
|
|
{
|
|
Screen(" Error - Out of memory");
|
|
rslt = DbiCloseCursor(&hCur);
|
|
ChkRslt(rslt, "CloseCursor");
|
|
CloseDbAndExit(&hDb);
|
|
Screen("\r\n*** End of Example ***");
|
|
return;
|
|
}
|
|
|
|
// Set the data to add.
|
|
strcpy(szLastName, "Smith");
|
|
strcpy(szFirstName, "John");
|
|
strcpy(szCompany, "Kauai Dive Shoppe");
|
|
strcpy(szPhone, "(304) 113-2244");
|
|
|
|
Screen(" Initialize the record buffer...");
|
|
rslt = DbiInitRecord(hCur, pRecBuf);
|
|
ChkRslt(rslt, "InitRecord");
|
|
|
|
Screen(" Add the fields to the record buffer...");
|
|
rslt = DbiPutField(hCur, 1, pRecBuf, (pBYTE) szLastName);
|
|
ChkRslt(rslt, "PutField");
|
|
|
|
rslt = DbiPutField(hCur, 2, pRecBuf, (pBYTE) szFirstName);
|
|
ChkRslt(rslt, "PutField");
|
|
|
|
rslt = DbiPutField(hCur, 3, pRecBuf, (pBYTE) szCompany);
|
|
ChkRslt(rslt, "PutField");
|
|
|
|
rslt = DbiPutField(hCur, 4, pRecBuf, (pBYTE) szPhone);
|
|
ChkRslt(rslt, "PutField");
|
|
|
|
|
|
Screen(" Add the record to the table...\r\n");
|
|
|
|
rslt = DbiInsertRecord(hCur, dbiNOLOCK, pRecBuf);
|
|
if (ChkRslt(rslt, "InsertRecord") != DBIERR_NONE)
|
|
{
|
|
if (rslt == DBIERR_KEYVIOL)
|
|
{
|
|
Screen(" Expected error - Continue...");
|
|
}
|
|
else
|
|
{
|
|
rslt = DbiCloseCursor(&hCur);
|
|
ChkRslt(rslt, "CloseCursor");
|
|
CloseDbAndExit(&hDb);
|
|
Screen("\r\n*** End of Example ***");
|
|
return;
|
|
}
|
|
}
|
|
|
|
Screen(" Search for the value in the table...\r\n");
|
|
rslt = DbiSetToKey(hCur, keySEARCHEQ, FALSE, 0, 0, pRecBuf);
|
|
ChkRslt(rslt, "SetToKey");
|
|
|
|
Screen(" Change the phone number of the just added record...\r\n");
|
|
|
|
Screen(" Get the record from the table...");
|
|
rslt = DbiGetNextRecord(hCur, dbiWRITELOCK, pRecBuf, NULL);
|
|
ChkRslt(rslt, "GetNextRecord");
|
|
|
|
Screen(" Change the value in the \"Phone\" field...");
|
|
strcpy(szPhone, "(304) 222-9876");
|
|
rslt = DbiPutField(hCur, 4, pRecBuf, (pBYTE) szPhone);
|
|
ChkRslt(rslt, "PutField");
|
|
|
|
Screen(" Write the changes to the table...");
|
|
rslt = DbiModifyRecord(hCur, pRecBuf, TRUE);
|
|
ChkRslt(rslt, "ModifyRecord");
|
|
|
|
Screen("\r\n Delete the record which was added...");
|
|
rslt = DbiDeleteRecord(hCur, NULL);
|
|
ChkRslt(rslt, "DeleteRecord");
|
|
|
|
free(pRecBuf);
|
|
|
|
Screen(" 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 ***");
|
|
}
|