Files
TeslaRel410/BORLAND/BDE/EXAMPLES/PASCAL/SEARCH.PAS
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

148 lines
4.7 KiB
ObjectPascal

{ search.pas }
program Search;
{$N+}
{$IfDef VER80}
uses SnipTool, SnipData, SysUtils, WinTypes, WinProcs,
DbiProcs, DbiTypes, DbiErrs;
{$Else}
uses WinTypes, WinCrt, Strings, DbiProcs, DbiTypes, DbiErrs,
SnipTool, SnipData;
{$EndIf}
const
szTblName = 'customer'; { Name of table to be created. }
szTblType = szPARADOX; { Table type to use. }
{========================================================================
Code: SearchTable();
Input: None.
Return: None.
Description:
This sample code will open a customer table and search it
for the key.
======================================================================== }
var
rslt: DBIResult; { Value returned from IDAPI functions }
hDb: hDBIDb; { Handle to the database }
hCur: hDBICur; { Handle to the table }
TblProps: CURProps; { Table properties }
sCustNum: String;
const
pBuf: pBYTE = nil; { Pointer to the record buffer }
fCustNum: FLOAT = 3052.00; { FLOAT value to seach for }
szKey: pCHAR = 'Sarasota'; { CHAR value to search for }
begin
Screen('*** Search Record 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 Database directory...');
ChkRslt(DbiSetDirectory(hDb, pCHAR(szTblDirectory)), DBIERR_NONE,
' Error - SetDirectorry.');
Screen(' Opening the Customer Table...');
rslt := ChkRslt(DbiOpenTable(hDb, pCHAR(szTblName), pCHAR(szTblType),
nil, nil, 0, dbiREADWRITE,
dbiOPENSHARED, xltFIELD, FALSE, nil,
hCur),
DBIERR_NONE, ' Error - OpenTable.');
if (rslt <> DBIERR_NONE) then { Check if successfull }
begin
Screen(' Close the Database and exit IDAPI...');
CloseDbAndExit(hDb);
Screen('');
Screen('*** End of Example ***');
exit;
end;
{ Get the properties of the table in order to create the correct
buffer size for the record. }
ChkRslt(DbiGetCursorProps(hCur,TblProps), DBIERR_NONE,
' Error - GetCursorProps.');
GetMem(pBuf, TblProps.iRecBufSize);
if not Assigned (pBuf) then
begin
Screen(' Error - Out of memory.');
Screen(' Close the Database and exit IDAPI...');
CloseDbAndExit(hDb);
Screen('');
Screen('*** End of Example ***');
exit;
end;
ChkRslt(DbiPutField(hCur, 1, pBuf, @(fCustNum)), DBIERR_NONE,
' Error - PutField.');
{ Example 1: Search for full key value using a record buffer. }
Str(fCustNum : 7 : 2, sCustNum);
Screen(' Searching for the record where field: Customer'+
' Number := '+ sCustNum);
rslt := DbiSetToKey(hCur, keySEARCHEQ, FALSE, 0, 0, pBuf);
if (rslt = DBIERR_NONE) then
begin
{ Cursor is left on the crack before the record. }
Screen('');
Screen(' Record was found:');
DisplayNextRecord(hCur);
end
else
begin
Screen('');
Screen(' Record was not found...');
ChkRslt(rslt, DBIERR_NONE, ' Error - SetToKey.');
end;
{ Example 2: Search on a partial key value using a direct buffer. }
Screen('');
Screen(' Switching to the "Place" index...');
ChkRslt(DbiSwitchToIndex(hCur, pCHAR('Place'), nil, 0, FALSE),
DBIERR_NONE, ' Error - SwitchToIndex.');
Screen(' Searching for the record using the "Place" index'+
' where');
Screen(' the field: City = "'+StrPas(szKey)+'"... ');
rslt := DbiGetRecordForKey(hCur, TRUE, 0, StrLen(szKey),
(szKey), nil);
if (rslt = DBIERR_NONE) then
begin
{ Cursor is left on the record. }
Screen('');
Screen(' Record was found:');
DisplayCurrentRecord(hCur);
end
else
begin
Screen('');
Screen(' Record was not found... ');
ChkRslt(rslt, DBIERR_NONE, ' GetRecordForKey.');
end;
Screen('');
Screen(' Close the Table...');
ChkRslt(DbiCloseCursor(hCur), DBIERR_NONE,
' Error - CloseCursor.');
FreeMem(pBuf, TblProps.iRecBufSize);
Screen(' Close the Database and exit IDAPI...');
CloseDbAndExit(hDb);
Screen('*** End of Example ***');
end.