zak
07-01-2011, 17:40
Hello
i have found a good regular expressions dll here:
http://www.codeproject.com/KB/library/deelx.aspx?fid=348264&fr=1
the dll demo contains the dll and a vb6 example on how to call it.
the vb6 example are working okay, i am trying to port it to thinbasic, the simplified vb6 example like this:
Private Declare Function regexp_create Lib "libdeelx.dll" () As Long
Private Declare Function result_create Lib "libdeelx.dll" () As Long
Private Declare Sub regexp_free Lib "libdeelx.dll" (ByVal hhh As Long)
Private Declare Sub result_free Lib "libdeelx.dll" (ByVal result As Long)
Private Declare Sub regexp_compile Lib "libdeelx.dll" (ByVal hhh As Long, ByVal pattern As String, ByVal flag As Long)
Private Declare Function regexp_replace Lib "libdeelx.dll" (ByVal hhh As Long, ByVal Text As String, ByVal replaceto As String, ByVal startpos As Long, ByVal times As Long, ByVal result As String, ByVal Size As Long) As Long
Private Declare Sub regexp_match Lib "libdeelx.dll" (ByVal hhh As Long, ByVal Text As String, ByVal startpos As Long, ByVal result As Long)
Private Declare Function result_ismatched Lib "libdeelx.dll" (ByVal result As Long) As Long
Private Declare Function result_start Lib "libdeelx.dll" (ByVal result As Long) As Long
Private Declare Function result_end Lib "libdeelx.dll" (ByVal result As Long) As Long
Private Sub Command1_Click()
Dim handle As Long
Dim result As Long
handle = regexp_create()
result = result_create()
regexp_compile handle, "23", 0
regexp_match handle, "ww123456", -1, result
If result_ismatched(result) <> 0 Then
MsgBox Str$(result_start(result))
MsgBox Str$(result_end(result))
Else
'...
End If
result_free result
regexp_free handle
End Sub
the corresponding non working thinbasic example like this:
Declare Function regexp_create Lib "libdeelx" () As Long
Declare Function result_create Lib "libdeelx" () As Long
Declare Sub regexp_free Lib "libdeelx" (ByVal myHandle As Long)
Declare Sub result_free Lib "libdeelx" (ByVal result As Long)
Declare Sub regexp_compile Lib "libdeelx" (ByVal myHandle As Long, ByVal pattern As String, ByVal flag As Long)
Declare Function regexp_replace Lib "libdeelx" (ByVal myHandle As Long, ByVal Text As String, ByVal replaceto As String, ByVal startpos As Long, ByVal times As Long, ByVal result As String, ByVal Size As Long) As Long
Declare Sub regexp_match Lib "libdeelx" (ByVal myHandle As Long, ByVal Text As String, ByVal startpos As Long, ByVal result As Long)
Declare Function result_ismatched Lib "libdeelx" (ByVal result As Long) As Long
Declare Function result_start Lib "libdeelx" (ByVal result As Long) As Long
Declare Function result_end Lib "libdeelx" (ByVal result As Long) As Long
Declare Function LoadLibrary Lib "KERNEL32.DLL" Alias "LoadLibraryA" (ByVal s As String) As Long
Declare Function FreeLibrary Lib "KERNEL32.DLL" Alias "FreeLibrary" (ByVal hLibModule As DWord) As Long
Dim myHandle As Long
Dim result As Long
Dim mylib As String
Dim hinst As Long
mylib = "libdeelx.dll"
myHandle = LoadLibrary(mylib)
If myHandle = 0 Then
MsgBox 0,"libdeelx cannot be found"
End If
myHandle = regexp_create()
result = result_create()
regexp_compile myHanfle, "23", 0
regexp_match myHandle, "ww123456", -1, result
If result_ismatched(result) <> 0 Then
MsgBox 0,Str$(result_start(result))
MsgBox 0,Str$(result_end(result))
Else
'...
End If
result_free result
regexp_free myHandle
but i get an error :
Variable not defined or misspelled Keyword
myHandle = regexp_create
Token found REGEXP_CREATE
even this "REGEXP_CREATE" function are declared before. and i have used also LoadLibrary.
i attach the vb6 demo the original and my simplified one with the dll.
regards
i have found a good regular expressions dll here:
http://www.codeproject.com/KB/library/deelx.aspx?fid=348264&fr=1
the dll demo contains the dll and a vb6 example on how to call it.
the vb6 example are working okay, i am trying to port it to thinbasic, the simplified vb6 example like this:
Private Declare Function regexp_create Lib "libdeelx.dll" () As Long
Private Declare Function result_create Lib "libdeelx.dll" () As Long
Private Declare Sub regexp_free Lib "libdeelx.dll" (ByVal hhh As Long)
Private Declare Sub result_free Lib "libdeelx.dll" (ByVal result As Long)
Private Declare Sub regexp_compile Lib "libdeelx.dll" (ByVal hhh As Long, ByVal pattern As String, ByVal flag As Long)
Private Declare Function regexp_replace Lib "libdeelx.dll" (ByVal hhh As Long, ByVal Text As String, ByVal replaceto As String, ByVal startpos As Long, ByVal times As Long, ByVal result As String, ByVal Size As Long) As Long
Private Declare Sub regexp_match Lib "libdeelx.dll" (ByVal hhh As Long, ByVal Text As String, ByVal startpos As Long, ByVal result As Long)
Private Declare Function result_ismatched Lib "libdeelx.dll" (ByVal result As Long) As Long
Private Declare Function result_start Lib "libdeelx.dll" (ByVal result As Long) As Long
Private Declare Function result_end Lib "libdeelx.dll" (ByVal result As Long) As Long
Private Sub Command1_Click()
Dim handle As Long
Dim result As Long
handle = regexp_create()
result = result_create()
regexp_compile handle, "23", 0
regexp_match handle, "ww123456", -1, result
If result_ismatched(result) <> 0 Then
MsgBox Str$(result_start(result))
MsgBox Str$(result_end(result))
Else
'...
End If
result_free result
regexp_free handle
End Sub
the corresponding non working thinbasic example like this:
Declare Function regexp_create Lib "libdeelx" () As Long
Declare Function result_create Lib "libdeelx" () As Long
Declare Sub regexp_free Lib "libdeelx" (ByVal myHandle As Long)
Declare Sub result_free Lib "libdeelx" (ByVal result As Long)
Declare Sub regexp_compile Lib "libdeelx" (ByVal myHandle As Long, ByVal pattern As String, ByVal flag As Long)
Declare Function regexp_replace Lib "libdeelx" (ByVal myHandle As Long, ByVal Text As String, ByVal replaceto As String, ByVal startpos As Long, ByVal times As Long, ByVal result As String, ByVal Size As Long) As Long
Declare Sub regexp_match Lib "libdeelx" (ByVal myHandle As Long, ByVal Text As String, ByVal startpos As Long, ByVal result As Long)
Declare Function result_ismatched Lib "libdeelx" (ByVal result As Long) As Long
Declare Function result_start Lib "libdeelx" (ByVal result As Long) As Long
Declare Function result_end Lib "libdeelx" (ByVal result As Long) As Long
Declare Function LoadLibrary Lib "KERNEL32.DLL" Alias "LoadLibraryA" (ByVal s As String) As Long
Declare Function FreeLibrary Lib "KERNEL32.DLL" Alias "FreeLibrary" (ByVal hLibModule As DWord) As Long
Dim myHandle As Long
Dim result As Long
Dim mylib As String
Dim hinst As Long
mylib = "libdeelx.dll"
myHandle = LoadLibrary(mylib)
If myHandle = 0 Then
MsgBox 0,"libdeelx cannot be found"
End If
myHandle = regexp_create()
result = result_create()
regexp_compile myHanfle, "23", 0
regexp_match myHandle, "ww123456", -1, result
If result_ismatched(result) <> 0 Then
MsgBox 0,Str$(result_start(result))
MsgBox 0,Str$(result_end(result))
Else
'...
End If
result_free result
regexp_free myHandle
but i get an error :
Variable not defined or misspelled Keyword
myHandle = regexp_create
Token found REGEXP_CREATE
even this "REGEXP_CREATE" function are declared before. and i have used also LoadLibrary.
i attach the vb6 demo the original and my simplified one with the dll.
regards