AboutAlex 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++
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