- 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>
294 lines
10 KiB
C++
294 lines
10 KiB
C++
// BDE - (C) Copyright 1995 by Borland International
|
|
|
|
// softdel.c
|
|
#include "snipit.h"
|
|
|
|
static const char szTblName[] = "cust";
|
|
static const char szTblType[] = szDBASE;
|
|
|
|
static DBIResult AddRecord(hDBICur hCur, DFLOAT fID, pCHAR szName,
|
|
pCHAR szStreet, pCHAR szCity, pCHAR szState_prov,
|
|
pCHAR szZIP_PST_CD, pCHAR szCountry, pCHAR szPhone,
|
|
UINT16 uDay, UINT16 uMonth, INT16 iYear);
|
|
|
|
static DBIResult FindRecord(hDBICur *phCur, DFLOAT fCust_ID);
|
|
|
|
//=====================================================================
|
|
// Function:
|
|
// SoftDel();
|
|
//
|
|
// Description:
|
|
// This example shows how the state of the soft-delete flag
|
|
// affects which records are visible in a table. When the
|
|
// soft-delete property is OFF, deleted records are not
|
|
// displayed. When the soft-delete property is ON, deleted
|
|
// records are displayed. Records are not actually deleted
|
|
// from the table until after the table has been packed.
|
|
//=====================================================================
|
|
void
|
|
SoftDel (void)
|
|
{
|
|
hDBIDb hDb; // Handle to the database
|
|
hDBICur hCur; // Handle to the table
|
|
DBIResult rslt; // Return value from IDAPI functions
|
|
BOOL bSoftDelete; // Soft-delete enabled?
|
|
UINT16 uLength; // Space required to store property
|
|
DFLOAT fCust_ID = 1000.0; // Customer ID for the record which is
|
|
// added to the table
|
|
|
|
Screen("*** Soft Delete 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(" Open the %s table...", szTblName);
|
|
rslt = DbiOpenTable(hDb, (pCHAR) szTblName, (pCHAR) szTblType,
|
|
"CUST.MDX", "CUST_NO", 0, dbiREADWRITE,
|
|
dbiOPENEXCL, xltFIELD, FALSE, NULL, &hCur);
|
|
if (ChkRslt(rslt, "OpenTable") != DBIERR_NONE)
|
|
{
|
|
CloseDbAndExit(&hDb);
|
|
Screen("\r\n*** End of Example ***");
|
|
return;
|
|
}
|
|
|
|
Screen(" Switch to the CUST_NO index...");
|
|
rslt = DbiSwitchToIndex(&hCur, "CUST.MDX", "CUST_NO", NULL, FALSE);
|
|
ChkRslt(rslt, "SwitchToIndex");
|
|
|
|
Screen(" Add a record to the table...");
|
|
if (AddRecord(hCur, fCust_ID, "SC Pro Divers, Ltd.", "71 Beach Hill",
|
|
"Santa Cruz", "CA", "95060", "U.S.A.", "408-111-2222",
|
|
3, 22, 1994)
|
|
!= DBIERR_NONE)
|
|
{
|
|
CloseDbAndExit(&hDb);
|
|
Screen("\r\n*** End of Example ***");
|
|
return;
|
|
}
|
|
|
|
Screen(" Delete the record which we have just added to the"
|
|
" table...");
|
|
rslt = DbiSetToBegin(hCur);
|
|
ChkRslt(rslt, "SetToBegin");
|
|
|
|
// First need to find the record which we have added to the table.
|
|
if (FindRecord(&hCur, fCust_ID) == DBIERR_NONE)
|
|
{
|
|
// Need to move the current record pointer in the cursor to the
|
|
// found record.
|
|
rslt = DbiGetNextRecord(hCur, dbiNOLOCK, NULL, NULL);
|
|
ChkRslt(rslt, "GetNextRecord");
|
|
|
|
rslt = DbiDeleteRecord(hCur, NULL);
|
|
ChkRslt(rslt, "DeleteRecord");
|
|
}
|
|
|
|
// Determine the state of soft-delete property.
|
|
rslt = DbiGetProp(hCur, curSOFTDELETEON, &bSoftDelete, sizeof(BOOL),
|
|
&uLength);
|
|
ChkRslt(rslt, "GetProp");
|
|
|
|
Screen("\r\n Display the table with SoftDelete %s",
|
|
bSoftDelete ? "ON" : "OFF");
|
|
|
|
rslt = DbiSetToBegin(hCur);
|
|
ChkRslt(rslt, "SetToBegin");
|
|
DisplayTable(hCur, 10);
|
|
|
|
// Toggle the Soft-delete property.
|
|
bSoftDelete = !bSoftDelete;
|
|
rslt = DbiSetProp(hCur, curSOFTDELETEON, (UINT32) bSoftDelete);
|
|
ChkRslt(rslt, "SetProp");
|
|
|
|
rslt = DbiGetProp(hCur, curSOFTDELETEON, &bSoftDelete, sizeof(BOOL),
|
|
&uLength);
|
|
ChkRslt(rslt, "GetProp");
|
|
|
|
Screen("\r\n Display the table with SoftDelete %s",
|
|
bSoftDelete ? "ON" : "OFF");
|
|
|
|
rslt = DbiSetToBegin(hCur);
|
|
ChkRslt(rslt, "SetToBegin");
|
|
DisplayTable(hCur, 10);
|
|
|
|
// Pack the table. Note that packing is required in order to remove
|
|
// deleted records from a dBASE table.
|
|
Screen("\r\n Pack the table - physically delete the record"
|
|
" from the %s table...", szTblName);
|
|
|
|
rslt = DbiPackTable(hDb, hCur, NULL, NULL, TRUE);
|
|
ChkRslt(rslt, "PackTable");
|
|
|
|
Screen("\r\n Display the table with SoftDelete %s after"
|
|
" packing...", bSoftDelete ? "ON" : "OFF");
|
|
|
|
rslt = DbiSetToBegin(hCur);
|
|
ChkRslt(rslt, "SetToBegin");
|
|
DisplayTable(hCur, 10);
|
|
|
|
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 ***");
|
|
}
|
|
|
|
//=====================================================================
|
|
// Code: AddRecord(hCur, fID, szName, szStreet, szCity, szState_prov,
|
|
// szZIP_PST_CD, szCountry, szPhone, uMonth, uDay,
|
|
// INT16 iYear);
|
|
//
|
|
// Input: hCur - Cursor to the table
|
|
// ID - Customer ID
|
|
// szName - Name of the company
|
|
// szStreet - Street address
|
|
// szCity - City
|
|
// szState_prov - State/Province
|
|
// szZIP_PST_CD - Zip or Postal code
|
|
// szCountry - Country
|
|
// szPhone - Phone number
|
|
// uMonth - Month
|
|
// uDay - Day
|
|
// Year - Year
|
|
//
|
|
// Return: Result of adding the record to the table
|
|
//
|
|
// Description:
|
|
// This function will add a record to the given table.
|
|
//=====================================================================
|
|
DBIResult
|
|
AddRecord (hDBICur hCur, DFLOAT fID, pCHAR szName, pCHAR szStreet,
|
|
pCHAR szCity, pCHAR szState_prov, pCHAR szZIP_PST_CD,
|
|
pCHAR szCountry, pCHAR szPhone, UINT16 uMonth, UINT16 uDay,
|
|
INT16 iYear)
|
|
{
|
|
DBIResult rslt; // Value returned from IDAPI functions
|
|
CURProps TblProps; // Table properties
|
|
pBYTE pRecBuf; // Record buffer
|
|
DBIDATE Date; // Structure to contain the date
|
|
|
|
// Allocate memory for the record buffer.
|
|
rslt = DbiGetCursorProps(hCur, &TblProps);
|
|
ChkRslt(rslt, "GetCursorProps");
|
|
|
|
pRecBuf = (pBYTE) malloc(TblProps.iRecBufSize * sizeof(BYTE));
|
|
if (pRecBuf == NULL)
|
|
{
|
|
Screen(" Error - Out of memory");
|
|
return DBIERR_NOMEMORY;
|
|
}
|
|
|
|
rslt = DbiInitRecord(hCur, pRecBuf);
|
|
ChkRslt(rslt, "InitRec");
|
|
|
|
// Put the ID Number (fID) into the record buffer.
|
|
rslt = DbiPutField(hCur, 1, pRecBuf, (pBYTE) &fID);
|
|
ChkRslt(rslt, "PutField");
|
|
|
|
// Put the Name (szName) into the record buffer.
|
|
rslt = DbiPutField(hCur, 2, pRecBuf, (pBYTE) szName);
|
|
ChkRslt(rslt, "PutField");
|
|
|
|
// Put the Street (szStreet) into the record buffer.
|
|
rslt = DbiPutField(hCur, 3, pRecBuf, (pBYTE) szStreet);
|
|
ChkRslt(rslt, "PutField");
|
|
|
|
// Put the City (szCity) into the record buffer.
|
|
rslt = DbiPutField(hCur, 4, pRecBuf, (pBYTE) szCity);
|
|
ChkRslt(rslt, "PutField");
|
|
|
|
// Put the State (szState_prov) into the record buffer.
|
|
rslt = DbiPutField(hCur, 5, pRecBuf, (pBYTE) szState_prov);
|
|
ChkRslt(rslt, "PutField");
|
|
|
|
// Put the Zip Code (szZIP_PST_CD) into the record buffer.
|
|
rslt = DbiPutField(hCur, 6, pRecBuf, (pBYTE) szZIP_PST_CD);
|
|
ChkRslt(rslt, "PutField");
|
|
|
|
// Put the Country (szCountry) into the record buffer.
|
|
rslt = DbiPutField(hCur, 7, pRecBuf, (pBYTE) szCountry);
|
|
ChkRslt(rslt, "PutField");
|
|
|
|
// Put the Phone number (szPhone) into the record buffer.
|
|
rslt = DbiPutField(hCur, 8, pRecBuf, (pBYTE) szPhone);
|
|
ChkRslt(rslt, "PutField");
|
|
|
|
// Encode the date into the format which Paradox understands.
|
|
rslt = DbiDateEncode(uMonth, uDay, iYear, &Date);
|
|
ChkRslt(rslt, "DateEncode");
|
|
|
|
rslt = DbiPutField(hCur, 9, pRecBuf, (pBYTE)&Date);
|
|
ChkRslt(rslt, "PutField");
|
|
|
|
Screen(" Insert the record into the table...");
|
|
rslt = DbiInsertRecord(hCur, dbiNOLOCK, pRecBuf);
|
|
ChkRslt(rslt, "InsertRecord");
|
|
|
|
free(pRecBuf);
|
|
|
|
return rslt;
|
|
}
|
|
|
|
//=====================================================================
|
|
// Code: FindRecord(phCur, fCust_ID);
|
|
//
|
|
// Input: phCur - pointer to the cursor handle
|
|
// fCust_ID - Customer ID
|
|
//
|
|
// Return: Result of finding the record
|
|
//
|
|
// Description:
|
|
// This function will search the given table for the indicated
|
|
// record.
|
|
//=====================================================================
|
|
DBIResult
|
|
FindRecord (hDBICur *phCur, DFLOAT fCust_ID)
|
|
{
|
|
DBIResult rslt; // Return value from IDAPI functions
|
|
pBYTE pRecBuf; // Record buffer to contain the searched-for
|
|
// value
|
|
CURProps TblProps; // Properties of the table - used to determine
|
|
// the size of the record buffer
|
|
|
|
// Create the key buffer.
|
|
rslt = DbiGetCursorProps(*phCur,&TblProps);
|
|
ChkRslt(rslt, "GetCursorProps");
|
|
|
|
pRecBuf = (pBYTE) malloc(TblProps.iRecBufSize);
|
|
if (pRecBuf == NULL)
|
|
{
|
|
Screen(" Error - Out of memory!");
|
|
return DBIERR_NOMEMORY;
|
|
}
|
|
|
|
// Place the value which we are searching for in the record buffer.
|
|
// In this case, we are searching for the Customer ID, which is the
|
|
// first field of the table.
|
|
rslt = DbiPutField(*phCur, 1, pRecBuf, (pBYTE) &fCust_ID);
|
|
ChkRslt(rslt, "PutField");
|
|
|
|
// The cust table has a primary index on the customer number.
|
|
// Therefore we do not need to create an index to search on the
|
|
// customer number.
|
|
rslt = DbiSetToKey(*phCur, keySEARCHEQ, FALSE, 0, 0, pRecBuf);
|
|
ChkRslt(rslt, "SetToKey");
|
|
|
|
free(pRecBuf);
|
|
|
|
return rslt;
|
|
}
|