External libraries

Post

Posted
Rating:
#1 (In Topic #497)
Guru
BruceSteers is in the usergroup ‘Guru’
Greetings all.

I'm trying to figure out how to use a library function but am clueless really :(

I want to use the XKeycodeToKeysym() command from the Xlib

I tried this..
Extern XKeycodeToKeysym(Disp As Object, code As Integer, Index As Integer) As String In "Xlib"

That does not work. says cannot find xlib.so

fumbling around in the dark here :(

Any clues would be appreciated.
Tia.
Bruce.
Online now: No Back to the top

Post

Posted
Rating:
#2
Avatar
Regular
stevedee is in the usergroup ‘Regular’

BruceSteers said

…I'm trying to figure out how to use a library function…

I think you are missing the Library declaration, take a look at my post: Captain Bodgit: Gambas: using external C libraries

In the meantime I'll take a look at xlib
Online now: No Back to the top

Post

Posted
Rating:
#3
Avatar
Regular
stevedee is in the usergroup ‘Regular’
Looks like the library you require is libx11: https://helpmanual.io/packages/apt/libx11-doc/

…we just got to figure out how to reference it
Online now: No Back to the top

Post

Posted
Rating:
#4
Guru
BruceSteers is in the usergroup ‘Guru’
 Cheers Steve with that nudge i've found the library with using libX11  (capital X)

thank you , i can play with that now, just gotta work out how to pass the args like "Display"
Online now: No Back to the top

Post

Posted
Rating:
#5
Avatar
Regular
stevedee is in the usergroup ‘Regular’

BruceSteers said

…just gotta work out how to pass the args like "Display"

I don't know if you have already found this: /howto/extern - Gambas Documentation

I think the Display argument is a pointer.

Good luck Bruce.
Online now: No Back to the top

Post

Posted
Rating:
#6
Regular
vuott is in the usergroup ‘Regular’

stevedee said

I think the Display argument is a pointer.
Yes, he has to use a Pointer data type.


BruceSteers
Here a few years ago I wrote some examples (text in italian) using the external functions of the <COLOR color="#800000">X11</COLOR> library in Gambas:

   Creare una finestra mediante le funzioni del API di X11 - Gambas-it.org - Wikipedia

Europaeus sum !

<COLOR color="#FF8000">Amare memorentes atque deflentes ad mortem silenter labimur.</COLOR>
Online now: No Back to the top

Post

Posted
Rating:
#7
Guru
BruceSteers is in the usergroup ‘Guru’

stevedee said

BruceSteers said

…just gotta work out how to pass the args like "Display"

I don't know if you have already found this: /howto/extern - Gambas Documentation

I think the Display argument is a pointer.

Good luck Bruce.

Yes, cheers , been reading up where i can.  heading into C world though , so much more complex than basic lol.

Definitely giving me a headache :-\

I may just blow it all out and make my app gtk only.
Key codes all seem fine and match keysymdef.h file on GTK , QT though , pah
Online now: No Back to the top

Post

Posted
Rating:
#8
Avatar
Regular
stevedee is in the usergroup ‘Regular’

BruceSteers said


….heading into C world though , so much more complex than basic…

Ideally, everyone should learn C.
Even if you never use it, having that background information is very useful when working with other languages and operating systems.

Definitely giving me a headache :-\


lol, try C++ for a full blown migraine!
Online now: No Back to the top

Post

Posted
Rating:
#9
Avatar
Regular
stevedee is in the usergroup ‘Regular’

vuott said

…Here a few years ago I wrote some examples (text in italian) using the external functions of the <COLOR color="#800000">X11</COLOR> library in Gambas:

   Creare una finestra mediante le funzioni del API di X11 - Gambas-it.org - Wikipedia

These are great examples vuott, and what a brilliant Gambas wiki!
Online now: No Back to the top

Post

Posted
Rating:
#10
Guru
BruceSteers is in the usergroup ‘Guru’
I gave up in the end lol, thanks for the help though , i tried.
I thought i was doing it right, i used the opendisplay command using Pointers then tried to use the function i wanted, then closedisplay.
Just got a segmentation 11 fault each time :(

But i found a work-around for now to get my macro recorder working (mostly) on QT.
I just have one little issue to deal with with a menu shortcut to play the macro.
On GTK if i hit F7 to play the macro and the macro calls a F3 (search) hit, it runs where it should.
On QT it seems the F3 hit does not get sent till all the macros have played out. (i'm guessing i'm locked in the KeyPress() function and the F3 hit does not function till out of the KeyPress function.)  annoying as it does not happen on GTK just QT.

But thanks for the links guys , useful resources for me to look at if i try again :).
All the best
Bruce
Online now: No Back to the top

Post

Posted
Rating:
#11
Regular
vuott is in the usergroup ‘Regular’

stevedee said

These are great examples vuott, and what a brilliant Gambas wiki!

Thank you so much, stevedee !

Europaeus sum !

<COLOR color="#FF8000">Amare memorentes atque deflentes ad mortem silenter labimur.</COLOR>
Online now: No Back to the top

Post

Posted
Rating:
#12
Regular
vuott is in the usergroup ‘Regular’

stevedee said

Ideally, everyone should learn C.
Even if you never use it, having that background information is very useful when working with other languages and operating systems.

I'm perfectly agree !   :!:

Europaeus sum !

<COLOR color="#FF8000">Amare memorentes atque deflentes ad mortem silenter labimur.</COLOR>
Online now: No Back to the top

Post

Posted
Rating:
#13
Guru
BruceSteers is in the usergroup ‘Guru’
When i first started coding i learned a bit.  That was on an Amiga1200 using AmigaE that was like C but higher level and like gambas I started venturing into using system libraries and learning C a bit :)
C always seems "full of rubbish" to me lol
Basic has it's fair share of rubbish with defining things but C , phew, talk about fussy , and a rubbish compiler. The AmigaE language and compiler took loads of the work out of it :)

