I ’am completely new to FreeBasic, but i have made a program in PowerBasic for Windows that I want to use ( database Btrieve/Pervasive) . I have tried with a number of different variants but nothing works. After correcting a series of errors, the errors are now localized to declarations and calls.
I am now in need of some help or guidance. How should the declaration and call be declared, where should it be stored to be found for the compiler?
Thank’s in advance
Code: Select all
Declare Function BTRCALL Lib "wbtrv32.dll" (ByVal Word, Asciiz, any, Integer, Any, ByVal Byte, ByVal Byte) As Integer
Const KEY_BUF_LEN = 255
Type RecordBuffer ’ test file
Number As Double
Dummy As String * 26
End Type
' ** START **
dim DataBuf As RecordBuffer
dim PosBlk As ZString *129 'Asciiz * 129
dim BufLen As Integer
Dim FilName As String
Dim KeyBuffer As ZString *KEY_BUF_LEN + 1 'Asciiz * KEY_BUF_LEN + 1
Dim KeyBufLen As Byte
Dim KeyNumber As Integer
Dim Stat As Integer
Dim KeyNum As Integer
Dim TMP As string
FILNAME = "TEST.BTR"
PosBlk = Space$(128)
KeyBuffer = Space$(KEY_BUF_LEN)
'>> Open File
KeyBufLen = KEY_BUF_LEN
KeyBuffer = FILNAME
BufLen = Len(DataBuf)
KeyNum = 0
Stat = BTRCALL(0, PosBlk, DataBuf, BufLen, KeyBuffer, KeyBufLen, KeyNum)
'>> Get First Record
BufLen = Len(DataBuf)
KeyBuffer = Space$(255)
KeyBufLen = KEY_BUF_LEN
Stat = BTRCALL(12, PosBlk, DataBuf, BufLen, KeyBuffer, KeyBufLen, 0)
If Stat <> 0 Then
TMP = TMP & "**Error on GETFIRST. " & Str$(Stat) & chr$(13,10)
Else
TMP = TMP & "GETFIRST = " & DataBuf.Dummy & chr$(13,10)
End If
'>> Get Next Record
BufLen = Len(DataBuf)
KeyBuffer = Space$(KEY_BUF_LEN)
KeyBufLen = KEY_BUF_LEN
Stat = BTRCALL(6, PosBlk, DataBuf, BufLen, KeyBuffer, KeyBufLen, 0)
If Stat <> 0 Then
TMP = TMP & "**Error on GETNEXT. " & Str$(Stat) & chr$(13,10)
Else
TMP = TMP & "GETNEXT = " & DataBuf.Dummy & chr$(13,10)
End If
'>> Close File
Stat = BTRCALL(1, PosBlk, DataBuf, BufLen, KeyBuffer, KeyBufLen, KeyNum)
If Stat <> 0 Then
TMP = TMP & "**Error on Close!" & Str$(Stat) & chr$(13,10)
Else
TMP = TMP & "CLOSE OK." & chr$(13,10)
End If
? TMP