BlitzPlus and Command Line output

BlitzPlus Forums/BlitzPlus Programming/BlitzPlus and Command Line output

soja(Posted 2003) [#1]
I'm trying to build a command-line-only application with BlitzPlus. The easy part is reading in and parsing the command line parameters. What I haven't figured out yet is how to print stuff to the command line window (i.e. output text). Here's what I'm doing:

1) Compile Blitz executable ("program.exe")
2) Run cmd.exe, cd to program folder
3) Run "program.exe /param1 /param2"
4) (In program.exe) read the command line parameters
5) (In program.exe) send output to cmd.exe "Program successfully completed, with params: ...etc"

So, as you can see, I just want it to be like every other command line tool -- no GUI, no other windows, etc. But...

I've tried "Print" -- it just opens another window and prints whatever.
I've tried "execfile("echo <message>")" -- it doesn't seem to do anything.
I don't notice any other ways in native blitz (not similar to these) to just print output to the console from which the program was executed.

Is there a way, or am I going to have to get creative with an external program or DLL?


Kevin_(Posted 2003) [#2]
You are doing the right thing by using cmd.exe , however cmd.exe can take a few arguments itself.

e.g. c$="cmd.exe /c dir"
ExecFile(c$)

will do a dir then immediatley close the console. the /c is a switch that closes the console. Can't remember any other switches but there are a few. Fiddle around with it.

Regards


skn3(Posted 2003) [#3]
type cmd /? in the command line to get all switches


soja(Posted 2003) [#4]
Whoa, thanks for the responses, but I must have badly explained myself.

I want to run my blitz executable from an open command window, and then output from blitz to that command window (stdout). I don't want to print the output to another window (even if it is another cmd.exe window).

I suppose many people call this a Console program.


RexRhino(Posted 2003) [#5]
soja:
As far as I know, this is not possible... I am pretty sure blitz ALWAYS creates a window.


Compt-Man(Posted 2007) [#6]
Use the Text command on a canvas gadget


Alaric(Posted 2007) [#7]
Blitz doesn't use stdout. If you want to write a command-line program then you are going to need to write a dll and use blitz's userlibs to write to stdout.


Phil Newton(Posted 2007) [#8]
Did anyone ever succeed with getting BlitzPlus (or Blitz3D) to use stdout instead? I tried to write a DLL to use stdout but no joy. I'm writing a command line application and I don't want it to open a new window when it prints to the screen, but I've had no success with anything yet. Is it not possible?


b32(Posted 2007) [#9]
Hmm, I'm not sure, I haven't tried it, but I found this:
http://playerfactory.proboards25.com/index.cgi?board=userlib&action=display&thread=1076521374


Phil Newton(Posted 2007) [#10]
Thanks b32. That doesn't work quite the way I'd like it, but it's given me a good base to build on. It can redirect to files and take input from files, but it doesn't write to the console window. I'm sure if can be done with a little tweaking.

Good find!