Qbasicnews.com

Full Version: How to pass arguments to compiled basic program?
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2
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>
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:
Code:
PRINT COMMAND$
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)
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)
Ah, never used a UNIX terminal. What's AWK?
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
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.
Mah, not sure I get that...I'll wait till I get to univ to dabble in UNIX, using their computers. Tongue
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.
*****
Pages: 1 2