AllExperts > Qbasic, Quickbasic 
Search      
Qbasic, Quickbasic
Volunteer
Answers to thousands of questions
 Home · More Qbasic, Quickbasic Questions · Answer Library  · Encyclopedia ·
More Qbasic, Quickbasic Answers
Question Library

Ask a question about Qbasic, Quickbasic
Volunteer
Experts of the Month
Expert Login

Awards

About Us
Tell friends
Link to Us
Disclaimer

 
 
 
 
About Alex Barry
Expertise
I have been a qbasic programmer since 2000, creating games, minor libraries and various small programs. I have experience using interrupts, graphics, file input/output, the mouse cursor, and using libraries. I have also learned FreeBASIC, c/c++, python, php and html.
I do not claim to be an absolute authority in any language, but I don't mind looking things up and learning with you.

Experience
Hobby programming since 2000

I no longer belong to any community programming groups, but do have knowledge of *basic dialects and C/C++

 
   

You are here:  Experts > Computing/Technology > Basic > Qbasic, Quickbasic > Passing Parameters

Qbasic, Quickbasic - Passing Parameters


Expert: Alex Barry - 3/9/2009

Question
Hi Alex, i hope you can give me some idea regarding my problem. Can I pass a parameter coming from the outside of the program? For example I have a program named 'PROGRAM.BAS', can I pass a parameter on this by executing PROGRAM Jojo 1234? Wherein the Jojo and 1234 value will be accepted inside the PROGRAM.BAS and manipulated.

Answer
Hi, Jojo,

What you'll want is to use the COMMAND$() built-in array.  I'm not sure if this will work without compiling the program, though.
To call the script, you'd do something like:
qb.exe yourBasicCode.bas arg1 arg2 3

You'll have to play around with the command to get it working right.

You may want to make a command like this:

FUNCTION HasCommandLine( lookFor AS STRING, index AS INTEGER )
 DIM i AS INTEGER
 HasCommandLine = -1
 IF index < 0 THEN
   FOR i = LBOUND( COMMAND$ ) TO UBOUND( COMMAND$ )
     IF LCASE$( COMMAND$( i ) ) = LCASE$( lookFor ) THEN
       HasCommandLine = i
       EXIT FUNCTION
     END IF
   NEXT i
 ELSE
   IF LCASE$( COMMAND$( index ) ) = LCASE$( lookFor ) THEN
     HasCommandLine = index
     EXIT FUNCTION
   END IF
 END IF

END FUNCTION

I hope that helps you out,
-Alex

Add to this Answer   Ask a Question


 
User Agreement | Privacy Policy | Kids' Privacy Policy | Help
Copyright  © 2008 About, Inc. AllExperts, AllExperts.com, and About.com are registered trademarks of About, Inc. All rights reserved.