Results 1 to 8 of 8

Thread: calling activex dll

  1. #1
    Senior Member zak's Avatar
    Join Date
    Dec 2008
    Posts
    637
    Rep Power
    83

    calling activex dll

    hi
    due to the limitation of vbscript described in:
    http://www.regular-expressions.info/vbscript.html
    i want to call perl regular expressions from within thinbasic
    i have a vb6 small program to call a perl script so to provide the matches positions(match start, match end) of a pattern globally through a string. the perl script is converted to an activex dll by the activestate perl development kit PDK
    please how i can call this activex dll from thinbasic?
    i enclosed the vb6 program together with patternposition.dll and the small perl script "template.pl"
    the vb6 code is:

    Private Sub Command1_Click()
    sentence$ = Text1.Text
    ptrn$ = Text2.Text
    Dim objpattern
    Dim chk
    Set objpattern = CreateObject("patternposition.Library")
    Rem calling the procedure ptrnois within the patternposition.dll
    chk = objpattern.ptrnpos(sentence$, ptrn$)

    Text3.Text = Text3.Text & chk & vbCrLf

    Set objpattern = Nothing
    End Sub

    i wish vbscript may be replaced in the future by may be the pcre library which are compatible with perl
    here is a compiled dll for pcre but i can't manage to use it.
    http://gnuwin32.sourceforge.net/packages/pcre.htm
    also the activestate dev kit is a commercial one, while the pcre is free.
    the returned position from the patternposition.dll in the example is 3,4,20,24,27,28 ie the positions of the first match is 3,4 the second is 20,24...
    for a string "to be or not aboze sbxxyer be"
    and a pattern: (?<!a)b.*?e
    thanks
    the vb6 source and the activex dll together with perl source
    note that we need to register the DLL by regsvr32
    http://ifile.it/glh0ira/vb_perl_regex.rar

  2. #2
    Super Moderator Petr Schreiber's Avatar
    Join Date
    Aug 2005
    Location
    Brno - Czech Republic
    Posts
    7,155
    Rep Power
    736

    Re: calling activex dll

    Hi Zak,

    and welcome!
    Regarding ActiveX - I don't want to give you false hope, but I think this could be manageable via COM module.


    Petr

    P.S. Could you attach that file to this post? It seems the link you provided need some sort of registration. Once I have the file I can check whether COM module is the way to go for this task.
    Learn 3D graphics with ThinBASIC, learn TBGL!
    Windows 10 64bit - Intel Core i5-3350P @ 3.1GHz - 16 GB RAM - NVIDIA GeForce GTX 1050 Ti 4GB

  3. #3
    Senior Member zak's Avatar
    Join Date
    Dec 2008
    Posts
    637
    Rep Power
    83

    Re: calling activex dll

    sorry, i have not noticed the advanced options
    i have attached the file
    Attached Files Attached Files

  4. #4
    Senior Member zak's Avatar
    Join Date
    Dec 2008
    Posts
    637
    Rep Power
    83

    Re: calling activex dll

    yes it may be manageable by a com module
    here is my unsuccessfull code , because i don't know where should i insert the pattern string,
    COM_Execute(theclass, "ptrnpos", %TB_DISPATCH_METHOD, 2, vParam,pattern, vResult)
    
    is this legitimate?
    i must supply two strings to the dll, if it is not possible i can supply the two strings as a one string then i must modify the dll to extract the two strings from the one string.
    uses "COM"
    
    dim theclass as dword
    dim RetVal  as long
    dim vParam as variant
    dim vResult  as variant
    dim pattern  as variant
    theclass = COM_CreateObject("patternposition.Library",RetVal)
    
    vParam = "to be or not aboze sbxxyer be"
    pattern = "(?<!a)b.*?e"
    IF COM_Succeeded(RetVal) THEN
       
     COM_Execute(theclass, "ptrnpos", %TB_DISPATCH_METHOD, 2, vParam,pattern, vResult)
     msgbox 0, vResult
    end if 
    
    
    COM_Release(theclass)
    

  5. #5
    Super Moderator Petr Schreiber's Avatar
    Join Date
    Aug 2005
    Location
    Brno - Czech Republic
    Posts
    7,155
    Rep Power
    736

    Re: calling activex dll

    Hi Zak,

    here is my progress. I used COM_CallMethod to call ptrnpos and got back comma delimited serie of numbers. Is that what it should do?

    Here is the code:
    [code=thinbasic]
    uses "com", "console"

    dim objpattern as dword
    dim RetVal as long
    dim vResult as variant

    ' -- Create instance of class
    objpattern = COM_CreateObject("patternposition.Library", RetVal)
    printl "objpattern", objpattern

    printl repeat$(79, "-")

    ' -- Put parameters for method to array of variants
    %MAX_NUMBER_OF_PARAMETERS = 2
    dim datain(%MAX_NUMBER_OF_PARAMETERS) as variant
    datain(1) = "to be or not aboze sbxxyer be"
    datain(2) = "(?<!a)b.*?e"
    printl "Pattern:", datain(1)
    printl "Sentence:", datain(2)

    IF COM_Succeeded(RetVal) THEN
    printl "Object creation succeeded"

    print "Calling method..."
    printl IIF$(COM_Succeeded(COM_CallMethod(objpattern, "ptrnpos", %MAX_NUMBER_OF_PARAMETERS, datain(1), vResult )), "Success", "Failure")
    printl repeat$(79, "-")
    printl "Pattern:", datain(1)
    printl "Sentence:", datain(2)
    printl "Result:", vResult

    else
    printl "Com failed, oh no... did you registered the DLL?"

    end if

    printl repeat$(79, "-")
    COM_Release(objpattern)
    waitkey
    [/code]

    It returns the same as under PowerBASIC, I could not run your VisualBasic code as it fails to create object.
    Let me know.

    Petr

    Learn 3D graphics with ThinBASIC, learn TBGL!
    Windows 10 64bit - Intel Core i5-3350P @ 3.1GHz - 16 GB RAM - NVIDIA GeForce GTX 1050 Ti 4GB

  6. #6
    Senior Member zak's Avatar
    Join Date
    Dec 2008
    Posts
    637
    Rep Power
    83

    Re: calling activex dll

    yes, it is succeeded wonderfully, and gives the same results as
    vb6 code
    thank you very much
    regards


  7. #7
    thinBasic author ErosOlmi's Avatar
    Join Date
    Sep 2004
    Location
    Milan - Italy
    Age
    57
    Posts
    8,818
    Rep Power
    10

    Re: calling activex dll

    @Petr
    thanks for your support. You always come out with a solution. You are my angel ;D

    @zak
    welcome to thinBasic.
    COM module can do some nice good job with ActiveX components.
    Anyhow consider this area (COM interfaces) is an area we will work a lot in new year development so expect for the future great things on COM interfaces. I'm confidend while I say this because the compiler we use to develop thinBasic (PowerBasic) as done a great jump in this direction in its latest version so I'm sure we will be able to take advance of it.

    Ciao
    Eros
    www.thinbasic.com | www.thinbasic.com/community/ | help.thinbasic.com
    Windows 10 Pro for Workstations 64bit - 32 GB - Intel(R) Xeon(R) W-10855M CPU @ 2.80GHz - NVIDIA Quadro RTX 3000

  8. #8
    Super Moderator Petr Schreiber's Avatar
    Join Date
    Aug 2005
    Location
    Brno - Czech Republic
    Posts
    7,155
    Rep Power
    736

    Re: calling activex dll

    I am happy it worked
    Learn 3D graphics with ThinBASIC, learn TBGL!
    Windows 10 64bit - Intel Core i5-3350P @ 3.1GHz - 16 GB RAM - NVIDIA GeForce GTX 1050 Ti 4GB

Similar Threads

  1. ocx / activex problem
    By not in forum Free Pascal
    Replies: 2
    Last Post: 26-12-2010, 04:13
  2. Replies: 12
    Last Post: 13-06-2009, 22:00

Members who have read this thread: 0

There are no members to list at the moment.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •