Page 1 of 1

Calling a command line script from PB program

Posted: Mon Oct 01, 2007 12:32 am
by ac667788
Hi All,
I would like to call a command line ruby script from within a PB program, but I am unsure of how to do it. Would you use the console functions or program functions? What would be the best way of passing data back?
Thanks

Posted: Mon Oct 01, 2007 1:26 am
by Thalius
The easy way would be to use runprogram() with the commandline ruby interpreter. However passing data back and forth eitehr had to be over a shared memory area or a database ( both ways have their tricky side about synchronization ).

The better way would be to use the ruby.dll (which you also can ship with your program - unaltered or with source ofc since its GPLed ) - the dll can be called from purebasic and basically gives you the functionality to call your own ruby scripts from file / memory from inside pb. Personally i havent done this yet with ruby ( i tried the similar with php - which worked ). Personally i now use Dracscript as scripting language as its written in PB and pretty easy to extend. :)

In case you havent seen that one yet check out: http://www.purebasic.fr/english/viewtopic.php?t=20312

Whats it for btw ? Writing your own webserver ? =)

Thalius

Posted: Mon Oct 01, 2007 7:24 pm
by ac667788
Thalius,
Thanks for the good insight, I will go ahead a check out ruby.dll and let you know how it goes.

I am trying to make a personalized stock analysis system and I want to take advantage of a ruby script that can download stock data from Yahoo Finance.

Posted: Mon Oct 01, 2007 8:16 pm
by Thalius
ac667788 wrote:Thalius,
... take advantage of a ruby script that can download stock data from Yahoo Finance.
hmmm - depending what format that data is ( some use RSS which is pretty common ) and if or not https then this would be pretty easy also to write in a simple set of PB Procedures ( faster too ) - and if its about pluggability then you could just epxort this as a dll ( much smaller and more compact than distributing the whole ruby incl your script etc =)

Thalius