Return value from a linux library (libg2.so)
Posted: Thu Aug 09, 2007 4:41 pm
Hello,
I tried (again) with PB 4.01 (Linux) using the library libg2 (G2, writing for example direct postscript files). But with the open-function (here "g2_open_PS") I get no return-value, it's always "0".
deviceG2.l = CallCFunction(hlibg2, #g2_open_PS, OutFile$, #g2_A4, #g2_PS_port)
deviceG2 should be a device-value, but is 0.Outfile$ is written! No other operations possible, because ther deviceID is needed.
Maybe it is the way calling the routines, but the most tries with external libraries, I've trouble... ;-)
Look here:
; ------------------------------------------------------------------
; Small test using this fin eg2- Library from (libg2, libg2-dev)
; http://g2.sourceforge.net/
; libg2.so
;
;XIncludeFile "/home/mv/mvData/EigeneDateien/develop/purebasic/linux/include/g2/g2_ps.inc"
;something aut of "g2_inc"...
#g2_open_PS = "g2_open_PS"
#g2_close = "g2_close"
#g2_line = "g2_line"
#g2_rectangle = "g2_rectangle"
#g2_string = "g2_string"
#g2_A4 = 4
#g2_PS_port = 1
Global hlibg2.l, OutFile$
OutFile$ = "gs_print.ps"
Procedure g2_Init()
Shared hlibg2
hlibg2 = OpenLibrary(#PB_Any, "libg2.so")
EndProcedure
Procedure g2_Quit()
Shared hlibg2
CloseLibrary(hlibg2)
hlibg2 = 0
EndProcedure
g2_Init()
deviceG2.l = CallCFunction(hlibg2, #g2_open_PS, OutFile$, #g2_A4, #g2_PS_port)
; =>>> deviceID doesn't get a value (on C it is declared as "int"-type)
; function is successfull!
CallCFunction(hlibg2, #g2_line, deviceG2, 10.0, 10.0, 90.0, 200.0)
CallCFunction(hlibg2, #g2_string, deviceG2, 20.0, 20.0, "This is a test g2-PureBasic!")
CallCFunction(hlibg2, #g2_close, deviceG2)
g2_Quit()
;MessageRequester("Fertig!","Programm beendet!")
MessageRequester("Ready!","Program terminated!")
End
;-------------------------------------------------------------------------
I tried (again) with PB 4.01 (Linux) using the library libg2 (G2, writing for example direct postscript files). But with the open-function (here "g2_open_PS") I get no return-value, it's always "0".
deviceG2.l = CallCFunction(hlibg2, #g2_open_PS, OutFile$, #g2_A4, #g2_PS_port)
deviceG2 should be a device-value, but is 0.Outfile$ is written! No other operations possible, because ther deviceID is needed.
Maybe it is the way calling the routines, but the most tries with external libraries, I've trouble... ;-)
Look here:
; ------------------------------------------------------------------
; Small test using this fin eg2- Library from (libg2, libg2-dev)
; http://g2.sourceforge.net/
; libg2.so
;
;XIncludeFile "/home/mv/mvData/EigeneDateien/develop/purebasic/linux/include/g2/g2_ps.inc"
;something aut of "g2_inc"...
#g2_open_PS = "g2_open_PS"
#g2_close = "g2_close"
#g2_line = "g2_line"
#g2_rectangle = "g2_rectangle"
#g2_string = "g2_string"
#g2_A4 = 4
#g2_PS_port = 1
Global hlibg2.l, OutFile$
OutFile$ = "gs_print.ps"
Procedure g2_Init()
Shared hlibg2
hlibg2 = OpenLibrary(#PB_Any, "libg2.so")
EndProcedure
Procedure g2_Quit()
Shared hlibg2
CloseLibrary(hlibg2)
hlibg2 = 0
EndProcedure
g2_Init()
deviceG2.l = CallCFunction(hlibg2, #g2_open_PS, OutFile$, #g2_A4, #g2_PS_port)
; =>>> deviceID doesn't get a value (on C it is declared as "int"-type)
; function is successfull!
CallCFunction(hlibg2, #g2_line, deviceG2, 10.0, 10.0, 90.0, 200.0)
CallCFunction(hlibg2, #g2_string, deviceG2, 20.0, 20.0, "This is a test g2-PureBasic!")
CallCFunction(hlibg2, #g2_close, deviceG2)
g2_Quit()
;MessageRequester("Fertig!","Programm beendet!")
MessageRequester("Ready!","Program terminated!")
End
;-------------------------------------------------------------------------