FATS - Fast Access Tree System
Table of Contents
Programming Interfaces
MS-Basic for OS/2


The FATS Toolkit supports a calling interface that is 100% compatible with the program FABS-Plus Net of Computer Control Systems. All programming interfaces of this software were reproduced.

There is no need to change your source code. You just need to change obj-/dll files to use FATS in existing projects, for example in the MS-DOS environment you only have to replace the FABSP module with the FATS module.

The following Microsoft Basic example demonstrates the use of the  FABS PLUS compatible commands:

PRINT "Compatible Programming Interface (FABS PLUS)"
PRINT
PRINT "This Test Program was designed for Microsoft Basic"
PRINT
PRINT "To compile and link the test program, use ONE of the following methods:"
PRINT
PRINT "  1. METHOD: Linking FATS to the program"
PRINT
PRINT "     BC tst0eng6 /Lp"
PRINT "     LINK tst0eng6 fats.obj"
PRINT
PRINT "     or if you own the extended version of FATS:"
PRINT
PRINT "     LINK tst0eng6 fatsx.obj"
PRINT
PRINT "  2. METHOD: Calling the Dynamic Link Library"
PRINT
PRINT "     BC tst0eng6 /Lp"
PRINT "     LINK tst0eng6 fatsmb6d.obj fats_o16.lib     (call FATS_O16.DLL)"
PRINT
PRINT "     or if you own the extended version of FATS:"
PRINT
PRINT "     LINK tst0eng6 fatsmb6d.obj fatsxo16.lib     (call FATSXO16.DLL)"
PRINT
INPUT "Please press the [ENTER] key ...", X$
PRINT

REM  -------> open file with test data

OPEN "R", #1, "..\..\..\DEMODATA\CUSTOMER.ASC", 105
FIELD #1, 5 AS F1$, 25 AS F2$, 25 AS F3$, 25 AS F4$, 5 AS F5$, 20 AS F6$

REM  -------> create data file

PRINT "Creating Data File ..."

OPEN "R", #2, "CUSTOMER.DAT", 128
FIELD #2, 1 AS DELETEDMARK$,_
          5 AS CUSTID$,_
         25 AS NAME$,_
         25 AS JOB$,_
         25 AS STREET$,_
          5 AS ZIP$,_
         20 AS CITY$

REM  -------> create index file

PRINT "Creating Index File ..."

CALL FABSMB("C\CUSTOMER.KEY\25\4\A\1", ERRORCODE%, RECNO%, ADRKEY%)
IF ERRORCODE% <> 0 GOTO ENDE

REM  -------> insert records

PRINT
PRINT "290 records will be inserted into the data file."
PRINT "For each record 4 keys will be stored in the index file"
PRINT
INPUT "Please press the [ENTER] key ...", X$

FOR X=1 TO 290
  GET #1,X
  LSET DELETEDMARK$=" "
  LSET CUSTID$=F1$
  LSET NAME$=F2$
  LSET JOB$=F3$
  LSET STREET$=F4$
  LSET ZIP$=F5$
  LSET CITY$=F6$
  CMND$="I\1\"+RTRIM$(CUSTID$)+"\"+RTRIM$(NAME$)+"\"+RTRIM$(JOB$)+"\"+RTRIM$(ZIP$+CITY$)
  CALL FABSMB(CMND$, ERRORCODE%, RECNO%, ADRKEY%)
  IF ERRORCODE% <> 0 GOTO ENDE
  PRINT NAME$;" --> RecNo ";RECNO%
  PUT #2,RECNO%
NEXT X

CLOSE #1

REM  -------> print all customers, sorted in ascending order by NAME

PRINT
PRINT "This list shows some fields from the Customer Table,"
PRINT "sorted in ascending alphabetical order on the Customer's"
PRINT "surname and forename."
PRINT
INPUT "Please press the [ENTER] key ...", X$

CMND$="F\2\1"
LOOP1:
  CALL FABSMB(CMND$, ERRORCODE%, RECNO%, ADRKEY%)
  IF ERRORCODE% <> 0 GOTO LABEL1
  CALL FABSGETKEY(FABSKEY$, ADRKEY%, 25)
  GET #2,RECNO%
  PRINT NAME$;" ";JOB$;" --> RecNo ";RECNO%
  CMND$="A\2\"+STR$(RECNO%)+"\1\"+FABSKEY$
  GOTO LOOP1
LABEL1:

REM  -------> print all customers, sorted in ascending order by JOB

PRINT
PRINT "Two columns - JOB and NAME are displayed, sorted in ascending"
PRINT "order by the JOB field."
PRINT
INPUT "Please press the [ENTER] key ...", X$

CMND$="F\3\1"
LOOP2:
  CALL FABSMB(CMND$, ERRORCODE%, RECNO%, ADRKEY%)
  IF ERRORCODE% <> 0 GOTO LABEL2
  GET #2,RECNO%
  PRINT JOB$;" ";NAME$;" --> RecNo ";RECNO%
  CMND$="N\1"
  GOTO LOOP2
LABEL2:

REM  -------> print list with records sorted by ZIP and CITY

PRINT
PRINT "Three columns - ZIP, CITY and NAME are displayed, sorted in"
PRINT "descending order by ZIP then CITY."
PRINT
INPUT "Please press the [ENTER] key ...", X$

CMND$="L\4\1"
LOOP3:
  CALL FABSMB(CMND$, ERRORCODE%, RECNO%, ADRKEY%)
  IF ERRORCODE% <> 0 GOTO LABEL3
  CALL FABSGETKEY(FABSKEY$, ADRKEY%, 25)
  GET #2,RECNO%
  PRINT ZIP$;" ";CITY$;" ";NAME$;" --> RecNo ";RECNO%
  CMND$="E\4\"+STR$(RECNO%)+"\1\"+FABSKEY$
  GOTO LOOP3
LABEL3:

ENDE:

REM  -------> close index file

CALL FABSMB("K\1", ERRORCODE%, RECNO%, ADRKEY%)

CLOSE #2
END


REM  -------> SUB: get the return key value from FATS

SUB FABSGETKEY (FABSKEY$, ADRKEY%, KEYLEN%)
  FABSKEY$=""
  CALL GFSEG(FSEG%)
  ADRKEY=ADRKEY%
  IF ADRKEY < 0 THEN ADRKEY=ADRKEY+65536!
  FOR X=ADRKEY TO ADRKEY+KEYLEN% - 1
    DEF SEG=FSEG%
    KCHAR=PEEK(ADRKEY)
    DEF SEG
    FABSKEY$=FABSKEY$+CHR$(KCHAR)
    ADRKEY=ADRKEY+1
  NEXT X
END SUB
 

© 2008  GCS Software, Udo Gertz