FATS - Fast Access Tree System
Table of Contents
Programming Interfaces
IBM-Pascal, MS-Pascal, Quick Pascal


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 Pascal example demonstrates the use of the  FABS PLUS compatible commands:

{ Compatible Programming Interface (FABS PLUS)
  This Test Program was designed for Microsoft Pascal }

program TST0_ENG (input,output);

type

  fatskeystr = string(25);

  custrec = record
      DELETEDMARK: char;
      ID: lstring(5);
      NAME: lstring(25);
      JOB: lstring(25);
      STREET: lstring(25);
      ZIP: lstring(5);
      CITY: lstring(20);
   end;


const

  fn_demo = '..\..\..\DEMODATA\CUSTOMER.ASC';
  fn_cust = 'CUSTOMER.DAT';

var
  hCustomer: file of custrec;
  hDemodata: text;
  cbuffer: custrec;
  szCmnd: lstring(255);
  lpFatsKey: ads of fatskeystr;
  szFatskey: fatskeystr;
  szRecno: lstring(8);
  uErrorcode, count: word;
  dwRecno: integer4;
  cChar: char;


function fbspas (vars szCmnd : lstring; vars uErrorcode: word) : word; extern;

function fbpas1 (vars szCmnd : lstring; vars uErrorcode: word;
                 vars pKeyadr : word) : word; extern;

function gfseg1: word; extern;


function fatscall: integer4;
Var uKeyOfs : Word;
Var dwRecno : integer4;
begin
  dwRecno := fbpas1(szCmnd, uErrorcode, uKeyOfs);
  lpFatsKey.r:=uKeyOfs;
  lpFatsKey.s:=gfseg1;
  szFatsKey:=lpFatsKey^;
  fatscall:=dwRecno;
end;


begin

  writeln;
  writeln ('To compile and link the test program, use ONE of the following methods:');
  writeln;
  writeln ('  1. METHOD: Linking FATS to the program');
  writeln;
  writeln ('     PAS1 tst0_eng');
  writeln ('     PAS2');
  writeln ('     LINK tst0_eng fats.obj');
  writeln;
  writeln ('  2. METHOD: Calling the Workstation Engine');
  writeln;
  writeln ('     PAS1 tst0_eng');
  writeln ('     PAS2');
  writeln ('     LINK tst0_eng fatsmspr.lib   (FATS Standard Version FATS_WE.EXE)');
  writeln;
  writeln ('     or if you own the extended version of FATS:');
  writeln;
  writeln ('     LINK tst0_eng fatsxmpr.lib   (FATS Extended Version FATSXWE.EXE)');
  writeln;
  writeln ('Please press the [ENTER] key ...');
  writeln;
  read(cChar);

  { -------> open file with test data }

  assign (hDemodata, fn_demo);
  reset (hDemodata);

  { -------> create data file }

  writeln ('Creating Data File ...');
  assign  (hCustomer, fn_cust);
  hCustomer.mode:=direct;
  rewrite (hCustomer);

  { -------> create index file }

  writeln ('Creating Index File ...');
  szCmnd:='C\CUSTOMER.KEY\25\4\A\1';
  dwRecno:=fbspas(szCmnd, uErrorcode);

  { -------> insert records }

  writeln;
  writeln ('290 records will be inserted into the data file.');
  writeln ('For each record 4 keys will be stored in the index file');
  writeln;
  writeln ('Please press the [ENTER] key ...');
  read(cChar);

  count:=0;
  repeat
     cbuffer.DELETEDMARK:=' ';
     read(hDemodata, cbuffer.ID);
     read(hDemodata, cbuffer.NAME);
     read(hDemodata, cbuffer.JOB);
     read(hDemodata, cbuffer.STREET);
     read(hDemodata, cbuffer.ZIP);
     read(hDemodata, cbuffer.CITY);
     szCmnd:='I\1\';
     concat(szCmnd, cbuffer.ID);
     concat(szCmnd, '\');
     concat(szCmnd, cbuffer.NAME);
     concat(szCmnd, '\');
     concat(szCmnd, cbuffer.JOB);
     concat(szCmnd, '\');
     concat(szCmnd, cbuffer.ZIP);
     concat(szCmnd, cbuffer.CITY);
     dwRecno:=fbspas(szCmnd, uErrorcode);
     seek(hCustomer, dwRecno);
     hCustomer^:=cbuffer;
     put(hCustomer);
     writeln(cbuffer.NAME,' --> RecNo ', dwRecno:-8);
     count:=count+1;
  until (count = 290) or (uErrorcode <> 0);

  close(hDemodata);

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

  writeln;
  writeln ('This list shows some fields from the Customer Table,');
  writeln ('sorted in ascending alphabetical order on the Customers');
  writeln ('surname and forename.');
  writeln;
  writeln ('Please press the [ENTER] key ...');
  read(cChar);

  szCmnd:='F\2\1';
  repeat
    dwRecno:=fatscall;
    if (uErrorcode = 0) and (encode(szRecno, dwRecno:8)) then begin
      seek(hCustomer, dwRecno);
      get(hCustomer);
      cbuffer:=hCustomer^;
      writeln(cbuffer.NAME, ' --> RecNo ', dwRecno:-8);
      szCmnd:='A\2\';
      concat(szCmnd, szRecno);
      concat(szCmnd, '\1\');
      concat(szCmnd, szFatskey);
    end;
  until uErrorcode <> 0;

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

  writeln;
  writeln ('Two columns - JOB and NAME are displayed, sorted in ascending');
  writeln ('order by the JOB field.');
  writeln;
  writeln ('Please press the [ENTER] key ...');
  read(cChar);

  szCmnd:='F\3\1';
  repeat
    dwRecno:=fatscall;
    if uErrorcode = 0 then begin
      seek(hCustomer, dwRecno);
      get(hCustomer);
      cbuffer:=hCustomer^;
      writeln(cbuffer.JOB, ' ', cbuffer.NAME, ' --> RecNo ', dwRecno:-8);

      { Attention: SEARCH NEXT command

        Each modification of the index file by inserting or deletion
        of keys makes an internal pointer invalid that is necessary for
        the commands "N" Search Next and "P" Search Previous.
        You better use the commands "A" Search Next After and
        "E" Search Previous Before because this can happen in the
        network environment from any station. }

      szCmnd:='N\1';
    end;
  until uErrorcode <> 0;

  { -------> print list with records sorted by ZIP and CITY }

  writeln;
  writeln ('Three columns - ZIP, CITY and NAME are displayed, sorted in');
  writeln ('descending order by ZIP then CITY.');
  writeln;
  writeln ('Please press the [ENTER] key ...');
  read(cChar);

  szCmnd:='L\4\1';
  repeat
    dwRecno:=fatscall;
    if (uErrorcode = 0) and (encode(szRecno, dwRecno:8)) then begin
      seek(hCustomer, dwRecno);
      get(hCustomer);
      cbuffer:=hCustomer^;
      writeln(cbuffer.ZIP,' ', cbuffer.CITY, ' ', cbuffer.NAME, ' --> RecNo ', dwRecno:-8);
      szCmnd:='E\4\';
      concat(szCmnd, szRecno);
      concat(szCmnd, '\1\');
      concat(szCmnd, szFatskey);
    end;
  until uErrorcode <> 0;

  { -------> close index file  }

  szCmnd:='K\1';
  dwRecno:=fbspas(szCmnd, uErrorcode);

  close(hCustomer);

end.
 

© 2008  GCS Software, Udo Gertz