home *** CD-ROM | disk | FTP | other *** search
- { }
- { Module Name: TURXFACE.PAS }
- { }
- { Description: This is the Btrieve interface for Turbo Pascal (MS-DOS). }
- { This routine sets up the parameter block expected by }
- { Btrieve, and issues interrupt 7B. It should be compiled }
- { with the $V- switch so that runtime checks will not be }
- { performed on the variable parameters. }
- { }
- { Synopsis: STAT := BTRIEVE (OP, POS.START, DATA.START, KBUF.START, KEY); }
- { where }
- { OP is an integer, }
- { POS.START is the integer variant of a 128 byte array, }
- { DATA.START is the integer variant of the data buffer, }
- { KBUF.START is the integer variant of the key buffer, }
- { and KEY is an integer. }
- { }
- { Returns: Btrieve status code (see Appendix B of the Btrieve Manual). }
- { }
- { Note: It is important that the 2nd, 3rd and 4th actual parameters }
- { be declared as variant records, with an integer type as one }
- { of the variants (used for Btrieve calls). For example, }
- { }
- { var DATA = record case boolean of }
- { FALSE: ( START: integer); }
- { TRUE: ( EMPLOYEE_ID: 0..99999; }
- { EMPLOYEE_NAME: packed array [1..50] of char; }
- { SALARY: real; }
- { DATE_OF_HIRE:DATE_TYPE); }
- { end; }
- { }
- { There should NEVER be any string variables declared in the }
- { data or key records, because strings store an extra byte for }
- { the length, which affects the total size of the record. }
- { }
- function BTRIEVE (OP:integer; var POS:integer; var DATA: integer;
- var KBUF:integer; KEY:integer):integer;
- const
- PASCAL_ID = $AAAA; {PASCAL language id}
- type
- ADDR32 = record {32 bit address}
- OFFSET: integer;
- SEGMENT: integer;
- end;
- BTR_PARMS = RECORD
- USER_BUF_ADDR: ADDR32; {data buffer address}
- USER_BUF_LEN: integer; {data buffer length}
- USER_CUR_ADDR: ADDR32; {currency block address}
- USER_FCB_ADDR: ADDR32; {file control block address}
- USER_FUNCTION: integer; {Btrieve operation}
- USER_KEY_ADDR: ADDR32; {key buffer address}
- USER_KEY_LENGTH: BYTE; {key buffer length}
- USER_KEY_NUMBER: BYTE; {key number}
- USER_STAT_ADDR: ADDR32; {return status address}
- XFACE_ID: integer; {language interface id}
- end;
- var
- STAT: integer; {Btrieve Status code}
- XDATA:BTR_PARMS; {Btrieve parameter block}
-
- begin
- with XDATA do
- begin
- { USER_BUF_ADDR := ADDR(DATA[0]); {set data buffer address}
- USER_BUF_LEN := 4090; {assume it's large enough}
- { USER_FCB_ADDR := ADDR(POS); {set FCB address}
- USER_CUR_ADDR.SEGMENT:= USER_FCB_ADDR.SEGMENT; {set cur segment}
- USER_CUR_ADDR.OFFSET := USER_FCB_ADDR.OFFSET; {set cur segment}
- USER_FUNCTION := OP; {set Btrieve operation code}
- { USER_KEY_ADDR := ADDR(KBUF); {set key buffer address}
- USER_KEY_LENGTH := 255; {assume it's large enough}
- USER_KEY_NUMBER := KEY; {set key number}
- { USER_STAT_ADDR := ADDR(STAT); {return status address}
- XFACE_ID := PASCAL_ID; {set language id}
- { }
- begin inline {additional inline code cause ADDR don't work }
- ( $8B / $46 / $0C / { MOV AX,12[BP] }
- $89 / $46 / $E2 / { MOV -30[BP],AX ;data buffer seg }
- $8B / $46 / $0A / { MOV AX,10[BP] }
- $89 / $46 / $E0 / { MOV -32[BP],AX ;data buffer off }
- $8B / $46 / $10 / { MOV AX,16[BP] }
- $89 / $46 / $EC / { MOV -20[BP],AX ;fcb seg }
- $89 / $46 / $E8 / { MOV -24[BP],AX ;cur block seg }
- $8B / $46 / $0E / { MOV AX,14[BP] }
- $89 / $46 / $EA / { MOV -22[BP],AX ;fcb off }
- $05 / $26 / $00 / { ADD AX,38 }
- $89 / $46 / $E6 / { MOV -26[BP],AX ;cur block off }
- $8B / $46 / $08 / { MOV AX,8[BP] }
- $89 / $46 / $F2 / { MOV -14[BP],AX ;key buffer seg }
- $8B / $46 / $06 / { MOV AX,6[BP] }
- $89 / $46 / $F0 / { MOV -16[BP],AX ;key buffer off }
- $8D / $46 / $FC / { LEA AX,-4[BP] }
- $89 / $46 / $F6 / { MOV -10[BP],AX ;status off }
- $8C / $D0 / { MOV AX,SS }
- $89 / $46 / $F8 ) { MOV -8[BP],AX ;status seg }
- end;
- end;
-
- if MemW[$0000:$01EC] <> $0033 then {make sure Btrieve is installed}
- STAT := 20
- else
- begin inline {inline code to invoke Btrieve via interrupt 7B}
- ( $55 / { PUSH BP ;save base pointer }
- $1E / { PUSH DS ;save data segment }
- $16 / { PUSH SS ;set default data seg }
- $1F / { POP DS ; to stack seg }
- $8D / $56 / $E0 / { LES DX,XDATA ;set parm address }
- $CD / $7B / { INT 7BH ;issue interrupt }
- $1F / { POP DS ;restore data segment }
- $5D ) { POP BP ;restore base pointer }
- end;
- BTRIEVE := STAT; {return status to user}
- end;