I've dabbled with perl java php vb , since but after moving over to linux and discovering gambas I stopped looking any further.

It's only now that i've gotten so deeply into gambas that im having to deal with C again.
I'm really digging being able to fork/clone it and have a version i can monkey around with :)

There's a couple of issues i have with the latest version (mostly it killing my test arg lists in the .project files)
I fixed that bug and sent a merge request but Benoít didn't bite.
Even tried editing the code on the the gambas gitlab page and having git auto create a branch set to delete on merge. but he still didn't bite.
I sent a mail the the M/L pleading for him to fix it as it was driving me mad every time i loaded a project in an older gambas it would delete my arg lists  :evil: .

It may seem trivial but my GUI builder GForm has an args list like this…

I once said

ArgumentList=[["end","tgbutton="tb1|This is a ToggleButton|on nostretch"","box","input="i1|some text=this"","unbox","box","toolbutton="tb2|Goodbye"","fontbox="FBX||stretch linkto=list1"","unbox","button="b4|well then|noclose|com=xdg-open /home"","box","label="|This ia a label\na 2 line label"","input="in3|more txt"","unbox","box","checkbox="cb1|Check box this|on background=200,230,230"","combobox="cmb1|l1,list 2,the third"","unbox","list="list1|l1,list 2,the third|1|lines=3"","box","maskbox="msk1|the mask"","button="BQ|Quit|stretch"","unbox","width=300","pipe=/tmp/fifo1","listen=/tmp/fifo2"],["return=end","listen=/tmp/fifo2","bg=200,200,100","label="lbl|testin\nthis label|stretch"","menu="mMain|form|Main Menu"","menu="m2|mMain|Open|icon=open toggle"","menu="m3|mMain|Close|icon=close"","menu="m4|mMain|Quit|icon=quit close"","box","button=0|Yes","button=1|no","button="2|Cancel|picture=cancel menu=mMain"","unbox","textbox="tb1|something|nostretch"","tgbutton="tgb|tgbutton|on"","pipe=/tmp/fifo1"],["help"],["button="b1|Button 1|icon=open|com=xed /media/bonus/Elements/LinuxStuff/GForm_dist/install/Install_GForm.sh"","button="|testing 1 2 3|tip=trying this\rtip here"","button="|CLose|close""],["allstretch","label="lbl|Test Menu Window"","menu="mMain|form|Main Menu"","menu="mItem|mMain|Menu Item|com=xed"","box","button="bt1|Button 1|menu=mMain icon=menu|shell=gambas3|tip=Click to run gambas3 IDE"","button="|Quit|icon=quit close""]]

<HR>[hr]</HR>

But then it hit me.
I have a clone on my hard drive, i edit the code myself and gambas updates now merge into my clone. leaving my changes be.
That's kinda excellent :)
I just have to be careful not to make my apps (that others could use) only work on my gambas.


But you can see a definite crossover point in gambas where it goes from gambas code to C , sigh

I guess I'm just a basic guy :)
Online now: No Back to the top
1 guest and 0 members have just viewed this.