- 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>
311 lines
11 KiB
ObjectPascal
311 lines
11 KiB
ObjectPascal
{ softdel.pas }
|
|
program SoftDel;
|
|
|
|
{$IfDef VER80}
|
|
uses SnipTool, SnipData, SysUtils, WinTypes, WinProcs,
|
|
DbiProcs, DbiTypes, DbiErrs;
|
|
{$Else}
|
|
uses WinTypes, WinCrt, Strings, DbiProcs, DbiTypes, DbiErrs,
|
|
SnipTool, SnipData;
|
|
{$EndIf}
|
|
|
|
const
|
|
szTblName = 'cust'; { Name of table }
|
|
szTblType = szDBASE; { Table type to use }
|
|
|
|
{=====================================================================
|
|
Code: AddRecord();
|
|
|
|
Input: hCur - Cursor to the table.
|
|
FLOAT fID - Customer ID
|
|
pCHAR szName - Name of the Company
|
|
pCHAR szStreet - Street address
|
|
pCHAR szCity - City
|
|
pCHAR szState_prov - State/Province
|
|
pCHAR szZIP_PST_CD - Zip or Postal code
|
|
pCHAR szCountry - Country
|
|
pCHAR szPhone - Phone Number
|
|
UINT16 uMonth - Month
|
|
UINT16 uDay - Day
|
|
INT16 iYear - Year
|
|
|
|
Return: Result of adding the record to the table
|
|
|
|
Description:
|
|
This function will add a record to the given table.
|
|
===================================================================== }
|
|
function AddRecord (hCur: hDBICur; fID: FLOAT; szName: pCHAR; szStreet: pCHAR;
|
|
szCity: pCHAR; szState_prov: pCHAR; szZIP_PST_CD: pCHAR;
|
|
szCountry: pCHAR; szPhone: pCHAR; uMonth: UINT16;
|
|
uDay: UINT16; iYear: INT16): DBIResult;
|
|
|
|
var
|
|
rslt: DBIResult; { Value returned from IDAPI functions }
|
|
TblProps: CURProps; { Table Properties }
|
|
pRecBuf: pBYTE; { Record Buffer }
|
|
sDate: DATE; { Structure to contain the date. }
|
|
|
|
begin
|
|
{ Allocate memory for the record buffer. }
|
|
ChkRslt(DbiGetCursorProps(hCur, TblProps), DBIERR_NONE,
|
|
' Error - GetCursorProps.');
|
|
|
|
{ Allocate memory for the record buffer. }
|
|
GetMem(pRecBuf, TblProps.iRecBufSize * sizeof(BYTE));
|
|
if not Assigned (pRecBuf) then
|
|
begin
|
|
Screen(' Error - Out of memory.');
|
|
AddRecord := DBIERR_NOMEMORY;
|
|
exit;
|
|
end;
|
|
|
|
ChkRslt(DbiInitRecord(hCur, pRecBuf), DBIERR_NONE,
|
|
' Error - InitRec.');
|
|
|
|
{ put the ID Number (fID) into the record buffer. }
|
|
ChkRslt(DbiPutField(hCur, 1, pRecBuf, @(fID)),
|
|
DBIERR_NONE, ' Error - PutField.');
|
|
|
|
{ put the Name (szName) into the record buffer. }
|
|
ChkRslt(DbiPutField(hCur, 2, pRecBuf, (szName)),
|
|
DBIERR_NONE, ' Error - PutField.');
|
|
|
|
{ put the Street (szStreet) into the record buffer. }
|
|
ChkRslt(DbiPutField(hCur, 3, pRecBuf, (szStreet)),
|
|
DBIERR_NONE, ' Error - PutField.');
|
|
|
|
{ put the City (szCity) into the record buffer. }
|
|
ChkRslt(DbiPutField(hCur, 4, pRecBuf, (szCity)),
|
|
DBIERR_NONE, ' Error - PutField.');
|
|
|
|
{ put the State (szState_prov) into the record buffer. }
|
|
ChkRslt(DbiPutField(hCur, 5, pRecBuf, (szState_prov)),
|
|
DBIERR_NONE, ' Error - PutField.');
|
|
|
|
{ put the Zip Code (szZIP_PST_CD) into the record buffer. }
|
|
ChkRslt(DbiPutField(hCur, 6, pRecBuf, (szZIP_PST_CD)),
|
|
DBIERR_NONE, ' Error - PutField.');
|
|
|
|
{ put the Country (szCountry) into the record buffer. }
|
|
ChkRslt(DbiPutField(hCur, 7, pRecBuf, (szCountry)),
|
|
DBIERR_NONE, ' Error - PutField.');
|
|
|
|
{ put the Phone number (szPhone) into the record buffer. }
|
|
ChkRslt(DbiPutField(hCur, 8, pRecBuf, (szPhone)),
|
|
DBIERR_NONE, ' Error - PutField.');
|
|
|
|
{ Encode the date into the format which Paradox Understands. }
|
|
ChkRslt(DbiDateEncode(uMonth, uDay, iYear, sDate),
|
|
DBIERR_NONE, ' Error - DateEncode.');
|
|
|
|
{ put the date (Date) into the record buffer. }
|
|
ChkRslt(DbiPutField(hCur, 9, pRecBuf, @(sDate)),
|
|
DBIERR_NONE, ' Error - PutField.');
|
|
|
|
Screen(' Insert the record into the table...');
|
|
rslt := ChkRslt(DbiInsertRecord(hCur, dbiNOLOCK, pRecBuf),
|
|
DBIERR_NONE, ' Error - InsertRecord.');
|
|
|
|
FreeMem(pRecBuf, TblProps.iRecBufSize * sizeof(BYTE));
|
|
|
|
AddRecord := rslt;
|
|
end;
|
|
|
|
{=====================================================================
|
|
Code: FindRecord();
|
|
|
|
Input: hDBICur *phCur - pointer to the cursor handle
|
|
FLOAT fCust_ID - Customer ID
|
|
|
|
Return: Result of finding the record
|
|
|
|
Description:
|
|
This function will search the given table for the indicated
|
|
record.
|
|
===================================================================== }
|
|
function FindRecord (phCur: hDBICur; fCust_ID: FLOAT): DBIResult;
|
|
|
|
var
|
|
rslt: DBIResult; { Return value from IDAPI functions }
|
|
pRecBuf: pBYTE; { Record Buffer to contain the searched for value }
|
|
TblProps: CURProps; { Properties of the table - used to determine
|
|
the size of the record buffer }
|
|
|
|
begin
|
|
{ create the key buffer. }
|
|
ChkRslt(DbiGetCursorProps(phCur,TblProps), DBIERR_NONE,
|
|
' Error - GetCursorProps.');
|
|
|
|
GetMem(pRecBuf, TblProps.iRecBufSize);
|
|
if not Assigned (pRecBuf) then
|
|
begin
|
|
Screen(' Error - Out of memory.');
|
|
FindRecord := DBIERR_NOMEMORY;
|
|
exit;
|
|
end;
|
|
|
|
{ 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. }
|
|
ChkRslt(DbiPutField(phCur, 1, pRecBuf, @(fCust_ID)), DBIERR_NONE,
|
|
' Error - 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);
|
|
|
|
FreeMem(pRecBuf, TblProps.iRecBufSize);
|
|
FindRecord := rslt;
|
|
end;
|
|
|
|
|
|
{=====================================================================
|
|
Code: SoftDel();
|
|
|
|
Input: None.
|
|
|
|
Return: None.
|
|
|
|
Description:
|
|
This example shows how the state of the Soft-Delete flag
|
|
effects 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 had been packed.
|
|
===================================================================== }
|
|
|
|
var
|
|
hDb: hDBIDb; { Handle to the Database }
|
|
hCur: hDBICur; { Handle to the table }
|
|
rslt: DBIResult; { Return value from IDAPI functions }
|
|
bSoftDelete: BOOL; { Soft-Delete enabled? }
|
|
uLength: UINT16; { Space required to store property }
|
|
const
|
|
fCust_ID: FLOAT = 1000.0; { Customer ID for the record which is
|
|
added to the table }
|
|
|
|
begin
|
|
Screen('*** Soft Delete Example ***');
|
|
|
|
Screen(' Initializing IDAPI...');
|
|
if (InitAndConnect(hDb) <> DBIERR_NONE) then { Terminate example if }
|
|
begin { Initialization fails }
|
|
Screen('');
|
|
Screen('*** End of Example ***');
|
|
exit;
|
|
end;
|
|
|
|
Screen(' Setting the default Database directory...');
|
|
ChkRslt(DbiSetDirectory(hDb, pCHAR(szTblDirectory)), DBIERR_NONE,
|
|
' Error - SetDirectory.');
|
|
|
|
Screen(' Open the '+szTblName+' table...');
|
|
if (ChkRslt(DbiOpenTable(hDb, pCHAR(szTblName), pCHAR(szTblType),
|
|
'CUST.MDX', 'CUST_NO', 0, dbiREADWRITE,
|
|
dbiOPENEXCL, xltFIELD, FALSE, nil, hCur),
|
|
DBIERR_NONE, ' Error - OpenTable.') <> DBIERR_NONE) then
|
|
begin
|
|
CloseDbAndExit(hDb);
|
|
Screen('');
|
|
Screen('*** End of Example ***');
|
|
exit;
|
|
end;
|
|
|
|
Screen(' Switch to the CUST_NO index...');
|
|
ChkRslt(DbiSwitchToIndex(hCur, 'CUST.MDX', 'CUST_NO', 0, FALSE),
|
|
DBIERR_NONE, ' Error - 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) then
|
|
begin
|
|
Screen(' Close the Database and exit IDAPI...');
|
|
CloseDbAndExit(hDb);
|
|
Screen('');
|
|
Screen('*** End of Example ***');
|
|
exit;
|
|
end;
|
|
|
|
Screen(' Delete the record which we have just added to the table...');
|
|
ChkRslt(DbiSetToBegin(hCur), DBIERR_NONE, ' Error - SetToBegin.');
|
|
|
|
{ First need to find the record which we have added to the table. }
|
|
rslt := FindRecord(hCur, fCust_ID);
|
|
ChkRslt(rslt, DBIERR_NONE, ' Error - FindRecord.');
|
|
if (rslt = DBIERR_NONE) then
|
|
begin
|
|
{ Need to move the current record pointer in the cursor to the
|
|
found record. }
|
|
ChkRslt(DbiGetNextRecord(hCur, dbiNoLock, nil, nil), DBIERR_NONE,
|
|
' Error - GetNextRecord.');
|
|
|
|
ChkRslt(DbiDeleteRecord(hCur, nil), DBIERR_NONE,
|
|
' Error - DeleteRecord.');
|
|
end;
|
|
|
|
{ Determine the state of Soft-delete }
|
|
ChkRslt(DbiGetProp( hDBIObj(hCur), curSOFTDELETEON,
|
|
@(bSoftDelete),
|
|
sizeof(BOOL), uLength), DBIERR_NONE,
|
|
' Error - GetProp.');
|
|
|
|
Screen(' ');
|
|
if (bSoftDelete) then
|
|
Screen(' Display the table with SoftDelete: ON')
|
|
else
|
|
Screen(' Display the table with SoftDelete: OFF');
|
|
ChkRslt(DbiSetToBegin(hCur), DBIERR_NONE, ' Error - SetToBegin.');
|
|
DisplayTable(hCur, 10);
|
|
|
|
{ Toggle the Soft-delete property }
|
|
bSoftDelete := not bSoftDelete;
|
|
ChkRslt(DbiSetProp(hDBIObj(hCur), curSOFTDELETEON,
|
|
UINT32(bSoftDelete)), DBIERR_NONE,
|
|
' Error - GetProp.');
|
|
|
|
ChkRslt(DbiGetProp(hDBIObj(hCur), curSOFTDELETEON, @bSoftDelete,
|
|
sizeof(BOOL), uLength), DBIERR_NONE,
|
|
' Error - GetProp.');
|
|
|
|
Screen(' ');
|
|
if (bSoftDelete) then
|
|
Screen(' Display the table with SoftDelete: ON')
|
|
else
|
|
Screen(' Display the table with SoftDelete: OFF');
|
|
|
|
ChkRslt(DbiSetToBegin(hCur), DBIERR_NONE, ' Error - SetToBegin.');
|
|
DisplayTable(hCur, 10);
|
|
|
|
{ Pack the table. Note that packing is required in order to remove
|
|
deleted records from a dBASE table. }
|
|
Screen('');
|
|
Screen(' Pack the table - physically delete the record'+
|
|
' from the '+szTblName+' table...');
|
|
ChkRslt(DbiPackTable(hDb, hCur, nil, nil, TRUE),
|
|
DBIERR_NONE, ' Error - PackTable.');
|
|
|
|
Screen(' ');
|
|
if (bSoftDelete) then
|
|
Screen(' Display the table with SoftDelete ON after packing...')
|
|
else
|
|
Screen(' Display the table with SoftDelete OFF after packing...');
|
|
ChkRslt(DbiSetToBegin(hCur), DBIERR_NONE, ' Error - SetToBegin.');
|
|
DisplayTable(hCur, 10);
|
|
|
|
Screen('');
|
|
Screen(' Close the '+szTblName+' table...');
|
|
ChkRslt(DbiCloseCursor(hCur), DBIERR_NONE,
|
|
' Error - CloseCursor.');
|
|
|
|
Screen('');
|
|
Screen(' Close the Database and exit IDAPI...');
|
|
CloseDbAndExit(hDb);
|
|
|
|
Screen('*** End of Example ***');
|
|
|
|
end.
|