Getting the COMMAND line arguments in QBASIC 
Author Message
 Getting the COMMAND line arguments in QBASIC

I would like to know how I get the command line arguaments in QBASIC ....?


Mon, 15 Jul 2002 03:00:00 GMT  
 Getting the COMMAND line arguments in QBASIC

Quote:

>I would like to know how I get the command line arguaments in QBASIC ....?

Feature not available.(Unless you locate the PSP and get the command string
that way.) (That requires assembly language and CALL ABSOLUTE.)

MCM



Mon, 15 Jul 2002 03:00:00 GMT  
 Getting the COMMAND line arguments in QBASIC

Quote:

>I would like to know how I get the command line arguaments in QBASIC ....?

Type QBASIC /? at the command prompt.

***** START OF COMMAND PROMPT SESSION *****

Microsoft(R) Windows NT(TM)
(C) Copyright 1985-1996 Microsoft Corp.

D:\>qbasic /?
Starts the MS-DOS QBasic programming environment.

QBASIC [/B] [/EDITOR] [/G] [/H] [/MBF] [/NOHI] [[/RUN] [drive:][path]filename]

  /B          Allows use of a monochrome monitor with a color graphics card.
  /EDITOR     Starts the MS-DOS Editor.
  /G          Provides the fastest update of a CGA screen.
  /H          Displays the maximum number of lines possible for your hardware.
  /MBF        Converts the built-in functions MKS$, MKD$, CVS, and CVD to
              MKSMBF$, MKDMBF$, CVSMBF, and CVDMBF, respectively.
  /NOHI       Allows the use of a monitor without high-intensity support.
  /RUN        Runs the specified Basic program before displaying it.
  [[drive:][path]filename] Specifies the program file to load or run.

D:\>

****** END OF COMMAND PROMPT SESSION ******



Mon, 15 Jul 2002 03:00:00 GMT  
 Getting the COMMAND line arguments in QBASIC
I think he wants the QBasic equivalent of QB's COMMAND$ rather than the
pre-defined command line switches.  I've never seen a way to get
user-defined command line arguments with QBasic.

--
Interested in A FREE DSL Internet Connection?
E-mail me!

Tom Lake


Quote:

