Files
TeslaRel410/BORLAND/BDE/EXAMPLES/SNIPIT/LNKCRSR.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

135 lines
4.7 KiB
C++

// BDE - (C) Copyright 1995 by Borland International
// LnkCrsr.c
#include "snipit.h"
static const char szMasterTable[] = "customer";
static const char szDetailTable[] = "orders";
static const char szTblType[] = szPARADOX;
//=====================================================================
// Function:
// LnkCrsr();
//
// Description:
// Linking cursors establishes a link between two cursors
// such that the detail cursor has its record set limited to
// the set of records matching the linking key values of the
// master cursor.
//=====================================================================
void
LnkCrsr (void)
{
hDBIDb hDb; // Handle to the database
hDBICur hCurMaster; // Handle to the master table
hDBICur hCurDetail; // Handle to the detail table
UINT32 ulNumRecs = 10; // Number of records to display,
// 0 = all
UINT16 uFieldsMaster[] = {1}; // Link the first field of Customer
UINT16 uFieldsDetail[] = {2}; // To the second field of Orders
// (which is indexed)
DBIResult rslt; // Return value from IDAPI functions
Screen("*** Linked Cursors Example ***\r\n");
BREAK_IN_DEBUGGER();
Screen(" Initializing the engine...");
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(" Open the %s master table...", szMasterTable);
rslt = DbiOpenTable(hDb, (pCHAR) szMasterTable, (pCHAR) szTblType,
NULL, NULL, 0, dbiREADWRITE, dbiOPENSHARED,
xltFIELD, FALSE, NULL, &hCurMaster);
if (ChkRslt(rslt, "OpenTable") != DBIERR_NONE)
{
CloseDbAndExit(&hDb);
Screen("\r\n*** End of Example ***");
return;
}
Screen(" Display the first %lu records of the %s master table...",
ulNumRecs, szMasterTable);
DisplayTable(hCurMaster, ulNumRecs);
Screen("\r\n Open the %s detail table...", szDetailTable);
rslt = DbiOpenTable(hDb, (pCHAR) szDetailTable, (pCHAR) szTblType,
NULL, NULL, 0, dbiREADWRITE, dbiOPENSHARED,
xltFIELD, FALSE, NULL, &hCurDetail);
if (ChkRslt(rslt, "OpenTable") != DBIERR_NONE)
{
CloseDbAndExit(&hDb);
Screen("\r\n*** End of Example ***");
return;
}
Screen(" Display the first %lu records of the %s detail table...",
ulNumRecs, szDetailTable);
DisplayTable(hCurDetail, ulNumRecs);
Screen("\r\n Set to the Customer_No index on the detail table...");
rslt = DbiSwitchToIndex(&hCurDetail, NULL, NULL, 2, FALSE);
ChkRslt(rslt, "SwitchToIndex");
Screen(" Link the tables...");
// Put the Customer table into link mode.
rslt = DbiBeginLinkMode(&hCurMaster);
ChkRslt(rslt, "BeginLinkMode");
// Put the Orders table into link mode.
rslt = DbiBeginLinkMode(&hCurDetail);
ChkRslt(rslt, "BeginLinkMode");
// Link the two tables, specifying which fields
// will be linked in the last two parameters.
// Specifically, link the first field of Customers
// to the indexed second field of Orders.
rslt = DbiLinkDetail(hCurMaster, hCurDetail, 1, uFieldsMaster,
uFieldsDetail);
ChkRslt(rslt, "LinkDetail");
Screen(" Display the %s detail table after the link:",
szDetailTable);
Screen(" Note that all Customer numbers correspond to the last"
" record displayed in\r\n the master table");
DisplayTable(hCurDetail, ulNumRecs);
Screen("\r\n End the link...");
// Unlink the detail table from the master table.
rslt = DbiUnlinkDetail(hCurDetail);
ChkRslt(rslt, "EndLinkMode");
// Take the Customer table out of link mode.
rslt = DbiEndLinkMode(&hCurMaster);
ChkRslt(rslt, "EndLinkMode");
// Take the Orders table out of link mode.
rslt = DbiEndLinkMode(&hCurDetail);
ChkRslt(rslt, "EndLinkMode");
Screen(" Close the tables...");
// Close the master table.
rslt = DbiCloseCursor(&hCurMaster);
ChkRslt(rslt, "CloseCursor");
// Close the detail table.
rslt = DbiCloseCursor(&hCurDetail);
ChkRslt(rslt, "CloseCursor");
Screen(" Close the database and exit IDAPI...");
CloseDbAndExit(&hDb);
Screen("\r\n*** End of Example ***");
}