Page 1 of 1

Minor problem...

Posted: Mon Jun 13, 2005 11:15 am
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

Posted: Mon Jun 13, 2005 11:59 am
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.

Posted: Mon Jun 13, 2005 2:31 pm
by Anlino
Ok, thanks.
It worked perf.

Posted: Mon Jun 13, 2005 2:55 pm
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

Posted: Mon Jun 13, 2005 3:08 pm
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 

Posted: Mon Jun 13, 2005 6:42 pm
by {Nathan}
... they always beet me to it

Posted: Mon Jun 13, 2005 11:19 pm
by Anlino
ok, thanks (again...)

Posted: Tue Jun 14, 2005 12:00 pm
by {Nathan}
ohh, and next time use the code tags