Is it possible to use command prompt commands with Qbasic?!

If you have questions about any aspect of QBasic programming, or would like to help fellow programmers solve their problems, check out this board!

Moderators: Pete, Mods

Post Reply
Sinuvoid
Veteran
Posts: 155
Joined: Wed Jul 25, 2007 8:20 am

Is it possible to use command prompt commands with Qbasic?!

Post by Sinuvoid »

How!!!(Title is my question)
User avatar
Stoves
Veteran
Posts: 101
Joined: Fri Feb 10, 2006 12:24 am
Location: Nashville, TN

Post by Stoves »

SHELL command

example:

SHELL "cd .."

or

SHELL "dir > t.tmp"

etc.

Code using SHELL that checks if a file exists:

Code: Select all

fileExists = 0
SHELL "dir/a/on/b autoexec.bat > t.tmp"

frnum = FREEFILE
OPEN "t.tmp" FOR INPUT AS #frnum
    DO WHILE NOT EOF(frnum) AND fileExists = 0
	fileExists = 1
    LOOP
CLOSE #frnum
	
IF fileExists = 0 THEN
    PRINT "File NOT found."
ELSE
    PRINT "File found."
END IF
Anonymous

Post by Anonymous »

you sure can, use SHELL

Code: Select all

Shell "echo hello"
User avatar
Kiyotewolf
Veteran
Posts: 96
Joined: Tue Apr 01, 2008 11:38 pm

Shelling around

Post by Kiyotewolf »

I solved this problem awhile ago..

First, write a batch file to start QBasic interpreter to run your program, and in the same batch file have it execute another batch file that the QBasic program creates.

If necessary, have the batch file the qbasic program makes set an environment variable that the main batch file can branch off from if set ..

I made a QBasic menu that runs programs, as well as QBasic programs from a list and used the batch file to do the calling so the two programs were not in the memory at the same time.

If you do not understand batch files.. you can either ask me or .. or.. i dunno..

I'm an expert at coding batch files. I have written a few gems in my time.

Kiyote!
Banana phone! We need more lemon pledge. * exploding fist of iced tea! * I see your psycho cat and counter with a duck that has a broken leg, in a cast.
User avatar
burger2227
Veteran
Posts: 2466
Joined: Mon Aug 21, 2006 12:40 am
Location: Pittsburgh, PA

Post by burger2227 »

Your humility is beyond amazing braggart!
Please acknowledge and thank members who answer your questions!
QB64 is a FREE QBasic compiler for WIN, MAC(OSX) and LINUX : https://www.qb64.org/forum/index.php
Get my Q-Basics demonstrator: https://www.dropbox.com/s/fdmgp91d6h8ps ... s.zip?dl=0
User avatar
Kiyotewolf
Veteran
Posts: 96
Joined: Tue Apr 01, 2008 11:38 pm

excuse me?

Post by Kiyotewolf »

Humility?

....


The reason I said I can expertly program batch files is because the zillions of us that have moved on from DOS to Win 3.11 to Win 9x to Vista then realizing how crappy Vista is then to Linux is..

..... how many of us actually remember how to code in *.BAT?

I do..

I was offering my services as I won't make them look like an idiot if I coded for them and they tried it and found a "syntax error" or "command undefined" from DOS or their virtual shell of choice.

I have been able to sneak around the shortcomings of Windows by employing batch files strategically in MIME handling and other stuffs, and am 100% confident in my work.

It's not a matter of boasting, simply a matter of pride. I have reached that point in *.BAT that I'm still striving for in *.BAS.

I will never be as good as other QBasic programmers, I am ALWAYS learning.. but in *.BAT, I have become quite fluent and am not a blithering idiot.

I can even code in TRS-80 Basic if you wanted me to or 6502 Commodore 64 C= Assembly for Christmas Sake if you asked, and even code a real commodore wedge.. so don't get on my case about being cute, I was just reasuring them that I can code in batch and that's final.

Like I said before, flaming is bogus man, and not worth my time..

So... have a donut on me.. and have a guud day dude.

See you in the next issue of QBXpress

Kudos

Kiyote!
Banana phone! We need more lemon pledge. * exploding fist of iced tea! * I see your psycho cat and counter with a duck that has a broken leg, in a cast.
Post Reply