Posts: 3
Threads: 1
Joined: Feb 2004
Hi everyone.
I'm sorry if this is a question that's been asked a million times but I roamed through the forum and couldn't find anything similar.
How do I pass values to a compiled program?
For example I want to use the contents of a file that will be given at run time but without user input: myprogram.exe <a file to use>
Posts: 1,752
Threads: 21
Joined: Jun 2002
Posts: 3,616
Threads: 287
Joined: Jan 2003
Plasma and his QB Online Help obsession...
Anyway, so you don't have to waste your bandwidth ( :wink: ), Jpeppas, here's my description of COMMAND$...
Here's some code:
Compile that program. Then run it from an msdos command line, with whatever command-line args you want. See what happens? Plainly put, COMMAND$ is the string that holds the command-line args you used.
(note that you don't need to compile that program, but rather you can go to RUN->Modify COMMAND$ to use args without compilation)
f only life let you press CTRL-Z.
--------------------------------------
Freebasic is like QB, except it doesn't suck.
Posts: 3
Threads: 1
Joined: Feb 2004
Thanks a million for your quick response.
I'm trying to use qb to create scripting commands not available in DOS, and it's quite testy.
Have you got any ideas (I'm trying to make the AWK unix command)
Posts: 3,616
Threads: 287
Joined: Jan 2003
Ah, never used a UNIX terminal. What's AWK?
f only life let you press CTRL-Z.
--------------------------------------
Freebasic is like QB, except it doesn't suck.
Posts: 3,279
Threads: 170
Joined: Nov 2003
I'd knock on wood, but my desk is particle board.
Posts: 3
Threads: 1
Joined: Feb 2004
you take the output of a command or a file that's tabbed and depending on the the number you give, you're returned the n'th column.For example
the file a is like:
a 2 4 5 test1
a 2 3 5 test2
b 2 4 5 test5
c 2 4 5 test7
if you asked for 1 you would get:
a
a
b
c
if you asked for 5 you would get:
test1
test2
test5
test7
It's very usefull when you need a specific column of a file or output so you can use it in a loop
Posts: 292
Threads: 31
Joined: Apr 2003
Do you know how TYPEs and Random Access/Binary files? That would probably be the easiest solution, depending on exactly how you have the files set up.
Posts: 3,616
Threads: 287
Joined: Jan 2003
Mah, not sure I get that...I'll wait till I get to univ to dabble in UNIX, using their computers.
f only life let you press CTRL-Z.
--------------------------------------
Freebasic is like QB, except it doesn't suck.
Posts: 1,956
Threads: 65
Joined: Jun 2003
Quote:Thanks a million for your quick response.
I'm trying to use qb to create scripting commands not available in DOS, and it's quite testy.
Have you got any ideas (I'm trying to make the AWK unix command)
Ti canis, Jpeppas. (Ego catalaveno ligo Helenica)
I have a limited knowledge of AWK, but I do remember that many of the parameters need to be in upper and lower case. If you use a COMMAND$ in your QB program, all the parameters will be converted to upper case. A solution is not to use the COMMAND$, but read the screen to get the parameters in their original case. I have done this and it's not simple.
Another approach would be to write a liitle input program where you prompt the user for the parameters and then write the parameters to a work file. Your main program then reads the work file and gets the parameters. This also avoids the user from having to know all the tricky parameters for AWK. Your input program will ask him all the right questions.
Think about it.
*****