BBS: Inland Empire Archive Date: 11-01-92 (20:31) Number: 338 From: MICHAEL JONES Refer#: NONE To: BOB LAPIERRE Recvd: NO Subj: Command Line Switches Conf: (2) Quik_Bas
on Oct 28, 92 Bob Lapierre 1:3611/15 you were saying that...
BL>I am trying to figure out, How can you make a Compiled QB4.5 program
BL>recognize command line switches at the DOS prompt? If anyone could
BL>help
BL>me out, I would greatly appreciate it.
I do not have any code handy. If I remember right the
example that comes with QB was hard to follow. At least it
was a few years ago. :-)
What you first want to do is to get the command line with the COMMAND$
function.
TheCommandLine$ = COMMAND$
Then what I do (probably is not necessary) is I force it to
upper case and strib the spaces off of the right and left.
Maybe QB does this already, I never checked.
TheCommandLine$ = UCASE$(RTRIM$(LTRIM$(TheCommandLine$)))
Then you want to set up a FOR NEXT LOOP. This might need
work, I'll rush through it.
Flag% = 0 ' Initialize the flag
TheSwitch$ = "" ' Initialize what the switch is
TheRest$ = "" ' Initialize the rest
FOR I = 1 TO LEN(TheCommandLine$)
Tmp$ = MID$(TheCommandLine$, I, 1) ' Step through 1 char at a time
IF Tmp$ = " " THEN ' If a space is found then
Flag% = 1 ' Start TheRest$
TheRest$ = TheRest$ + Tmp$ ' Add the char to TheRest$
ELSE ' otherwise.......
TheSwitch$ = TheSwitch$ + Tmp$ ' It is still the switch
END IF
NEXT I
That should be all that you need. I usually require a - for the switch
and afterward check for it but that is really not necessary.
Enjoy!
--- QM v1.00
* Origin: Shelter From The Storm (404)518-1356 (1:133/115.0)

Books at Amazon:
Back to BASIC: The History, Corruption, and Future of the Language
Hackers: Heroes of the Computer Revolution (including Tiny BASIC)
Go to: The Story of the Math Majors, Bridge Players, Engineers, Chess Wizards, Scientists and Iconoclasts who were the Hero Programmers of the Software Revolution
The Advent of the Algorithm: The Idea that Rules the World
Moths in the Machine: The Power and Perils of Programming
Mastering Visual Basic .NET