• Prototyping QRcode Apis (Non Clarion DLL)

    From paul.blero@21:1/5 to All on Thu Nov 15 07:36:08 2018
    Hello,

    I have somme problems to insert in my program non windows Api.

    This is the first time I do that and I'm a little lost

    I'm still working with Clarion 6.3.

    I used libamker to create .lib file.

    I included this .lib in my project structure.

    Now, I try to prototype some functions with complex structure

    First problem :

    typedef struct {
    int version; // version of the symbol
    int width; // width of the symbol
    unsigned char *data; // symbol data
    } QRcode;

    For me it is

    QRcode group,type
    version long
    width long
    data *byte
    end

    But I have an error when I compile the program (*byte).

    Second problem - prototyping the functions :

    int CreateStaticQRCode(LPCWSTR posId, QRcode **qrCode);

    LPCWSTR is CSTRING (Right ?)
    I have a problem with **qrCode. I don't know what I have to write

    int SaveQRCodeAsBitmap(QRcode *code, int pixelSize, LPCWSTR filePath);

    Same problem with *code.

    Could you help me to solve my problem.

    I don't know if all of this is possible in this Clarion version.

    Thank you in advance.

    Paul

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Paul Attryde@21:1/5 to paul.blero on Thu Nov 15 18:04:43 2018
    On 15-Nov-18 10:36 AM, paul.blero wrote:> Hello,

    I have somme problems to insert in my program non windows Api.

    This is the first time I do that and I'm a little lost

    I'm still working with Clarion 6.3.

    I used libamker to create .lib file.

    I included this .lib in my project structure.

    OK, that's right so far

    Now, I try to prototype some functions with complex structure

    First problem :

    typedef struct {
    int version; // version of the symbol
    int width; // width of the symbol
    unsigned char *data; // symbol data
    } QRcode;

    For me it is

    QRcode group,type
    version long
    width long
    data *byte
    end

    But I have an error when I compile the program (*byte).

    Yes. "unsigned char *data" is a pointer to data of type 'unsigned char'
    aka byte. But CW doesn't have the concept of a data pointer type.

    I have to admit I have a terrible habit of prototyping any type of
    pointer as a ulong, but it works for me.

    So, when you have to get creative:

    QRcode group,type
    version long
    width long
    data ulong
    end

    Then you have something like:

    fred byte,dim(100)
    code
    fred = ! whatever
    qrcode:data = address(fred)

    Second problem - prototyping the functions :

    What's the calling convention? It's not the CW internal one, it'll
    either be C or Pascal
    So you'll need the relevant thing on the end of your prototype

    int CreateStaticQRCode(LPCWSTR posId, QRcode **qrCode);

    CreateStaticQRCode(ulong,ulong),int,c
    OR
    CreateStaticQRCode(ulong,ulong),int,pascal

    The **qrcode implies a pointer to a pointer to some data.
    Which is wierd, but not entirely unheard of.
    Assuming I'm right, off the top of my head it might be something like this:

    fred dim,byte(100)
    ptr1 ulong
    ptr2 ulong
    code
    fred = ! whatever
    ptr1 = address(fred)
    ptr2 = address(ptr1)
    returnedvalue = CreateStaticQRCode(100,address(ptr2))

    int SaveQRCodeAsBitmap(QRcode *code, int pixelSize, LPCWSTR filePath);

    Same concept:
    SaveQRCodeAsBitmap(ulong,ulong,ulong),int,C

    fred like(qrcode)
    filename cstring(300)
    code
    fred = ! whatever
    filename = 'c:\fred.bmp'
    returnedvalue = SaveQRCodeAsBitmap(address(fred),100, address(filename))


    hth,
    Paul

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From paul.blero@21:1/5 to All on Fri Nov 16 03:44:21 2018
    Hi Paul,

    Very interesting your solution.

    I tried it but my application crashed (unhandled win32 exception [1496])

    I agree with you for the group declaration.

    But I had to change your instructions a bit.

    To begin, I take the first function

    MAP
    MODULE('QRCODE.LIB')
    CreateStaticQRCode(ulong, ulong),byte,c
    END
    END

    So, I define

    fred group(QRcode)
    end
    ptr0 ulong
    ptr1 ulong
    ptr2 ulong
    posId cstring(29)

    In the code

    posId = '2COMPANY*0C123456789F12345678'

    ptr0 = address(posid)
    ptr1 = address(fred)
    ptr2 = address(ptr1)
    returnvalue = CreateStaticQRCode(address(ptr0),address(ptr2))

    But the application crashed.

    I have tried with C or Pascal => same result.

    Some informations about my application.

    ABC Template.

    Dictionnay in an app (dll)
    programs in several apps (others dlls)
    Main program in a separate app (exe)

    The dll in which I have added the instructions is called edition.app

    The procedure where I added the api definitions named PrintInvoice.

    I added the qrcode.lib in Project Editor / Library, Object and ressourcs file (in this app).

    Is that correct?

    The qrcode.dll file is in the same directory.

    How does the program make the connection between the 2 files?

    Maybe I forgot something?

    Thank you for your help.

    Paul

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From paul.blero@21:1/5 to All on Fri Nov 16 08:12:09 2018
    Hi, Paul

    I found how to access to the apis.

    I had to put my module in the global map of my application.

    Next step : to create qrcode without error.

    Thank you for your help.

    Paul

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)