Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

passing parameters to QBASIC.EXE 1.1

Status
Not open for further replies.

MrMoor

Technical User
Apr 13, 2003
1
US
ok so I looked for the answer in the posts and the answer given was

COMMAND$

unfortunatly in the qbasic help this is listed:

The following QuickBasic keywords are not supported in QBasic:

ALIAS EVENT LOCAL SETMEM
BYVAL $INCLUDE SADD SIGNAL
CDECL Int86 Interrupt UEVENT
COMMAND$ Int86X InterruptX

So how can I pass a command line parameter to a QBASIC.EXE (1.1) program from a batch file?

Mind you I have no problem expanding the batch file too, and this can be part of an exceptable solution.

Thanks
Eric
 
I think I have seen an example there man had read from screen (or from environment strings?)
But anyway it's too complex for me ;)
(actually I had not such problem - so I just marked in my mind "that's just not possible [to do it simple]").
But! You mention BAT files... So I tried.
Here is it:
batch file, "params.bat"
Code:
@echo off
if "%1"=="" goto usage

del params.dat
:again
echo %1 >>params.dat
shift
if "%1"=="" goto run
goto again

:run
qbasic /run params.bas
goto end

:usage
echo This program needs some parameters

:end
program, "params.bas"
Code:
open "params.dat" for input as #1
?"Passed parameters:"
while not eof(1)
	line input #1, a$
	?&quot;>&quot;;a$;&quot;<&quot;
wend
?&quot;That's all&quot;
system
starting program
Code:
params.bat test1 2 13 157.11 &quot;7mbmnbfgg hfhgf &quot;
output
Code:
Passed parameters:
>test1 <
>2 <
>13 <
>157.11 <
>&quot;7mbmnbfgg hfhgf &quot; <
That's all
Hope this helps (man, I really like it! ;))
 
apparently Qbasic 1.1 does not have command$
You can find qb4.5 around though (illegal without permission)

but it will work using $command

should be as easy as:
(in bat file)
qbasic /run progname.bas /CMD &quot;myparam&quot;

in the qb file

a$=command$

then for testing

print a$

 
As everyone mentioned, you'll need to use an environment string to pass params along.

Here's a quick test you can try, files are BAT and BAS respectfully:


(example of bat file:)
rem File--Test.bat
rem
@echo off
cls
echo About to start QB 1.0 with params /Run TestMe.bas
echo Storing Miggyd to PassBASParam for QB 1.0
set PassBASParam=Miggyd
pause
qbasic10.exe /run testme.bas
exit


(example of bas file:)
rem File--TestMe.bas
rem
CLS
FromEnviron$ = ENVIRON$(&quot;PASSBASPARAM&quot;)
IF FromEnviron$ = &quot;&quot; THEN
PRINT &quot;Sorry, nothing passed...can't run&quot;
ELSE
PRINT &quot;Work around [Passed Param]: &quot;; FromEnviron$
print &quot;was found in DOS environment.&quot;
END IF
PRINT &quot;Press any key to exit&quot;
SLEEP 20
END
 
Sorry, forgot to mention that I really did use QB 1.0 (not 1.1) for this test on WinME.

--MiggyD
 
You should really update. I think that you can find newer versions at qb4all.com. Although it may be techinqually illegal to download newer versions of qbasic, microsoft does not support it. When I emailed them, they said it was no longer supported, and that there was no problem with me getting it off the internet. On another site, that allowed qbasic downloads, the author supposedly got the same kind of answer. You can download 7.1 there. It is eagleperch.net.
 
PERSONALLY, I SUGGEST QB 4.5

IT IS THE MOST WIDELY USED, SEEMS TO RUN FASTER, AND 7.1 DOES NOT SUPPORT 4.5 LIBRARIES

, USUALLY ALSO HAS A WIDE VARIETY OF COMPILERS

Have Fun, Be Young... Code BASIC
-Josh Stribling
cubee101.gif

 
Thanks guys but the truth of the matter is that I have QB 1.0, 1.1, 4.5, and 7.1 along with VB 4 (primarily for my Win95 Clients -- and one Win 3.11 [don't even ask]) and VS 6 (everybody else LOL ).

Once upon a time I also had VB for DOS (for all of 3 weeks) then I found VB 4 at an expo and threw out vb 1.

The reason I posted the second time was so that MrMoor can see that QB 1.1 should be able to handle it (backward compatability ya'no?). I didn't think that it would have mattered but thanks anyway.

--MiggyD
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top