in Pascal: how to exec a program, discard text output or send to text file
I'm trying to create a program in windows that executes mplayer.exe to play a file, and either discards the output (an equivalent to Linux's "mplayer music.mp3 > /dev/null") or sends it to a file.
What I've tried so far, is this test program: Code:
Program test; Now, if I open a command prompt and enter "mplayer.exe mymusic.mp3 > logfile.txt", it does exactly what I want to: sends all that info about the mp3 to logfile.txt, without displaying anything on the screen. In the big picture: I want to write a guitar tuning/learning program, that uses mplayer to play the sounds, and that's why I want it not to display anything. So, how can I play the file, without recieving any text output from the program? (either mplayer, or if anyone can suggest another command-line GPL-ed version wav/midi player) If anyone has any other ideas on how I can do this (besides coding the media player program my self, as I don't have enough skills to do that), that will be also welcomed. Thanks for reading, and sorry for the newbie question. Any info/suggestion is welcomed. |
Hi
I remember a bit about DOS but I'm good at forgetting. I think devices was name and : - so maybe try: exec('mplayer.exe',' mymusic.mp3 > nul:'); Think there was a null device, but i'm not sure the name was "nul:". Edit: Was not so good at forgetting after all :) Quote:
|
Thanks for the quick reply.
Indeed, it is "nul:". Thanks for telling me about it, it's good to know I won't have to complicate my program with useless textfiles. It works ok from a command prompt, but, as with the output from a file, doesn't work within the program.... It still outputs the text to the main screen... I guess I got the exec function wrong? It seems to ignore the "> whatever " bit at the end... Any ideas on this? |
Maybe
exec("mplayer.exe mymusic.mp3 > nul:"); I don't know why it was split up? edit: I think I recall something like exec(getenv("COMSPEC")+" /c "+args) Good luck with the program! |
Thanks, I half-got it now...
It's split in two because the syntax is: exec('program name','arguments to be given to program'); Tried the first thing you said, aka put parameters in first string, leave second string empty, but it doesn't even play the song that way. Tried the second, like this: exec(getenv('comspec'),'/c mplayer.exe song.mp3 > NUL:'); Now the part that I don't understand is that under freepascal, it works correctly: it plays the song without displaying anything. But compuled with turbo pascal, it still shows what mplayer displays... Anyway, I'll just compile it with freepascal. I hope it behaves ok in the program as well. Thanks again. Edit: Another noob question, no sense in opening a new thread for this: Can I make it run in full screen mode directly, without having to press alt+enter when the program runs? Or modify the terminal window's size from within the program? The highschool manuals just don't give enough info... :| |
Hi again
I don't know how to set fullscreen within the program. But if you make a shortcut to the exe-file, you can right click it, select properties, and then in the "Options" tab, you can chose to run it in fullscreen. |
Oh yeah, I forgot about that... I haven't booted into windows for quite a while now...
Thanks! :) |
All times are GMT -5. The time now is 01:37 AM. |