[Gambas-user] Use of a Gambas library in a module

Gianluigi bagonergi at gmail.com
Mon Oct 22 22:52:11 CEST 2018


Hi Lee,
I don't know how to respond to your comments, let's see what Benoit has to
say, the wiki page (unknown to me until now) seems to conflict with the
last code I posted (see my post with 'Dynamic libraries' attached).
Probably because it refers to the libraries loaded through the IDE dialog.
The code: Object.Call(Module1, "Main"), I think works because it is
inserted in the Sub Main (try to double click on the library).

Regards
Gianluigi

Il giorno lun 22 ott 2018 alle ore 20:51 T Lee Davidson <
t.lee.davidson at gmail.com> ha scritto:

> Yes, Gianluigi, that code does work.
>
> Interestingly, with the library located within the project directory, I
> was able to load it with, literally,
> 'Component.Load("/doesnotexist/myLibrary")'. But, it would not find it
> with the path specified as "myLibrary", "../myLibrary",
> or "./myLibrary".
>
> Apparently, since it could not be found at a path that does not exist,
> Gambas then applied the Library Search Paths [0] finding
> the library in the first path searched, the project directory. However, if
> the library is not in the project directory and since
> Gambas does not know its vendor, the library cannot be found in (regexp
> expressed):
> ($XDG_DATA_HOME |
> ~/.local/share)/gambas3/lib/<vendor>/<name>:<version>.gambas
> or any of the other search paths since they also rely on <vendor>.
>
>
> And that brings up a question.
>
> Reference [0] states, "When a project that depends on a library is
> executed, the library executable is searched for in the
> following paths [...]"
>
> Now, for a project to 'know' that it depends on a library, the library
> must be specified in the Project properties Libraries
> tab, correct? And, if that is done, then the project would already 'know'
> the location of the library.
>
> So then, why the need for search paths?
>
> If the search paths are to facilitate dynamic loading of libraries, then
> all but one path would be guaranteed to fail to produce
> results since the vendor of the library would not be known unless somehow
> specified.
>
> Is it supposed to be possible to load a library by specifying its name as
> "<vendor>/<name>" or "<vendor>/<name>:<version>" [ie.
> Component.Load("gambasbook_de/myLibrary)]?
>
>
> [0] http://gambaswiki.org/wiki/doc/library#t2
>
>
> ___
> Lee
>
> P.S. Gianluigi, calling the Main method of Class.Load[ed] Module1 also
> works as:
>   Dim Module1 As Class
>
>   Module1 = Class.Load("Module1")
>   Object.Call(Module1, "Main")
>
>
> On 10/21/18 4:31 PM, Gianluigi wrote:
> > Hans, Lee,
> > this attached code, here works.
> >
> > Regards
> > Gianluigi
> >
> > Il giorno dom 21 ott 2018 alle ore 20:48 T Lee Davidson <
> t.lee.davidson at gmail.com <mailto:t.lee.davidson at gmail.com>> ha scritto:
> >
> >     Actually, "/usr/lib/gambas3/" would be the *system* path where all
> the components are stored. You get that particular path
> >     string with Component.Path.
> >
> >     When you make an executable of a library (in this case resulting in
> "myLibrary.gambas"), a copy is also automatically placed in
> >     the *user* path:
> >     <Desktop.DataDir>/gambas3/lib/<vendor_name>/<file_name> (filename in
> this case is "myLibrary:0.0.gambas").
> >
> >
> >     ___
> >     Lee
> >
> >
> >     On 10/21/18 10:42 AM, Gianluigi wrote:
> >     > As suggested by Benoit and Jussi, the Library should be copied
> inside the project, then in Sub Open you writs:
> >     >
> >     >   Dim sPath As String
> >     >   sPath = "/usr/lib/gambas3/myLibrary:0"
> >     >   Component.Load(sPath)
> >     >
> >     > and with help from this lesson [0], completes the project.
> >     >
> >     > Regards
> >     > Gianluigi
> >
> >     ----[ Gambas mailing-list is hosted by https://www.hostsharing.net
> ]----
> >
> >
> >
> > ----[ Gambas mailing-list is hosted by https://www.hostsharing.net ]----
> >
>
> ----[ Gambas mailing-list is hosted by https://www.hostsharing.net ]----
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.gambas-basic.org/pipermail/user/attachments/20181022/3a2d5990/attachment.html>


More information about the User mailing list