On 08-31-96, Ronald Schlegel wrote to All:
RS> Hello,
RS> Does anyone know how to pass more than 1 variable to COMMAND$? I
RS> am trying to trap DOS environment variables...here is my example:
RS> TEST.BAT
RS> --------
RS> UPLOAD %1 %2
RS> The program reads the %1 fine, but never sees the %2. The program
RS> that will pass the %1 & %2, passes the filename as %1 and the
RS> file-extention as %2. I've got other programs that I need to pass
RS> multiple parameters to (ie. "TEST 1 3 OUTPUT.TXT"), but can on
RS> figure how to pass 1 of the parameters...the first one.
DEFINT A-Z
TEST$ = COMMAND$
NumberOfWords? = DimParse(Test$)
IF NumberOfWords? 2 GOTO FOOBAR
DIM Words$(NumberOfWords?)
FOR I = 1 TO NumberOfWords?
Words$(I) = Parse(Test$)
NEXT
VAR1$ = Words$(1)
VAR2$ = Words$(2)
'VAR3$ = Words$(3)
'VAR4$ = Words$(4)
'etc
PRINT VAR1$
PRINT VAR2$
'PRINT VAR3$
'PRINT VAR4$
'etc
Foobar:
PRINT
PRINT "Usage: PROGRAM %1 %2
PRINT
END
FUNCTION DimParse% (TIn$) STATIC
TIn$ = RTRIM$(LTRIM$(TIn$))
Parses = 0
Length = LEN(TIn$)
IF Length = 0 THEN
DimParse% = 0
EXIT FUNCTION
END IF
FOR I = 1 TO Length
IF MID$(TIn$, I, 1) = " " THEN Parses = Parses + 1
NEXT I
DimParse% = Parses + 1
END FUNCTION
FUNCTION Parse$ (TIn$)
STATIC ParseAt%, Length
IF ParseAt% = 0 THEN
ParseAt% = 1
Length = LEN(TIn$)
END IF
IF Length = 0 OR ParseAt% > Length THEN EXIT FUNCTION
Offset% = INSTR(ParseAt%, TIn$, " ")
IF Offset% = 0 THEN Offset% = Length + 1
Parse$ = MID$(TIn$, ParseAt%, Offset% - ParseAt%)
ParseAt% = Offset% + 1
IF ParseAt% = Length + 2 THEN ParseAt% = 0 END FUNCTION
--- GEcho 1.20/Pro
---------------
* Origin: Toast House Remote (1:100/560.1)
|