(Jeremy

> >I would like to know how I get the command line arguaments in QBASIC
....?

> Type QBASIC /? at the command prompt.

> ***** START OF COMMAND PROMPT SESSION *****

> Microsoft(R) Windows NT(TM)
> (C) Copyright 1985-1996 Microsoft Corp.

> D:\>qbasic /?
> Starts the MS-DOS QBasic programming environment.

> QBASIC [/B] [/EDITOR] [/G] [/H] [/MBF] [/NOHI] [[/RUN]

[drive:][path]filename]

- Show quoted text -

Quote:

>   /B          Allows use of a monochrome monitor with a color graphics
card.
>   /EDITOR     Starts the MS-DOS Editor.
>   /G          Provides the fastest update of a CGA screen.
>   /H          Displays the maximum number of lines possible for your
hardware.
>   /MBF        Converts the built-in functions MKS$, MKD$, CVS, and CVD to
>               MKSMBF$, MKDMBF$, CVSMBF, and CVDMBF, respectively.
>   /NOHI       Allows the use of a monitor without high-intensity support.
>   /RUN        Runs the specified Basic program before displaying it.
>   [[drive:][path]filename] Specifies the program file to load or run.

> D:\>

> ****** END OF COMMAND PROMPT SESSION ******



Mon, 15 Jul 2002 03:00:00 GMT  
 Getting the COMMAND line arguments in QBASIC

Quote:

>I think he wants the QBasic equivalent of QB's COMMAND$ rather than the
>pre-defined command line switches.  I've never seen a way to get
>user-defined command line arguments with QBasic.

You can write a batch file that accepts user-defined command line
arguments, writes them to a file, then runs QBASIC, but I don't
think QBASIC alone can do it.  Maybe under DOS you might be able
to peek at the keyboard buffer?


Mon, 15 Jul 2002 03:00:00 GMT  
 Getting the COMMAND line arguments in QBASIC
Here is an example program I threw together.

It is set up for GWBASIC, but notice the lines in the code
that specify which line to use for GWBASIC and which for QB4.5.

To see it work, at the command line type GWBASIC DTADEMO xxxxxx
where xxxxxx is your program's command line arguement.

You might need to fix up the code in case it does not come accross
well when posted to the newsgroup, but you get the idea.

10 REM DEMO OF READING A COMMAND LINE ARGUMENT FROM THE DISK TRANSFER
AREA
20 GOSUB 3000:REM SET UP ASSEMBLY LANGUAGE ROUTINE
30 GOSUB 2000:REM CALL ROUTINE TO GET PROGRAM SEGMENT PREFIX ADDRESS
40 DTA$="":REM CLEAR THE STRING INITIALLY
50 DEF SEG=PSPADD:REM POINT TO PSP SEGMENT (NUMBER OF CHARACTERS IS AT
&H80)
60 FOR A=&H81 TO &HFF:REM &H81 WILL USUALLY BE A SPACE
70 A$=CHR$(PEEK(A)):REM GET EACH CHARACTER
80 IF A$=CHR$(13) THEN 110:REM ALL COMMANDS SHOULD END WITH A CARRIAGE
RETURN
90 DTA$=DTA$+A$:REM BUILD STRING
100 NEXT A:REM CONTINUE UNTIL CARRIAGE RETURN
110 DEF SEG:REM BACK TO BASIC'S SEGMENT
120 PRINT "COMMAND ARGUEMENT=";DTA$
130 END
1970 REM
********************************************************************
1980 REM ----------- SET UP AND CALL ASSEMBLY LANGUAGE SUBROUTINE
-----------
1990 REM
2000 DEF SEG=&H4B                  :REM POINT TO SEGMENT OF SUBROUTINE
2010 ASMSUB=0:CALL ASMSUB          :REM THIS LINE FOR GWBASIC
INTERPRETER
2020 REM CALL ABSOLUTE(0)          :REM THIS LINE FOR QUICKBASIC
COMPILER
2030 PSPADD=(PEEK(4)*256)+PEEK(3)  :REM FORM PROGRAM SEGMENT PREFIX
ADDRESS
2040 IF PSPADD>32767 THEN PSPADD=PSPADD-65536!:BEEP
2050 DEF SEG                       :REM RETURN TO BASIC SEGMENT
2060 RETURN
2070 REM
2830 REM
********************************************************************
2840 REM ---------------- LOAD ASSEMBLY LANGUAGE SUBROUTINE
-----------------
2850 REM
2860 REM This routine loads a assembly language subroutine into the area
2870 REM just below the DOS inter-program communication area. 0000:04B0
2880 REM
2890 REM               CODE SEGMENT
2900 REM               ASSUME  CS:CODE
2910 REM               JMP     HERE            ;JUMP AROUND STORAGE AREA
2920 REM        TEMP   DW      0               ;STORAGE FOR REGISTERS-
2930 REM        HERE:  MOV      AH,62H          ;GET PSP ADDRESS FUNCTION
2940 REM                INT     21H             ;DOS FUNCTION CALL INTERRUPT
2950 REM                MOV     CS:TEMP,BX      ;STORE RETURNED VALUE
2960 REM               RETF                    ;FAR RETURN
2970 REM               CODE ENDS
2980 REM               END
2990 REM
3000 DEF SEG=&H4B:RESTORE 3040
3010 FOR I=0 TO 14:READ B:POKE I,B:NEXT I
3020 DEF SEG:RETURN
3030 REM -----
3040 DATA &HEB,&H03,&H90
3050 DATA &H00,&H00
3060 DATA &HB4,&H62
3070 DATA &HCD,&H21
3080 DATA &H2E,&H89,&H1E,&H03,&H00
3090 DATA &HCB

--

Gary Peek

http://www.industrologic.com



Mon, 15 Jul 2002 03:00:00 GMT  
 Getting the COMMAND line arguments in QBASIC
Since QB 4.5 includes the read-only variable COMMAND$, there's really no
need to do this in QB.

--
Interested in a FREE DSL Internet Connection?
E-Mail me!

Tom Lake


Quote:
> Here is an example program I threw together.

> It is set up for GWBASIC, but notice the lines in the code
> that specify which line to use for GWBASIC and which for QB4.5.

> To see it work, at the command line type GWBASIC DTADEMO xxxxxx
> where xxxxxx is your program's command line arguement.

> You might need to fix up the code in case it does not come accross
> well when posted to the newsgroup, but you get the idea.

> 10 REM DEMO OF READING A COMMAND LINE ARGUMENT FROM THE DISK TRANSFER
> AREA
> 20 GOSUB 3000:REM SET UP ASSEMBLY LANGUAGE ROUTINE
> 30 GOSUB 2000:REM CALL ROUTINE TO GET PROGRAM SEGMENT PREFIX ADDRESS
> 40 DTA$="":REM CLEAR THE STRING INITIALLY
> 50 DEF SEG=PSPADD:REM POINT TO PSP SEGMENT (NUMBER OF CHARACTERS IS AT
> &H80)
> 60 FOR A=&H81 TO &HFF:REM &H81 WILL USUALLY BE A SPACE
> 70 A$=CHR$(PEEK(A)):REM GET EACH CHARACTER
> 80 IF A$=CHR$(13) THEN 110:REM ALL COMMANDS SHOULD END WITH A CARRIAGE
> RETURN
> 90 DTA$=DTA$+A$:REM BUILD STRING
> 100 NEXT A:REM CONTINUE UNTIL CARRIAGE RETURN
> 110 DEF SEG:REM BACK TO BASIC'S SEGMENT
> 120 PRINT "COMMAND ARGUEMENT=";DTA$
> 130 END
> 1970 REM
> ********************************************************************
> 1980 REM ----------- SET UP AND CALL ASSEMBLY LANGUAGE SUBROUTINE
> -----------
> 1990 REM
> 2000 DEF SEG=&H4B                  :REM POINT TO SEGMENT OF SUBROUTINE
> 2010 ASMSUB=0:CALL ASMSUB          :REM THIS LINE FOR GWBASIC
> INTERPRETER
> 2020 REM CALL ABSOLUTE(0)          :REM THIS LINE FOR QUICKBASIC
> COMPILER
> 2030 PSPADD=(PEEK(4)*256)+PEEK(3)  :REM FORM PROGRAM SEGMENT PREFIX
> ADDRESS
> 2040 IF PSPADD>32767 THEN PSPADD=PSPADD-65536!:BEEP
> 2050 DEF SEG                       :REM RETURN TO BASIC SEGMENT
> 2060 RETURN
> 2070 REM
> 2830 REM
> ********************************************************************
> 2840 REM ---------------- LOAD ASSEMBLY LANGUAGE SUBROUTINE
> -----------------
> 2850 REM
> 2860 REM This routine loads a assembly language subroutine into the area
> 2870 REM just below the DOS inter-program communication area. 0000:04B0
> 2880 REM
> 2890 REM               CODE SEGMENT
> 2900 REM               ASSUME  CS:CODE
> 2910 REM               JMP     HERE            ;JUMP AROUND STORAGE AREA
> 2920 REM        TEMP   DW      0               ;STORAGE FOR REGISTERS-
> 2930 REM        HERE:  MOV AH,62H          ;GET PSP ADDRESS FUNCTION
> 2940 REM        INT 21H             ;DOS FUNCTION CALL INTERRUPT
> 2950 REM        MOV CS:TEMP,BX      ;STORE RETURNED VALUE
> 2960 REM               RETF                    ;FAR RETURN
> 2970 REM               CODE ENDS
> 2980 REM               END
> 2990 REM
> 3000 DEF SEG=&H4B:RESTORE 3040
> 3010 FOR I=0 TO 14:READ B:POKE I,B:NEXT I
> 3020 DEF SEG:RETURN
> 3030 REM -----
> 3040 DATA &HEB,&H03,&H90
> 3050 DATA &H00,&H00
> 3060 DATA &HB4,&H62
> 3070 DATA &HCD,&H21
> 3080 DATA &H2E,&H89,&H1E,&H03,&H00
> 3090 DATA &HCB

> --

> Gary Peek

> http://www.industrologic.com



Mon, 15 Jul 2002 03:00:00 GMT  
 Getting the COMMAND line arguments in QBASIC


Quote:
> I would like to know how I get the command line arguaments in QBASIC ....?

This is very easy from a Windows DOS Prompt and quite easy from MS-DOS.  The
same method can be used for QBASIC or for QuickBASIC.  Firstly, here's how
to do it when running a QBASIC program from the Windows DOS Prompt.

1)    Run your BASIC program

