Announcement

Collapse
No announcement yet.

Function Pointers, OCX, Demo

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Function Pointers, OCX, Demo

    Hello,

    I am interested in Purchasing PB/DLL, however there is one thing
    that I haven't found listed in the features, which is what I am
    looking for (among all the other goodies it already has )...

    They are function pointers...

    Example is:

    Dim fpProc as (Whatever it would be, FPointer Of (Declared Function), etc...)
    Dim lPointer as Long

    lPointer = some function's address

    fpProc = lPointer

    then be able to call fpProc directly

    result = fpProc(arg1, arg2, etc...)


    This is a necessity for me, Microsoft Visual Basic doesn't have
    this all they have is VarPtr and Address Of, with no way to do
    this directly... The basis for this is to call a LoadLibrary
    at runtime, and use functions from the library at runtime,
    without having to directly know the dll name...

    And while I know C, I hate it's syntax (it's only my
    opinion) and would rather not use it to do this...
    All my programs are C-Free hehe...

    I looked at the Callback stuff with PB/DLL, however there isn't
    any detailed description on this website about it...

    Also, is it possible to create OCX (I know it's 'basically' just
    a DLL, but...) controls with this?

    Also, is there a Demo of this or anything? I don't like to
    purchase programming products without at least demoing it first
    to see if I'm comfortable with it ...

    Thanks,

    Rick Fleming

  • #2
    You can almost do anything if it's on an API level.
    The pointers you described are certainly easy.
    Forget copymemory in callbacks etc..

    Using COM is hard but can be done.
    If you can succesfully build OCX's, i don't have an example..

    Jump to the 3th party section and look for the 'jazzage'.
    He does all the COM stuff for PB.
    VB is MUCH more easy to do such things, so i will not encourage COM in PB at the moment.


    ------------------
    [email protected]
    hellobasic

    Comment


    • #3
      Function pointers are obtained with the CODEPTR intrinsic if the function is located in the current source code module or using GetProcAddress if the function is in a loaded DLL.

      You can call functions by pointer (address) using the CALL DWORD USING...TO... syntax.

      MCM


      [This message has been edited by Michael Mattias (edited September 09, 2000).]
      Michael Mattias
      Tal Systems Inc. (retired)
      Racine WI USA
      [email protected]
      http://www.talsystems.com

      Comment


      • #4
        Sweet...

        In Visual Basic you can GetProcAddress (loadlibrary) or
        Address Of (module proc) to get the function pointer,
        but you can't do anything with it but pass it around...

        Now only if there's a demo so I can see all the features
        for myself then I will probably buy it...

        Thanks,

        Rick Fleming

        Comment


        • #5
          There is no demo available at this time, be we do offer a 30-day money-back guarantee on all products (except when delivered electronically). The following pages may give you more ideas about the capability of PowerBASIC:
          http://www.powerbasic.com/products/pbdll32
          https://www.powerbasic.com/shop
          http://www.powerbasic.com/support/technote/basic.asp
          http://www.powerbasic.com/products/compiler.asp

          Thanks for asking!

          ------------------
          Lance
          PowerBASIC Support
          mailto:[email protected][email protected]</A>
          Lance
          mailto:[email protected]

          Comment


          • #6
            <<
            Jump to the 3th party section and look for the 'jazzage'.
            He does all the COM stuff for PB.
            VB is MUCH more easy to do such things, so i will not encourage COM in PB at the moment.
            >>
            That is right, VB is the best development for ActiveX programming at the moment.
            Our product do the best that can be done with the languages it supports.
            For example, our addons for Xbase++ make that language almost 'compatible'
            with VB for ActiveX client programming.

            A few extensions to PB/DLL would make it much more COM/ActiveX aware,
            but given the amount of misleading information spread in the PB
            community about those 'bloated' technologies, I don't think that
            the situation will change in a foresable future, even though announcements
            were made about 18 months ago that future versions would support COM:
            we will see what happens.

            Philippe Monteil
            [email protected]
            JAZZAge Software



            ------------------

            Comment


            • #7
              Rick,

              =======================================
              lPointer = some function's address
              fpProc = lPointer
              then be able to call fpProc directly
              result = fpProc(arg1, arg2, etc...)
              =======================================

              The things you require here are straight forward capacity in PowerBASIC.

              fpProc = lPointer

              is done with,

              fpProc = CodePtr(FunctionName) ' get address of function

              There is a high level syntax for calling a function by its address,

              CALL DWORD var USING ....

              The addressing techniques in PowerBASIC are powerful enough to do most
              things,

              address = StrPtr(basicString$) ' string addresses
              address = VarPtr(variable) ' addresses of variables, UDTs etc...
              address = CodePtr(Function/Sub) ' procedure address

              PowerBASIC has a data type of PTR so you can pass an address and get its
              actual value by using the POINTER operator [ @var ].

              If you have a background in VB, the performance enhancing capacity in
              PowerBASIC is very good when designing DLLs that must perform well. With
              your background in C, PowerBASIC gives you the C style low level capacity
              but with basic syntax.

              If high speed compiler performance is still not good enough for what you
              have to do, PowerBASIC supports a very good inline assembler so you can
              target speed critical code.

              The COM interface is another matter, it is currently a proprietry and
              complex interface that is difficult to implement in low level code. The
              current version of PowerBASIC does not provide a high level interface for
              COM objects.

              If your main experience in basic is VB, you will enjoy the sheer grunt of
              PowerBASIC, it allows you to write code that is close to the speed of
              assembler in normal basic syntax and if that is not fast enough for you,
              you can write it in assembler in PowerBASIC. The API functions are
              available as normal functions without having to mess around with extra
              declarations.

              Good luck with your choice and I hope you can get the swing of PowerBASIC.

              Regards,

              [email protected]


              ------------------
              hutch at movsd dot com
              The MASM Forum

              www.masm32.com

              Comment

              Working...
              X