Page 1 of 1

Converting DLL to Gambas Libary

Posted: Monday 17th May 2021 4:15pm
by AndyGable
Hi Everyone,

I hope someone could advice me on this issue.

I have a DLL that has been custom wrote for me to provide promotional support to my Point of sale system (I paid for this to be created)

I have spoken to the company that did this DLL and they can not and will not convert it for use with Gambas. (as they use FreeBASIC in Linux)

Is is possible to convert a DLL to become a Library File for Gambas? ( I am happy to pay a small amount for someone to do this if it is possible)

Re: Converting DLL to Gambas Libary

Posted: Monday 17th May 2021 4:50pm
by BruceSteers
You should just be able to load the dll into gambas.
http://gambaswiki.org/wiki/howto/extern

Not my area of expertise I'm afraid, Steve and Voutt are masters of this kind of thing.
As long as you have the function names/parameters details it "should" be not too complicated.

Re: Converting DLL to Gambas Libary

Posted: Monday 17th May 2021 4:53pm
by BruceSteers
Can you get the source code?

If you have paid for it i'd ask for the source.
you may be able to re-write/convert it by hand

or if the dll is not useable then get the FreeBasic version of the library

Re: Converting DLL to Gambas Libary

Posted: Monday 17th May 2021 6:34pm
by vuott
If you have and want to use an external library, it means that you intend to use the functions and other resources contained in that library.
Generally in Gambas external functions of a shared library (.so), no DLL, can be called.
Such external libraries must be written in C language. In Gambas it is also possible to use external ".so" libraries, written in C ++, but their use is much more complex.

A conversion from the DLL library source can have two answers in my opinion:
- patiently :? convert each resource (and therefore the code contained in any external functions) of the DLL library into Gambas language (...this is not always possible);
- convert the library from "Dynamic Library " DLL into "Shared Library " .SO, so that then the external functions are called with the keyword "Extern " in your Gambas program.

Anyway, could you show us the source code of your dynamic library .DLL ?

Re: Converting DLL to Gambas Libary

Posted: Monday 17th May 2021 6:53pm
by AndyGable
BruceSteers wrote: Monday 17th May 2021 4:53pm Can you get the source code?

If you have paid for it i'd ask for the source.
you may be able to re-write/convert it by hand

or if the dll is not useable then get the FreeBasic version of the library
I have the source code it was written in Visual studios 2019

Re: Converting DLL to Gambas Libary

Posted: Monday 17th May 2021 6:55pm
by AndyGable
vuott wrote: Monday 17th May 2021 6:34pm If you have and want to use an external library, it means that you intend to use the functions and other resources contained in that library.
Generally in Gambas external functions of a shared library (.so), no DLL, can be called.
Such external libraries must be written in C language. In Gambas it is also possible to use external ".so" libraries, written in C ++, but their use is much more complex.

A conversion from the DLL library source can have two answers in my opinion:
- patiently :? convert each resource (and therefore the code contained in any external functions) of the DLL library into Gambas language (...this is not always possible);
- convert the library from "Dynamic Library " DLL into "Shared Library " .SO, so that then the external functions are called with the keyword "Extern " in your Gambas program.

Anyway, could you show us the source code of your dynamic library .DLL ?
I can show you a snipe as for some reason the compnay did the DLL in seperate functions

Code: Select all

Imports System.Xml

Public Class _
  AnyOfDiscountProduct

  Inherits DiscountProduct

  Public Overrides Function _
    Accepts(
      anItem As MultisaverDiscountItem) _
    As Boolean

    Return (
      _barCodes.Contains(anItem.Item.Product.BarCode) AndAlso
      Not Filtered(anItem))
  End Function

  Public Overrides Function _
    FromXml(
      aNode As XmlNode,
      aSupportedFilters As FilterFactory) _
    As DiscountProduct

    MyBase.FromXml(aNode, aSupportedFilters)

    For _
      Each child As XmlNode _
      In aNode.ChildNodes

      If (child.Name.ToLower() = "barcode") Then
        _barCodes.Add(child.InnerText.Trim())
      End If
    Next

    Return (Me)
  End Function

  Private _
    _barCodes As New List(Of String)
End Class
The DLL handles the promotions like

buy one get one free or any 6 get 10% off the total lot

The VB app would send to the module every item that is scanned and when the total key is pressed I would get a result of all offers that
was processed.

I have tired in the past to support the offers etc with in my app and code them myself but I could never get it to work and this DLL handles
them perfectly

Re: Converting DLL to Gambas Libary

Posted: Monday 17th May 2021 7:02pm
by vuott
I do not know Visual studios 2019 language, but it seems to me a Basic dialect. Most likely it could be translated directly into Gambas.
It also seems to me that there are references to other functions or in any case to other resources external to that your posted code.

Re: Converting DLL to Gambas Libary

Posted: Monday 17th May 2021 7:06pm
by vuott
Sorry, have you ever thought about writing a Gambas code yourself, to solve that problem ?

Re: Converting DLL to Gambas Libary

Posted: Monday 17th May 2021 7:37pm
by AndyGable
vuott wrote: Monday 17th May 2021 7:02pm I do not know Visual studios 2019 language, but it seems to me a Basic dialect. Most likely it could be translated directly into Gambas.
It also seems to me that there are references to other functions or in any case to other resources external to that your posted code.
Yes the code I sent is a veriest of BASIC (Visual BASIC) As all of my EPoS systems are Done in Visual basic (visual studio 2008 for my part) I am very up on VB but I am still getting my head around Gambas

From what I can see the code is not using any Windows only API the only thing it is importing is a XML framework as that is the format the data comes from the back office system (as that was what the other company requested I output to them in)
vuott wrote: Monday 17th May 2021 7:06pm Sorry, have you ever thought about writing a Gambas code yourself, to solve that problem ?
I would love to write it myself but I never managed to get it to work in VB ever (that is why I had to pay another software company to create the DLL for me in the first place.)

Re: Converting DLL to Gambas Libary

Posted: Monday 17th May 2021 8:42pm
by vuott
You could try writing in Gambas and ask for help in this forum in case of difficulty.
Otherwise someone who knows the Visual basic / Visual studio for conversion should step in to help you here.