home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Power-Programmierung
/
CD1.mdf
/
basic
/
library
/
qb_pds
/
cmdline
/
comndlin.doc
next >
Wrap
Text File
|
1989-08-09
|
5KB
|
90 lines
┌───────────────────────────────────────────────────────────────────────┐
│ Author: Jon R. Meyer Compiler: QB 4.x and up and │
│ 484 Neal Ave S. Bascom 6 │
│ Afton, MN 55001 │
│ Date: August 8, 1989 Release : 1.0 │
│ │
│ Copyright(C) 1989 Jon R. Meyer │
├───────────────────────────────────────────────────────────────────────┤
│ │
│ Name: ComndLin Type: SUB Level: BASIC │
│ │
│ Syntax: CALL ComndLin(arg$(), qty%) │
└───────────────────────────────────────────────────────────────────────┘
This will read the command line into an array for return to calling
program. Whatever is on the command line will be parsed and returned
with all leading and trailing blanks removed. Any delimiter that you
instruct the user to specify WILL NOT BE REMOVED from each argument
in the array. No special character is required other than a space in
between each argument.
Example: MYPROG /A /BC
will return 2 items in the array, "/A" and "/BC". If so instructed,
you could just as easily instruct the user to start the program with:
MYPROG A BC or MYPROG -A -BC
It will be up to you to determine which, if any, delimiter is used, just
remember, ComndLin only parses the command line it does not strip
"special" characters (other than blanks) from it.
The string array ARG$ should be dimensioned to the MAXIMUM number
of command line arguments that you expect or that your application
has available or allows (in case ALL of them are called).
Qty% tells the routine the offset in the array to start storing
the different arguments ie qty% = 4 would place the first retrieved
argument in ARG$(4). This is to allow placement in a config array and
to allow for OPTION BASE 0 and 1.
Example:
MyProg -a -v -m -ex 'Sample program Command Line
max = 6 'where max = maximum number of parameter calls possible
DIM arg$(max)
qty% = 3 'where qty% = starting point in array to store first param.
CALL comndlin(arg$(), qty%)
Qty% returns the number of elements in the array starting at position 3,
and arg$() holds the command line parameters.
Return :
qty% = 6 'The last arg # in the array
arg$(3) = "-a"
arg$(4) = "-v"
arg$(5) = "-m"
arg$(6) = "-ex"
This routine is for whomever wants to use it. I am not charging (at this
time) anything as long it is used for personal use or freeware programs.
If this routine is to be used in any packages that is to be sold to the
public (either commercially or as registered shareware), I feel it is
only fair that I be informed of this use. I also feel that it would be
appropriate in this case to send me a small donation (A couple of bucks
tops but atleast your name and address and a free copy of your program).
I am not in this to make money but if someone else is going to make money
from my work, I should get at least a little something from it.
As you may have noticed, I did not include the source code for this
routine. The reason for this is to protect thise routine and the others
that I have or may develop from time to time from any changes which may
cause them to no longer function the way they are documented. I am
willing to accept any comments or suggestions for changes but I will
have the final say (obviously) on what happens. I do not intend to make
changes which would cause this routine not to function as originally
documented unless it is felt that the changes will only improve the
routine. Of course if this happens, I will make note of it so please
read the documentation.
I do have one thing that I would like to ask of anyone who might decide
to use this routine, let me know what you think of it. I like praise
but I can also take criticism. You can either send me a note at
the address above leave a note for me on PC Library BBS in Minneapolis.
The number is 612-435-8058.