Announcement

Collapse
No announcement yet.

Calling DLL from Visual FoxPro

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

  • Tom Hanlin
    replied
    Umm, no. MSDN is a wonderful resource, but not so much "well organized"
    as "well disorganized". It's in there somewhere, presumably buried in
    the "Visual Tools and Languages" / "Microsoft Visual FoxPro 7.0" tree.
    Sorry.

    ------------------
    Tom Hanlin
    PowerBASIC Staff

    Leave a comment:


  • Joshua Zavelovich
    replied
    Originally posted by Tom Hanlin:
    Digging around in MSDN turns up the following correspondences...


    Tom ,

    Could you point out the MSDN document that you found?

    Joshua

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

    Leave a comment:


  • Tom Hanlin
    replied
    It's useful to know that VB doesn't really support passing strings BYVAL,
    at least, not to DLLs. When you tell VB "BYVAL string", it actually just
    converts the string to ASCIIZ form before passing it by reference. On
    return from the call, VB translates the ASCIIZ result back to a VB string.

    It is conceivable that FoxPro uses a similar approach, in which case, the
    BYVAL does not mean that you can't change the string...!

    ------------------
    Tom Hanlin
    PowerBASIC Staff

    Leave a comment:


  • Peter Redei
    replied
    All of my DLLs are written in PB 5.0 or 6.0. I am not a VFP programmer either. Yet, I sold quite a lot for VFP and the workaround seems to work. I use in PB ASCIIZ passed as parameter. This translates in VFP to String. Since it is identical in VB as passing a string BYVAL it can not be used to hold a return value. Yet, a function that returns a string value in both PB and VFP works. I suspect that there is a better and more elegant way than my approach, but I did not want to learn VFP just for that.

    Regards,

    Peter Redei


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

    Leave a comment:


  • Tom Hanlin
    replied
    Digging around in MSDN turns up the following correspondences.
    Code:
    Visual FoxPro   PowerBASIC
    -------------   ----------
    SHORT           INTEGER
    INTEGER         LONG
    SINGLE          SINGLE
    DOUBLE          DOUBLE
    LONG            LONG
    STRING          ASCIIZ  ?
    It appears that a FoxPro string may be the same as ASCIIZ * 254 or
    ASCIIZ * 255, but this is not wholly clear.

    The docs show methods for BYVAL and BYREF declarations so, unless
    there is some profound and unexpected problem with FoxPro, there
    ought to be a way to set up the interface you need. I gather that
    we are short of FoxPro users here, however. You might ask in a FoxPro
    forum for someone who is familiar with the syntax for declaring and
    calling DLLs.

    ------------------
    Tom Hanlin
    PowerBASIC Staff

    Leave a comment:


  • Joshua Zavelovich
    replied
    Originally posted by Peter Redei:
    Yes, your observation is correct. I am passing max. three variables that needs to return values. All I can tell you is that, so far nobody complained about this technic and it seems to work.
    In fact, passing a selection parameter by value as 1,2,3,4... etc. can be used in a loop to return values.
    If you find any other way that works with VFP please let me know.

    Sincerely,


    Peter Redei

    Peter,

    I have no problem with invoking the rotine in the loop, but I cannot pass even a single parameter of either type.
    Also the execution of my DLL routine cannot be repeated for the same set of some parameters due to specifics of the application.
    I have my douts now whether the data type definitions like STRING, SINGLE, INTEGER in PB and VFP mean the same thing.
    Have you written your DLL in PB or you used another language?

    Regards,

    Joshua



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

    Leave a comment:


  • Peter Redei
    replied
    Yes, your observation is correct. I am passing max. three variables that needs to return values. All I can tell you is that, so far nobody complained about this technic and it seems to work.
    In fact, passing a selection parameter by value as 1,2,3,4... etc. can be used in a loop to return values.
    If you find any other way that works with VFP please let me know.

    Sincerely,


    Peter Redei

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

    Leave a comment:


  • Joshua Zavelovich
    replied
    Peter,

    I got your documentation. I can see that you have problems
    with VFP when you need to pass parametrs by reference. You constracted
    parallel functions for VFP with parametrs passed by value. I have not tried it ,
    but even if it works, it will be very akword solution for me, because I need
    several parameters to return from the SUBs.

    Joshua

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

    Leave a comment:


  • Joshua Zavelovich
    replied
    Peter,

    Thank you for quick reply. I will look up the documents on this site.

    Joshua

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

    Leave a comment:


  • Joshua Zavelovich
    replied
    Originally posted by Scott Turchin:
    I'm no fox pro expert but post what you got as for the declares adn the calling and see what I can do....
    I've got access to a foxpro whiz here..

    Scott,

    Here are the fragments of code:
    The name of the DLL file is CARDNET.DLL

    In PB the function is declared as follows:

    DEFSTR A-Z
    ''''''''''''''''''''''''''''''
    SUB CESSALEM ALIAS "CESSALEM" (amount!, cardnumber, expdate, commerror, transok%,_ lrcerror%, app_code, t_batch%, b_first%, b_last%, conf_file) EXPORT

    In Visual FoxPro: Symbol ";" carries the command over to the next line, like "_" in PB, the symbol @ designates passing of parameter by reference.

    DECLARE CESSALEM IN Cardnet SINGLE @ amount, STRING @ cardnumber, ;
    STRING @ expdate, STRING @ commerror, INTEGER @ transok, ;
    INTEGER @ lrcerror, STRING @ appcode, INTEGER @ batch, ;
    INTEGER @ first, INTEGER @ last, STRING @ conffile

    Variables are initialized. Then the function is invoked as follows:
    =CESSALEM(@amount,@cardnumber,@expdate,@commerror,@transok,@lrcerror,@appcode,;@batch,@first,@last,@conffile)

    The above statement produces the following error:

    "Declare DLL call caused an exception" that is either the number of parameters passed or the type of some parameters is wrong.

    Thank you and your Fox whiz for help.

    Joshua


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

    Leave a comment:


  • Peter Redei
    replied
    I sell two of my products for VFP too. I had problems with some of the functions, and in order to get them work with VFP I had to create alternate VFP functions.
    As I can recall I did not have problem by passing variables, but I had with passing pointers and trying to get value back from VFP.
    Take a look on the on-line documentation of RemailPlus DLL and you will see the PB as well the VFP declarations. You can get it from http://www.direct-print.com.


    Regards,


    Peter Redei

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

    Leave a comment:


  • Scott Turchin
    replied
    I'm no fox pro expert but post what you got as for the declares adn the calling and see what I can do....
    I've got access to a foxpro whiz here..

    ------------------
    Scott Turchin
    MCSE, MCP+I
    Computer Creations Software
    http://www.tngbbs.com/ccs

    Leave a comment:


  • Joshua Zavelovich
    started a topic Calling DLL from Visual FoxPro

    Calling DLL from Visual FoxPro

    I have composed a DLL in PB/DLL 6.0. I want to access the DLL routines from Visual FoxPro.
    I am able to access the routines that don't have parameters. When I am trying to call a routine with
    passing parameters, I get an Error telling me that either number of parameters, or the type of parameters
    passed to the routine are wrong. I checked these two possible reasons. None of them is there.
    I would appreciate any help from someone who had experience in calling from Visual FoxPro DLL routines
    created in PBDLL environment.

    Joshua
Working...
X