2)    Use the command  --  LET C$ = ENVIRON$("CMDLINE")  --  to load the
command line text into C$.

C$ now contains the whole line which you typed in at the DOS prompt.  You
can print it or process it in any way that you need to.

Secondly, it's not quite so satisfactory, but here's how to do it when you
are running a QBASIC program from the MS-DOS Prompt.

1)    Create a little batch file called QBASIC.BAT containing these lines

SET CMDLINE=qbasic.exe
:Again

set CMDLINE=%CMDLINE% %1
SHIFT
GOTO :Again
:Done
%CMDLINE%
set CMDLINE=

2)    Save that file in your DOS directory.

3)    Run your BASIC program

4)    Use the command  --  LET C$ = ENVIRON$("CMDLINE")  --  to load the
command line text into C$.

In some ways these methods are better than using the COMMAND$ function which
is built into QuickBASIC 4.5 because they give you the complete command line
whereas COMMAND$ only gives you the command line after it has been converted
to upper case and had the first "word" cut off it.  Sometimes you want to
know what the case of the command line was and sometimes you want a program
to know its own name.  COMMAND$ will not help you in those cases but
ENVIRON$("CMDLINE") will.

Cheers

Derek



Mon, 15 Jul 2002 03:00:00 GMT  
 
 [ 10 post ] 

 Relevant Pages 

1. Command line arguments in QBasic

2. Re; Command line arguments in QBasic

3. Getting command line arguments...

4. Getting the command line arguments

5. Getting command line arguments with Win32_process

6. getting a qbasic program to run the command to start another non qbasic

7. Command-Line arguments using Command()

8. "/decompile" command line argument

9. command line arguments for project files

10. Command Line arguments for Project

11. Project_Open and command Line arguments in MSP2k

12. Command Line Arguments

 

 
Powered by phpBB® Forum Software