Qbasic Interpreter for Scott Adams games

Hi guys,

Im trying this interpreter and everything is working fine but the games are not showing the items, it only says “visible items.”

trs-80.com/wordpress/emulation-scott-adams/
Goes to Qbasic Interpreter

Anyone has a clue what goes wrong?. Im using windows and QB64 for compile the basic code.

Anyone knows the creator Chad Elliot?

The code about this is:

[code]
’ -------------------------------
’ °±² ROOM DRAWING SUBROUTINE ²±°
’ -------------------------------
DRAWROOM:

IF BITFLAGS(15) = 0 OR ITEMLOCATIONS(9) = CURRENTROOM OR ITEMLOCATIONS(9) = -1 THEN
DWALK = 0
END IF

VIEW PRINT 1 TO 13
IF BITFLAGS(15) = 0 THEN COLOR FCTOP, BCTOP
IF BITFLAGS(15) = 1 AND ITEMLOCATIONS(9) <> CURRENTROOM AND ITEMLOCATIONS(9) <> -1 THEN COLOR 15, 1
IF BITFLAGS(15) = 1 AND ITEMLOCATIONS(9) = CURRENTROOM OR BITFLAGS(15) = 1 AND ITEMLOCATIONS(9) = -1 THEN COLOR 15, 6

FOR X = 0 TO 10
PRINT " "
NEXT X
LOCATE 1

IF BITFLAGS(15) = 0 OR ITEMLOCATIONS(9) = CURRENTROOM OR ITEMLOCATIONS(9) = -1 THEN
TEMP$ = UCASE$(MID$(DESCRIPTION$(CURRENTROOM), 1, 1))
IF TEMP$ <> “*” THEN
PRINT "I’m in a ";
PRINT DESCRIPTION$(CURRENTROOM)
ELSE PRINT MID$(DESCRIPTION$(CURRENTROOM), 2, LEN(DESCRIPTION$(CURRENTROOM)) - 1)
END IF
ELSE PRINT “It’s too dark to see.”
END IF

PRINT
PRINT "OBVIOUS EXITS: ";

IF BITFLAGS(15) = 0 OR ITEMLOCATIONS(9) = CURRENTROOM OR ITEMLOCATIONS(9) = -1 THEN
IF MAP(CURRENTROOM, 0) <> 0 THEN PRINT "NORTH ";
IF MAP(CURRENTROOM, 1) <> 0 THEN PRINT "SOUTH ";
IF MAP(CURRENTROOM, 2) <> 0 THEN PRINT "EAST ";
IF MAP(CURRENTROOM, 3) <> 0 THEN PRINT "WEST ";
IF MAP(CURRENTROOM, 4) <> 0 THEN PRINT "UP ";
IF MAP(CURRENTROOM, 5) <> 0 THEN PRINT “DOWN”;
END IF

PRINT
PRINT
PRINT "VISIBLE ITEMS: ";

IF BITFLAGS(15) = 0 OR ITEMLOCATIONS(9) = CURRENTROOM OR ITEMLOCATIONS(9) = -1 THEN
FOR X = 0 TO NUMBEROFWORDS
IF ITEMLOCATIONS(X) = CURRENTROOM THEN
TEMP$ = ITEM$(X) + " - "
IF POS(0) + LEN(TEMP$) > 80 THEN PRINT
PRINT TEMP$;
END IF
NEXT X
IF CSRLIN > 0 AND POS(0) - 2 > 0 THEN
LOCATE CSRLIN, POS(0) - 2
PRINT “.”
END IF
END IF

LOCATE 10
PRINT “<------------------------------------------------------------------------------>”;
VIEW PRINT 11 TO 25
COLOR FCBOT, BCBOT
LOCATE 25
PRINT " "
RETURN[/code]

I downloaded and tried the program in QB4.5 running in DOSBOX on Win7 64b without any problems. The line prints as expected after 'VISIBLE ITEMS: ’
I can only surmise that QB64 is doing something under the hood that is not the same as the original QB4.5 program. I had quick browse of the QB64 wiki but didn’t see anything there that should prevent this from running correctly. Unfortunately QB664 doesn’t have any debug commands (that I could find) to allow for a closer inspection. It did however state that programs should be tested in QB4.5 or QBASIC before compiling in QB64. You may need to report it as a bug in their forums.

Thank you for the answer, for some reason the forum of QB64 doesn’t allow me to post or login.

Is there another Basic tool, QB45 or QBX, etc, that creates an .EXE file out there for windows machines?

FreeBASIC, with the command line option –lang qb (although it may require a few minor tweaks).

Thank you, I’ll try that.

R2T1, I think i found the debug for the QB64, it’s in the menu/Options, check mark and create an exe, it will add some files to the program files, do you understand any of that? I would be helpful.

Hey prevtenet, I run the program in FreeBasic and I have these errors, do you know how to fix it?

[code]C:\Users\mdiaz\Dropbox\Qbasic\FreeBasic>FBC -lang qb SCOTTQB.BAS
SCOTTQB.BAS(77) error 10: Expected ‘=’, found '.DAT’
FILES "
.DAT"
^
SCOTTQB.BAS(979) error 72: Array access, index expected, before ‘=’
FOR A = 1 TO LEN(ITEM$(B))
^
SCOTTQB.BAS(980) error 72: Array access, index expected, before ‘,’
IF MID$(ITEM$(B), A, 1) <> " " THEN TEMPWORD$ = TEMPWORD$ + UCASE$(MID$(IT
EM$(B), A, 1))
^
SCOTTQB.BAS(980) error 72: Array access, index expected, before ‘,’
IF MID$(ITEM$(B), A, 1) <> " " THEN TEMPWORD$ = TEMPWORD$ + UCASE$(MID$(IT
EM$(B), A, 1))

     ^

SCOTTQB.BAS(981) error 72: Array access, index expected, before ‘,’
IF MID$(ITEM$(B), A, 1) = " " OR A = LEN(ITEM$(B)) THEN
^
SCOTTQB.BAS(999) error 72: Array access, index expected
NEXT A
^[/code]

The first error is because FreeBASIC doesn’t support QBasic’s FILES command; just comment out that line, unless you feel like writing your own FILES routine using the DIR() function.

The rest of the errors are because A is being used both as a single variable and as an array. QBasic lets you do this, FreeBASIC doesn’t. I’d suggest changing all the usages of A that aren’t array access - i.e. A(something) - to another letter, so FreeBASIC knows it’s a different variable.

Ok, thank you, i made the changes. It compiled but when running the games the program crashes. Any other qbasic to exe tool?

Not that I know of, aside from, you know, the actual QuickBASIC 4.5 DOS compiler. You’ll probably need to stick with QB64 or FreeBASIC and get into the code to figure out why it’s not working.

I couldn’t work out the DEBUG you suggested, so I reverted to the age-old method of inserting print statements at strategic locations.
I used ADV01.DAT for all testing as the first room should have 1 visible item - Trees.

IF I add thisPRINT "VISIBLE ITEMS: "; PRINT CURRENTROOM; " "; FOR xx = 0 TO 69 ' there are 70 items (NUMBEROFWORDS) IF ITEMLOCATIONS(xx) = 11 THEN ' 11 is the current room number PRINT xx; " "; ITEMLOCATIONS(xx); " "; ITEM$(xx) END IF NEXT to the ROOM DRAWING SUBROUTINE, I can see that the CURRENTROOM is 11. (This is the same in QB64 & QB4.5)
ITEMLOCATIONS(58) should hold the value 11 (the current room number) and ITEM$(58) holds the string “trees”.

This all prints as expected in QB4.5 however QB64 prints nothing. I suspect that the array is either not being loaded correctly after choosing the game to play. Given that QB64 is still a beta version, you may need to try to contact the author if he is still around or download the source code and try to work it out yourself.
It could also be, & most likely is, (as the program runs OK in QB4.5) the C++ compiler that is the fault.

QB4.5 also has the ability to make an .EXE file but I suspect it may only be a 16bit file which won’t run under WIN 64bit.