Creating a library
Posted: Wednesday 16th November 2022 12:14pm
A library is just a group of subs and functions but should it have a different format than a normal project? Every project should have a startup method but for a library isn't it redundant?
I tried creating this toy library, following the instructions in the docs :
I tried creating this toy library, following the instructions in the docs :
' Gambas module file
Export
Public Function add(a As Single, b As Single) As Single
Return a + b
End
Public Function subtract(a As Single, b As Single) As Single
Return a - b
End
Public Function multiply(a As Single, b As Single) As Single
Return a * b
End
Public Function divide(a As Single, b As Single) As Single
Return a / b
End
I saved the code as a library and the executable is in ./local/share/gambas3/lib (called arithmetic.gambas), but when I try to access it (after loading it) in a new project, using say arithmetic.add(), I get an "unknown identifier" error. I'm probably doing a whole lot of things wrong here, and I suspect it's because I'm still confused about OOP. I'm still stuck in the procedural way of doing things.