FATS - Fast Access Tree System
Table of Contents
Programming Interfaces
Visual Basic for Windows 95/NT

Visual Basic for Windows 95/NT


 
Windows Libraries FATS_W32.DLL / FATSXW32.DLL

The diskette "FATS for Windows 95/NT" contains the dynamic link libraries FATS_W32.DLL (basis version) resp. FATSXW32.DLL (extended version), that must be copied into the system directory of Windows:

COPY FATS?W32.DLL \WINDOWS\SYSTEM

The libraries are exporting the following functions:

Private Declare Function dll_FATSInit Lib "fats_w32.dll" Alias "FATSLibInit"(ByVal nSize As Long, ByVal nAPI As Long) As Long

Private Declare Function dll_FATSExit Lib "fats_w32.dll" Alias "FATSLibExit" (ByVal lpFatsdata As Long) As Long

Private Declare Function dll_FATSCall Lib "fats_w32.dll" Alias "FATSLibCallA" (ByVal lpCmnd As String, nErrorcode As Long, nKeylen As Long, ByVal lpFatsdata As Long) As Long

Private Declare Sub dll_FATSGetKey Lib "fats_w32.dll" Alias "FATSLibGetKeyA" (ByVal lpFatsKey As String, ByVal lpFatsdata As Long)

The functions dll_FATSInit and dll_FATSExit are not needed when using Visual Basic for 32-Bit systems. They are used by other programming languages to allocate a data area for FATS.
If you need these functions for certain reasons, e.g. with several FATS sessions within one process, then you please read "Using several FATS environments" at the end of this paragraph.

 
Calling FATS

FATS commands are executed with the function dll_FATSCall:

dwRecno = dll_FATSCall(szCmnd, nErrorcode, nKeylen, 0)

Parameter Usage:

szCmndCommand string (input)
nErrorcodeErrorcode (output)
nKeylenLength of key value (output)
0Identification of the FATS environment respectively the data area of FATS. At specifying 0 the global memory area of the calling application is used.

To access the key value returned by FATS you have to code the following:

If nKeylen > 0 Then
szFatsKey = Space(nKeylen)
Call dll_FATSGetKey(szFatsKey, 0)
Else
szFatsKey = ""
End If

The dll_FATSCall function does the actual call to FATS and returnes the length of a found key in the nKeylen variable. This value should be used to assign to the key string variable the value SPACE$(nKeylen). Until your application assigns some value to the string variable, it has a length of 0.
The dll_FATSGetKey function copies the key value from the previous FATS call to the key string variable.

 
Testprograms

The FATS distribution disk for Windows 95/NT contains some test programs in the directory WIN_32I\BASIC\VBWIN that illustrate how you can use the FATS commands in your programs:

tst1_eng.makTest program for MS-Visual-Basic for Win95/NT
 tst1_eng.frm (form module)
tst1_eng.bas (program module)

The extended version of FATS contains the following additional test programs:

 tst2_eng.frmIntroduction to the Matchcode Functions
 mcsort.frmUse of the key-flag with command 'MC'

 
Using Several FATS Environments

If you want to call FATS by several threads from one application you have to take care that only one thread accesses FATS at the same time.

Therefore FATS offers the following methods:

1.) Thread Specific Processing

If you want FATS to assign a unique data area automatically to each thread you have to call the functions dll_FATSCall & dll_FATSGetKey with an identification code of 16:

dwRecno = dll_FATSCall(szCmnd, nErrorcode, nKeylen, 16)

Call dll_FATSGetKey(szFatsKey, 16)

Thereby the FATS environments of the individual threads are absolutely independent, i.e. thread 1 does not have an access to the data area assigned to thread 2.

2.) Several FATS Environments

By the use of the functions dll_FATSInit and dll_FATSExit you can assign one or more FATS environments to the threads. Unfortunately it is not always possible in the test- and development environment of Visual Basic to intercept the abortion of a program in order to return resources used by FATS to the operating system or to close still opened FATS files.

With the function dll_FATSInit you create a new FATS environment:

lpFatsdata = dll_FATSInit(0,0)

The first parameter determines the size of the FATS data area. If you indicate a zero here, then the minimum needed storage space is reserved (approx. 18-20 KB). The second parameter intends the assigned programming language, for Visual Basic this value must equal to 0. The address of the data area is returned in the variable lpFatsdata.

The memory address returned by dll_FATSInit must be used to specify the FATS environment when calling the functions dll_FATSCall and dll_FATSGetKey:

dwRecno = dll_FATSCall(szCmnd, nErrorcode, nKeylen, lpFatsdata)

Call dll_FATSGetKey(szFatsKey, lpFatsdata)

Before terminating the application program you should release the storage area allocated by dll_FATSInit . You can do this by calling the function dll_FATSExit :

lpFatsdata = dll_FATSExit( lpFatsdata )


 

© 2008  GCS Software, Udo Gertz