Ms-Dos - Parametros en qbasic

 
Vista:

Parametros en qbasic

Publicado por abcnill (1 intervención) el 22/05/2007 15:00:45
Como puedo leer los parametro que le pasan a mi Programa (echo en qbasic).

Cuel seria el codigo fuente.

Ej:

MiAplicacion.exe /P /T
Valora esta pregunta
Me gusta: Está pregunta es útil y esta claraNo me gusta: Está pregunta no esta clara o no es útil
0
Responder

RE:Parametros en qbasic

Publicado por Pedro Amaro (15 intervenciones) el 23/05/2007 22:19:42
Tienes que utilizar la funcion COMMAND$ que te retorna el contenido de la linea de comandos, yo utilizo una SUB que pille hace años en alguna BBS que me sapara los parametros y me retorna una matriz con cada uno de ellos.

'SUB procedimiento que separa los argumentos del COMMAND$
'Parametros: NumArgs : Numero de Argumentos encontrados
' Args$() : Matriz donde se devuelven los Argumentos
' MaxArgs : Maximo numero de Argumentos que se pueden retornar
SUB Comline (NumArgs, Args$(), MaxArgs) STATIC
CONST TRUE = -1, FALSE = 0

NumArgs = 0: In = FALSE
'Get the command line using the COMMAND$ function.
Cl$ = COMMAND$
L = LEN(Cl$)
'Go through the command line a character at a time.
FOR i = 1 TO L
c$ = MID$(Cl$, i, 1)
'Test for character being a blank or a tab.
IF (c$ <> " " AND c$ <> CHR$(9)) THEN
'Neither blank nor tab. Test if you're already inside an argument.
IF NOT In THEN
'You've found the start of a new argument.
'Test for too many arguments.
IF NumArgs = MaxArgs THEN EXIT FOR
NumArgs = NumArgs + 1
In = TRUE
END IF
'Add the character to the current argument.
Args$(NumArgs) = Args$(NumArgs) + c$
ELSE
'Found a blank or a tab.
'Set "Not in an argument" flag to FALSE.
In = FALSE
END IF
NEXT i
END SUB

Un saludo

Pedro Amaro
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar