Translate

Thursday, April 5, 2018

Some Basics 4 MSX Basic ( part 2 )

Here is already part 2 of my tips and tricks. Have fun !

Problem: Test if the right disk is in the drive
 
Solution: Using FILES and ON ERROR GOTO instead of DSKI$
 
Example:
100 PRINT " Check disk with HELLO.BAS"110 ON ERROR GOTO 150
120 FILES "HELLO.BAS"
130 PRINT "Disk okay"
140 GOTO 180
150 IF ERL=120  AND ERR=53 THEN 190
160 PRINT ERR,ERL
170 ON ERROR GOTO 0
180 END
190 PRINT "Wrong Disk"
200 RESUME 170

As you can see, it just checks of the file HELLO.BAS exist on the disk. 
If not if and there is a disk inserted, it prints that it's the "Wrong Disk". 

When other errors happened, like no disk in drive, it just prints the error + error line 
and stops. I use ERL=120 to check where the error starts (in the line with FILES)  
and ERR=53 (File not found) to be sure I test only if HELLO.BAS exists.

I used this trick in the mainmenu's of the WORDSTORE Picture Demo's 
to check if the demo was on the inserted disk or not.

No comments:

Post a Comment