command.com echo command

BlitzMax Forums/BlitzMax Programming/command.com echo command

Kev(Posted 2008) [#1]
Hi Guys

is it possable to execute a command like it was done in the command prompt?

ie.. if i had a dos box up and typed 'echo hello from dos prompt' the text 'hello from dos prompt' is only printed using the echo command?

any help would be great
kev


SebHoll(Posted 2008) [#2]
Do you mean outputting text to a console? If so, just use the Print command:

Print "What is your name?"
Local tmpInput$ = Input("> ")
Print "Hello " + tmpInput
The print command outputs text to StandardIO (á la echo). Conversely, the input command returns input from the console.

Building untitled1
Executing:untitled1.exe
What is your name?
> Kev
Hello Kev

Process complete

When running your program from the IDE it will appear in the BlitzMax output tab, but when the EXE is run from Windows Explorer, the text appears in the console.




Kev(Posted 2008) [#3]
i think you mis-understand, take the following.

in a dos box if you type 'echo hi from blitz' the echo command displays the line 'hi from blitz'. what i need is a way for the echo command to display the text not blitz its self. does this make better sence?

using print would display the complete text as passed to print ie. 'echo hi from blitz' the echo command does not print it. input would so do the same where by the outputted text is from blitz not the echo command.

kev


grable(Posted 2008) [#4]
Stricly speaking, you cant. At least not in any direct way.
Since "echo" is an internal shell command (command.com or cmd.com for 2000++) they need to be active for it to function.
Doing a Print from blitzmax does exactly the same thing with a lot less overhead though.

If what you realy want is to run batch scripts from your program, you could start a new shell from your own program:
system_("cmd /c ~qecho hello world!~q")



Dreamora(Posted 2008) [#5]
you still missunderstand ... from his specs it seems like he wants to do his own console.
That actually would be fairly simple given the fact that you have some kind of fixed command structure.

Given you have your input stored in cmd:string, then you could simply do

 local cmdCall:string = cmd.split(" ")
 local cmdData:string = right( cmd, cmd.length - instr(cmd, " ")+1))
 select cmdCall
  case "echo"
   print cmdData
 end select



Kev(Posted 2008) [#6]
ok seems like i almost have what im after. Im using the system command from c.

c code
#include <process.h>

void _system(char *command){
   system(command);
}


max code
Import "system.c"

Extern
	Function _system(command$z)
End Extern

_system("echo hi from blitz!")


as you should see a quick flash of the dos box and the text 'hi from blitz!' is displayed using echo. just need to figure how to do this so the dos box is hidden

kev