Minor problem...

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
Anlino

Minor problem...

Post by Anlino »

I have been working on a couple various programs, games, utilities, graphics etc, but i have forgoten hove you instruct another program to open another file!

My goal is to make one file, that you can boot everything from.
So, if i want to run my Tetris from it, i simple type Tetris in a INPUT, and then Tetris boots. When i shut Tetris down, i come back to the file that i could boot everything from.

The problem is, i have forgotten wich command it was that opened other files. If someone could answer me on this one, i would be grateful.

/Anlino
User avatar
{Nathan}
Veteran
Posts: 1169
Joined: Thu Aug 19, 2004 6:08 pm
Location: The wetlands of central Ohio, USA
Contact:

Post by {Nathan} »

Im pretty sure you want chain. It is just like this:

Code: Select all

if lcase$(input$) = "tetris" then chain "tetris.bas"
or, if its a .exe then you want shell

Code: Select all

if lcase$(input$) = "tetris" then shell "tetris.exe"
it depends whether its a .exe or .bas.
Image
Anlino

Post by Anlino »

Ok, thanks.
It worked perf.
Anlino

Post by Anlino »

Discovered a minor problem here Though...

When i type in the name of the program, it said that i couldnt find it, redo, or something like that. But when i doesnt type in anything, all programs boot.(It took a while to shut down all of them...) Here is a piece of the code i use:

IF (valj = Tetris) THEN
Shell "tetris.exe"
END IF
IF (valj = Pacman) THEN
Shell "pacman.exe"
END IF
IF (valj = Solitaire) THEN
shell "solitaire.exe"
END IF

Can anyone of you discover a mistyping or something like that in this piece of code?

(I know that i am being a real a:!::!: going around like this, but it puts you on when something doesnt work)

Thanks,
Anlino
User avatar
Xerol
Veteran
Posts: 81
Joined: Tue Jan 04, 2005 6:27 pm
Location: Timonium, MD
Contact:

Post by Xerol »

You're using a numerical value, when you should be using a string. When you don't type in anything, that's basically like inputting 0, and previously unused variables are initialised as 0, so Tetris, Pacman, and Solitaire are all integers that are 0.

Also, you'll need to strip the input down so that the user can input them in either upper or lower or mixed case, that's what LCASE$() does. (It makes the string all lowercase.)

And you need to change all instances of valj to valj$ so that it's a string, not a numerical value.

Fixed code:

Code: Select all

IF (lcase$(valj$)) = "tetris") THEN 
Shell "tetris.exe" 
END IF 
IF (lcase$(valj$)) = "pacman") THEN 
Shell "pacman.exe" 
END IF 
IF (lcase$(valj$)) = "solitaire") THEN 
shell "solitaire.exe" 
END IF 
If you need music composed in MP3, WAV, or MIDI format, please contact me via email.

Xerol's Music - Updated Regularly!
User avatar
{Nathan}
Veteran
Posts: 1169
Joined: Thu Aug 19, 2004 6:08 pm
Location: The wetlands of central Ohio, USA
Contact:

Post by {Nathan} »

... they always beet me to it
Image
Anlino

Post by Anlino »

ok, thanks (again...)
User avatar
{Nathan}
Veteran
Posts: 1169
Joined: Thu Aug 19, 2004 6:08 pm
Location: The wetlands of central Ohio, USA
Contact:

Post by {Nathan} »

ohh, and next time use the code tags
Image
Post Reply