Hi all,
is there a way in SpiderBasic, to work / communicate with native applications like a exe in Windows?
If is so, can any one show me a small sample how i must start to do this?
Thanks and a nice easter to all of you!
Nico
Communicate / Work with a nativ Application (EXE)
Re: Communicate / Work with a nativ Application (EXE)
From the client side (browser), you can't lanuch an exe or anything outside the browser. But you can do it server-side, with a CGI or a PHP script which launch the exe (you can call the URL from SpiderBasic with HTTPRequest())
Re: Communicate / Work with a nativ Application (EXE)
Thanks for replay.Fred wrote:From the client side (browser), you can't lanuch an exe or anything outside the browser. But you can do it server-side, with a CGI or a PHP script which launch the exe (you can call the URL from SpiderBasic with HTTPRequest())
Do you have a smal sample how we can do this?
What i need to do is:
- start a exe
- read stdout or pull data from a DB
- close the exe
Thanks for your help!
Re: Communicate / Work with a nativ Application (EXE)
Here is a sample of client / server comms in spiderbasic / purebasic
When you click the button it sends string to cgi which uppers the string and sends back the result
Spiderbasic will then update the textgadget
You need the CGI Lib for Purebasic for server end.
You also need to run the Spiderbasic and the CGI Purebasic from the same webserver to avoid cross domain request problems.
i.e. it will not work from the IDE with default Apache setup
In my example both are served from a local Apache server on Windows box.
You also have to configure Apache to allow CGI etc.
However you can make it work from IDE by modifying the following in Apache.
Add in mod_headers.so
and in Directory section add
Header set Access-Control-Allow-Origin "*"
Handy for testing only......
Spiderbasic
Purebasic
When you click the button it sends string to cgi which uppers the string and sends back the result
Spiderbasic will then update the textgadget
You need the CGI Lib for Purebasic for server end.
You also need to run the Spiderbasic and the CGI Purebasic from the same webserver to avoid cross domain request problems.
i.e. it will not work from the IDE with default Apache setup
In my example both are served from a local Apache server on Windows box.
You also have to configure Apache to allow CGI etc.
However you can make it work from IDE by modifying the following in Apache.
Add in mod_headers.so
and in Directory section add
Header set Access-Control-Allow-Origin "*"
Handy for testing only......
Spiderbasic
Code: Select all
Procedure UpperWeb(Success, Result$)
If Success
SetGadgetText(3,Result$)
Else
Debug "Failed"
EndIf
EndProcedure
Procedure getbutton()
temp$=GetGadgetText(3)
HTTPRequest(#PB_HTTP_Get, "http://127.0.0.1/upper.pbe?string="+temp$, "", @UpperWeb())
EndProcedure
If OpenWindow(1, 100, 100, 250, 75, "Test", #PB_Window_TitleBar)
ButtonGadget(2, 20, 30, 75, 30, "To Upper")
StringGadget(3, 120, 30, 75, 30, "abc")
BindGadgetEvent(2,@getbutton(), #PB_EventType_LeftClick )
EndIf
Purebasic
Code: Select all
CGI_In()
string$=CGI_Val("string")
string$=UCase(string$)
CGI_Header()
CGI_Out(string$)
End
Re: Communicate / Work with a nativ Application (EXE)
e2robot wrote:Here is a sample of client / server comms in spiderbasic / purebasic
When you click the button it sends string to cgi which uppers the string and sends back the result
Spiderbasic will then update the textgadget
You need the CGI Lib for Purebasic for server end.
You also need to run the Spiderbasic and the CGI Purebasic from the same webserver to avoid cross domain request problems.
i.e. it will not work from the IDE with default Apache setup
In my example both are served from a local Apache server on Windows box.
You also have to configure Apache to allow CGI etc.
However you can make it work from IDE by modifying the following in Apache.
Add in mod_headers.so
and in Directory section add
Header set Access-Control-Allow-Origin "*"
Handy for testing only......
Spiderbasic
Code: Select all
Procedure UpperWeb(Success, Result$) If Success SetGadgetText(3,Result$) Else Debug "Failed" EndIf EndProcedure Procedure getbutton() temp$=GetGadgetText(3) HTTPRequest(#PB_HTTP_Get, "http://127.0.0.1/upper.pbe?string="+temp$, "", @UpperWeb()) EndProcedure If OpenWindow(1, 100, 100, 250, 75, "Test", #PB_Window_TitleBar) ButtonGadget(2, 20, 30, 75, 30, "To Upper") StringGadget(3, 120, 30, 75, 30, "abc") BindGadgetEvent(2,@getbutton(), #PB_EventType_LeftClick ) EndIf
Purebasic
Code: Select all
CGI_In() string$=CGI_Val("string") string$=UCase(string$) CGI_Header() CGI_Out(string$) End
Hi,
thnaks for the sample.
I will try it if i'm back at home.
Cheers,
Nico
Re: Communicate / Work with a nativ Application (EXE)
No problems......I have a full invoicing / job tracking database system written using this tech.
The cgi library for Purebasic I used is from
http://www.reelmedia.org/cgi-bin/PurePr ... &sub=ASM52
Would be nice to see CGI built into Purebasic now with have Spiderbasic to play with too.
Phil
The cgi library for Purebasic I used is from
http://www.reelmedia.org/cgi-bin/PurePr ... &sub=ASM52
Would be nice to see CGI built into Purebasic now with have Spiderbasic to play with too.
Phil
Re: Communicate / Work with a nativ Application (EXE)
That's true, a native CGI lib could be useful
Re: Communicate / Work with a nativ Application (EXE)
@Fred, so we can hope for a native CGI lib in one of the next PB Versions? That will be very nice!Fred wrote:That's true, a native CGI lib could be useful
Thanks,
Nico