const BLANCO = ' '; MAXCMD = 10; BUFFER = $80; type longstr = string[200]; strindx = record prim : smallint; len : smallint; end; var command : string[31] absolute BUFFER; cmdargs : smallint; cmdindx : array [1..MAXCMD] of strindx; procedure initcmd; var i : integer; begin cmdargs := 0; i := 1; repeat while (i <= length(command)) and (command[i] = BLANCO) do i := succ(i); if (i <= length(command)) then begin cmdargs := succ(cmdargs); cmdindx[cmdargs].prim := i; while (command[i] <> BLANCO) and (i <= length(command)) do i := succ(i); cmdindx[cmdargs].len := i - cmdindx[cmdargs].prim end until i > length(command) end; {initcmd} function nargs : integer; begin nargs := cmdargs end; {nargs} function getarg(n : integer; var s : str) : boolean; {Funcion : devolver el enesimo argumento de la linea de comando} begin if (n < 1) or (n > cmdargs) then getarg := false else begin s := copy(command,cmdindx[n].prim,cmdindx[n].len); getarg := true end end; {getarg}