Author Topic: Shortest bug ever?  (Read 5911 times)

flet

  • Guest
Shortest bug ever?
« on: 2008-Jan-06 »
Hi - I'm new to GLBasic and am currently evaluating it for use on Windows Mobile.

Found a bug in the compiler (GLBasic 5.037):

Source code :

Code: (glbasic) [Select]
a=","That's all...

Compiler crashes:

Quote
*** Configuration: WINCE ***
precompiling:
GPC - GLBasic Precompiler V.2007.264 - 2D, WIN32
Wordcount:1 commands

compile+link:
C:/DOCUME~1/ADMINI~1/LOCALS~1/Temp/glbasic/gpc_temp0.cpp: In function `int
   __GLBASIC__::__MainGameSub_()':
C:/DOCUME~1/ADMINI~1/LOCALS~1/Temp/glbasic/gpc_temp0.cpp:6: error: cannot
   convert `__GLBASIC__::CGStr' to `DGInt' in assignment
*** FATAL ERROR - Please post this output in the forum

Offline Kitty Hello

  • code monkey
  • Administrator
  • Prof. Inline
  • *******
  • Posts: 10760
  • here on my island the sea says 'hello'
    • View Profile
    • http://www.glbasic.com
Shortest bug ever?
« Reply #1 on: 2008-Jan-06 »
a$ - you're assigning a string.
You can convert strings to numbers:
a$ = "5.0"
a = a$
but not const strings.

flet

  • Guest
Shortest bug ever?
« Reply #2 on: 2008-Jan-07 »
Quote from: GernotFrisch
a$ - you're assigning a string.
You can convert strings to numbers:
a$ = "5.0"
a = a$
but not const strings.
Right. My code is definitely buggy.
However, my point was to stress that it makes the compiler crash - instead of reporting a bug in the source code. The bottomline is: if you have a line such as <> (instead of, say, <>) in a 1000 lines source code, you get absolutely no idea what's going wrong, and you need very good eyes to figure that the line is the source of the crash.

Offline Kitty Hello

  • code monkey
  • Administrator
  • Prof. Inline
  • *******
  • Posts: 10760
  • here on my island the sea says 'hello'
    • View Profile
    • http://www.glbasic.com
Shortest bug ever?
« Reply #3 on: 2008-Jan-07 »
Ah. Right. :)
It's a problem of the C++ interface. It should work, but it makes not much sense.

flet

  • Guest
Shortest bug ever?
« Reply #4 on: 2008-Jan-10 »
Hi,

other bugs such as array assignments without proprer dim sometimes let the C++ compiler yell. But there's no way to trace the error back to the GLBasic source...

Offline shaf

  • Mc. Print
  • *
  • Posts: 18
    • View Profile
Shortest bug ever?
« Reply #5 on: 2008-Jan-12 »
I've had the same problem with array assignments
usually the complier give an error something like this:

C:/Users/shaf/AppData/Local/Temp/glbasic/gpc_temp0.cpp:195: error: invalid initialization of reference of type '__GLBASIC__::DGIntArray&' from expression of type 'DGInt'
C:/Program Files (x86)/GLBasic/Compiler/platform/Include/glb.h:407: error: in passing argument 1 of `void __GLBASIC__::DIM(__GLBASIC__::DGIntArray&, DGInt, DGInt, DGInt, DGInt)'
C:/Users/shaf/AppData/Local/Temp/glbasic/gpc_temp0.cpp:197: error: `__GLBASIC__::AC' cannot be used as a function
C:/Users/shaf/AppData/Local/Temp/glbasic/gpc_temp0.cpp:199: error: `__GLBASIC__::AC' cannot be used as a function
C:/Users/shaf/AppData/Local/Temp/glbasic/gpc_temp0.cpp:201: error: `__GLBASIC__::AC' cannot be used as a function
C:/Users/shaf/AppData/Local/Temp/glbasic/gpc_temp0.cpp:203: error: `__GLBASIC__::AC' cannot be used as a function

The AC array is my Primarry array for the text adventure I'm working on.

Shaf

Offline Kitty Hello

  • code monkey
  • Administrator
  • Prof. Inline
  • *******
  • Posts: 10760
  • here on my island the sea says 'hello'
    • View Profile
    • http://www.glbasic.com
Shortest bug ever?
« Reply #6 on: 2008-Jan-13 »
post some source, maybe?

Offline shaf

  • Mc. Print
  • *
  • Posts: 18
    • View Profile
Shortest bug ever?
« Reply #7 on: 2008-Jan-15 »
Attached is the Source for the Array errors above:
Code: (glbasic) [Select]
// --------------------------------- //
// Project: Tower of Mystery
// Start: Tuesday, November 06, 2007
// IDE Version: 5.062
// Upgraded to IDE Version: 5.129
//
// declare constants
//
// NR number of rooms
// NT number of things/items
// NP number of Pseudo-Objects (all other Objects)
// NO number of objects of all kinds
// NV number of verbs
//
// declare Flags
//
// CA Computer Active (in-game)
// CD Computer is Dead
// LI Character is logged into computer
// CP COPY of program is running on computer
// MF Computer Manual Found
// MT Tape mounted
// CF Coin Found
// WD Room description request flag
// RatFight  Rats are Trouble (was RT)
// BatFight Bats are trouble (was BT)
// CT Time since computer was started
//
// General Variables
//
// C$  Command input
// C1$ First word of command
// C2$ Second Word of command
// C1  Verb token
// C2 Object token
// RM Room currently occupied
//
// Arrays
//
// AC[NR][6] Access Array
// VB$[NV] Verb array
// OB$[NO] Object Array
// RM$[NR] Room description array
// TD$[NT] Item description array
// VN[NV]  Verb token array
// ItemLoc[NT]  Item Location Array (Initially was TL[nt])
// ItemFlag[NT]  Item Flag array (for can item be carried) )(Initially was TF[nt])
//
// Directions can be numeric or alpha
//
// 1 N  North
// 2 S  South
// 3 E  East
// 4 W  West
// 5 U  Up
// 6 D  Down
//
//
GLOBAL RatFight, BatFight, AC, FT, I, K, L, X, A, A$, NR, NT, NP, NV, NO, MT
GLOBAL RM, CT, CF, RT, CA, MF, CD, WD, LI,  CP, BT, VB$, OB$, RM$, TD$, VN, TLL, ItemFlag, ItemLoc
GLOBAL C1, C2, C3, C4, C$, C1$, C2$, ItemLocF, AccessF, ROOMARRAY
NR=14
NT=11
NP=11
NV=29
NO=NT+NP
// DIM AC[NR-1][5]
// DIM VB$[NV]
// DIM OB$[NO]
// DIM RM$[NR]
// DIM TD$[NT]
// DIM VN[NV]
// DIM ItemLoc[NT]
// DIM ItemFlag[NT]
// Initialization of Variables
RM = 1
CT= 0
CF= 0
INTEGER (RatFight)
RatFight=-1
CA= 0
MF= 0
CD= 0
WD= -1
LI= 0
INTEGER (BatFight)
BatFight=-1
FOR I = 1 TO NR
DIM RM$[i]
DIMDATA RM$[], "You are in the front of an old factory with a Clock tower." ,"You are at the bottom of a stairwell." ,"You are at the top of the basement steps." ,"You are in a damp cellar." ,"You are in a storeroom." ,"You are in the cafeteria." ,"You are at a landing on the stairs." ,"Around you is a manufacturing area." ,"You are at a landing on the third floor." ,"You are in the Computer room." ,"You are inside the Clock Tower." ,"You are at the top of the stairs." ,"You are in a long corridor going east." ,"You are at the east end of the corridor."

NEXT
FOR I = 1 TO NV
// READ VB$[i],VN[i];
DIM VB$[i]
DIMDATA VB$[], "N","S","E","W","U","D","GO","EAT","KICK","INSERT","DEPOSIT","TYPE","TAKE","GET","DROP","THROW","INVENTORY","I","INV","MOUNT","READ","FIGHT","KILL","START","POWER","OPEN","QUIT","LOOK","WIND","EXAMI","EXAMINE"
DIM VN[i]
DIMDATA VN[], 1,2,3,4,5,6,7,8,9,10,10,11,12,12,13,13,14,14,14,15,16,17,17,18,18,19,20,21,22,23,23
// DATA N,1,S,2,E,3,W,4,U,5,D,6,"GO",7,"EAT",8,"KICK",9,"INSERT",10,"DEPOSIT",10,"TYPE",11
// DATA "TAKE",12,"GET",12,"DROP",13,"THROW",13,"INVENTORY",14,I,14,"INV",14,"MOUNT",15,"READ",16
// DATA "FIGHT",17,"KILL",17,"START",18,"POWER",18,"OPEN",19,"QUIT",20,"LOOK",21
// DATA "WIND",22,"EXAMI",23,"EXAMINE",23
 NEXT
FOR I = 1 TO NO;
// READ OB$[i];
DIM OB$[i]
DIMDATA OB$[] ,"RATS","TAPE","MACHINE","TERMINAL","COIN","CANDY","COMPUTER","BATS","DESK","MANUAL","CLOCK","ROAD","DIR","ADVEN","COPY","LOGOUT","NORTH","SOUTH","EAST","WEST","UP","DOWN"
// DATA "RATS","TAPE","MACHINE","TERMINAL","COIN","CANDY","COMPUTER","BATS","DESK","MANUAL","CLOCK","ROAD"
// DATA "DIR","ADVEN","COPY","LOGOUT","NORTH","SOUTH","EAST","WEST","UP","DOWN"
 NEXT
FOR I = 1 TO NT
// READ TD$[i],ItemLoc[i],ItemFlag[i]
DIM TD$[i]
DIMDATA TD$[] ,"HUNGRY RATS", "COMPUTER TAPE", "VENDING MACHINE", "BROKEN-DOWN TERMINAL", "COIN", "CANDY BAR", "COMPUTER","BATS","DESK","COMPUTER MANUAL","ELABORATE CLOCKWORK"
DIM ItemLoc[i]
DIMDATA ItemLoc[] ,4 ,5 ,6 ,8 ,-1 ,-1 ,10 ,13 ,14 ,-1 , 11
DIM ItemFlag[i]
DIMDATA ItemFlag[] ,0,1,0,1,1,1,1,0,0,1,0
// DATA "HUNGRY RATS",4,0,"COMPUTER TAPE",5,1,"VENDING MACHINE",6,0
// DATA "BROKEN-DOWN TERMINAL",8,1,"COIN",-1,1,"CANDY BAR",-1,1,"COMPUTER",10,1
// DATA "BATS",13,0,"DESK",14,0,"COMPUTER MANUAL",-1,1,"ELABORATE CLOCKWORK",11,0
 NEXT

DIM AC [14] [6]

 AC [0] [0] = 2
 AC [1] [0] = 3
 AC [11] [0] = 11
 AC [1] [1] = 1
 AC [2] [1] = 2
 AC [12] [1] = 12
 AC [3] [2] = 5
 AC [5] [2] = 7
 AC [6] [2] = 8
 AC [8] [2] = 10
 AC [11] [2] = 13
 AC [12] [2] = 14
 AC [4] [3] = 4
 AC [6] [3] = 6
 AC [7] [3] = 7
 AC [9] [3] = 9
 AC [12] [3] = 12
 AC [13] [3] = 13
 AC [1] [4] = 7
 AC [3] [4] = 3
 AC [6] [4] = 9
 AC [8] [4] = 12
 AC [2] [5] = 4
 AC [6] [5] = 2
 AC [8] [5] = 7
 AC [11] [5] = 9

// DATA 2,0,0,0,0,0
// DATA 3,1,0,0,7,0
// DATA 0,2,0,0,0,4
// DATA 0,0,5,0,3,0
// DATA 0,0,0,4,0,0
// DATA 0,0,7,0,0,0
// DATA 0,0,8,6,9,2
// DATA 0,0,0,7,0,0
// DATA 0,0,10,0,12,7
// DATA 0,0,0,9,0,0
// DATA 0,12,0,0,0,0
// DATA 11,0,13,0,0,9
// DATA 0,0,14,12,0,0
// DATA 0,0,0,13,0,0
// NEXT
// MAIN LOOP - Room Description
// MAIN was line 200
MAIN:
IF WD = 0 THEN GOTO MAINCOM
WD = 0
PRINT RM$[RM] ,100,100
SHOWSCREEN
K = 0
FOR I = 1 TO NT STEP 1
ItemLoc[i] = ItemLocF
IF ItemLocF > 1 THEN
GOTO MAIN2
IF ItemLocF < 1 THEN
GOTO MAIN2
IF K = 0 THEN
PRINT "You See:" ,100,100
SHOWSCREEN
K=1
PRINT TD$[i] ,100,100
SHOWSCREEN

// MAIN2 was line 270
MAIN2:
NEXT
PRINT "Exits are:" , 100,100
SHOWSCREEN
FOR I = 1 TO 6 STEP 1
// IF AC(RM,I)<>0 THEN PRINT VB$(I);"  ";
AC [RM] [i] = AccessF
IF AccessF <> 0 THEN
PRINT VB$[i] ,100,100
SHOWSCREEN
NEXT
// PRINT " " 100,100
// MAIN LOOP - command input and parser
// MAINCOM was line 400
MAINCOM:
INPUT C$ ,100,100
// L= LEN(C$); IF L=0 THEN MAINCOM
L = LEN (C$); IF L = 0  THEN GOTO MAINCOM
C1$=""; C2$="";C2=0;X=0
// FOR I = 1 TO L STEP 1
FOR I = 1 TO L STEP 1
A$ = MID$ (C$ ,I ,1 ); A=ASC(A$);IF A >= 97 AND A <= 122 THEN A$=CHR$(A-32)
IF A$<>" " THEN GOTO MAINCOM2
IF C2$<>"" THEN GOTO MAINCOM4
X=1
GOTO MAINCOM3
//MAINCOM2 was line 460
MAINCOM2:
IF X=0 THEN C1$=C1$+A$; GOTO MAINCOM3
C2$=C2$+A$
// MAINCOM3 was line 490
MAINCOM3:
NEXT
//MAINCOM4 was line 500
MAINCOM4:
IF C1$="" THEN PRINT "Excuse me?" ,100,100; GOTO MAINCOM
// C1$=LEFT$(C1$,5); C2$=LEFT$(C2$,5); Left$ not a function
C1$=MID$(C1$,0, C1); C2$=MID$(C2$,0, C2);
FOR C1 = 1 TO NV STEP 1
IF VB$[C1]=C1$ THEN C1=VN[C1]; GOTO MAINCOM5
NEXT
// Fix this line // PRINT "I don't know the verb " C1$; GOTO MAINCOM
PRINT "I don't know the verb " , 100,100;PRINT C1$ ,100,100; GOTO MAINCOM
//MAINCOM5 was line 600
MAINCOM5:
IF C2$="" THEN GOTO PREFIL
FOR C2=1 TO NO
IF OB$[C2]=C2$ THEN GOTO PREFIL
NEXT
IF C1=11 THEN C2=1; GOTO PREFIL

// NOOBJ was line 640
NOOBJECT:
// Fix this line //PRINT "I don't know the object"; C2$
PRINT "I don't know the object" ,100,100; PRINT C2$ ,100,100
SHOWSCREEN
GOTO MAINCOM5

// Prelimiary filtering of commands
// PREFIL was line 700
PREFIL:
IF C2 > (NT+5) AND C1 <> 7 AND C1 <> 11 THEN GOTO NOOBJECT
IF C2 > NT AND C2 < NT+5 THEN IF C1 <> 11 THEN GOTO COMPMESEG1
IF C2 > NT THEN GOTO PREFIL2
TLL=ItemLoc[C2]
IF C1 <> 11 AND TLL <> RM AND TLL <> 0 THEN PRINT "It isn't here.", 100,100;GOTO MAINCOM

// PREFIL2 was line 750
PREFIL2:
// IF C1=1 THEN GOTO DIRECT
// IF C1=2 THEN GOTO DIRECT
// IF C1=3 THEN GOTO DIRECT
// IF C1=4 THEN GOTO DIRECT
// IF C1=5 THEN GOTO DIRECT
// IF C1=6 THEN GOTO DIRECT
// IF C1=7 THEN GOTO GO
// IF C1=8 THEN GOTO EAT
// IF C1=9 THEN GOTO BOOT
// IF C1=10 THEN GOTO INSERT
// IF C1=11 THEN GOTO KEYIN
// IF C1=12 THEN GOTO TAKE
// IF C1=13 THEN GOTO DROP
// IF C1=14 THEN GOTO INVENTORY
// IF C1=15 THEN GOTO MOUNT
// IF C1=16 THEN GOTO PEER
// IF C1=17 THEN GOTO FIGHT
// IF C1=18 THEN GOTO START
// IF C1=19 THEN GOTO OPEN
// IF C1=20 THEN GOTO FIN
// IF C1 = 21 THEN GOTO LOOK
// IF C1 = 22 THEN GOTO WIND
// IF C1 = 23 THEN GOTO EXAMINE
SELECT C1
 CASE 1 TO 6
   GOTO DIRECT
 CASE 7
   GOTO GO
 CASE 8
   GOTO EAT
 CASE 9
  GOTO BOOT
 CASE 10
  GOTO INSERT
 CASE 11
  GOTO KEYIN
 CASE 12
  GOTO TAKE
 CASE 13
  GOTO DROP
 CASE 14
  GOTO INVENTORY
 CASE 15
  GOTO MOUNT
 CASE 16
  GOTO PEER
 CASE 17
  GOTO FIGHT
 CASE 18
  GOTO START
 CASE 19
  GOTO OPEN
 CASE 20
  GOTO FIN
 CASE 21
  GOTO LOOK
 CASE 22
  GOTO WIND
 CASE 23
  GOTO EXAMINE
ENDSELECT


// ON C1 GOTO DIRECT,DIRECT,DIRECT,DIRECT,DIRECT,DIRECT,GO,EAT,BOOT,INSERT
// ON C1-10 GOTO KEYIN,TAKE,DROP,INVENTORY,MOUNT,PEER,FLIGHT,START,OPEN,FIN
// ON C1-20 GOTO LOOK,WIND,EXAMINE

// Directions renamed Direct
// COMPASS was line 1000
DIRECT:
// IF AC[RM][C1]=0 THEN PRINT "You can't go that way.", 100,100;GOTO MAIN
ROOMARRAY = AC [RM] [C1]
IF ROOMARRAY = 0 THEN PRINT "You can't go that way.", 100,100;GOTO MAIN
IF RM=4 AND RatFight <> 0 AND C1=3 THEN PRINT "The rats look too fierce.",100,100;GOTO COMPROUTINE
RM=ROOMARRAY
WD=-1
GOTO COMPROUTINE

// Go
// GO was Line 1100
GO:
IF C2=0 THEN GOTO COMPMESEG5
IF C2 <= 16 THEN GOTO COMPMESEG4
C1 = (C2-16);GOTO DIRECT

// Eat
// EAT was Line 1200
EAT:
IF C2 <> 6 THEN GOTO COMPMESEG2
TLL=-1
 PRINT "It tastes stale." ,100,100; GOTO COMPROUTINE

// Kick
// BOOT was line 1300
BOOT:
IF C2=0 THEN GOTO COMPMESEG5
IF C2 <> 7 OR CD <> 0 THEN GOTO COMPMESEG2
IF CA <> 0 THEN
CT=9
GOTO COMPROUTINE

// Insert
// INSERT was line 1400
INSERT:
IF C2=0 THEN GOTO COMPMESEG5
IF C2<>5 THEN GOTO COMPMESEG1
IF RM<>6 THEN GOTO COMPMESEG3
ItemLoc[5]=-1
ItemLoc[6]=RM
PRINT "A Candy bar comes out.",100,100;GOTO COMPROUTINE

// Type
// KEYIN was line 1500
KEYIN:
IF C2 = 0 THEN GOTO COMPMESEG5
IF RM <> 10 THEN GOTO COMPMESEG3
IF CA = 0 THEN PRINT "The Computer isn't running.",100,100;GOTO COMPROUTINE
IF LI <> 0 THEN GOTO COMPLOGIN

// LOGIN was line 1600
COMPLOGIN:
IF CP = 0 THEN GOTO TAPEUNIT
IF C2 <= 12 THEN PRINT "'Invalid Command'",100,100;GOTO COMPROUTINE
IF C2 = 13 THEN PRINT "'Copy Logu Adven'",100,100;GOTO COMPROUTINE
IF C2 = 14 THEN PRINT "'Welcome to Adventure w#uld y#$*'" ,100,100;CT=9;GOTO COMPROUTINE
IF C2 = 5 THEN PRINT "'Mount Tape then type file name'" ,100,100;CP=-1;GOTO COMPROUTINE
PRINT "'logged out.'" ,100,100; LI =0 ;GOTO COMPROUTINE



// Take

// TAKE was line 1800
TAKE:
IF C2 = 0 THEN GOTO COMPMESEG5
IF ItemFlag[C2]=0 THEN
PRINT "That's beyond your ability.",100,100;GOTO COMPROUTINE
IF ItemLocF = 0 THEN
PRINT "you've already got it!",100,100;GOTO MAIN
IF C2=4 AND CF=0 THEN
PRINT "'There was a coin under it.'",100,100;
ItemLoc[5]=RM
CF=-1
IF C2=2 THEN MT=0
ItemLoc[C2]=0
GOTO COMPMESEG

// Drop
// DROP was Line 1900
DROP:
IF C2=0 THEN GOTO COMPMESEG5
IF ItemLocF <>0 THEN PRINT "You Don't have it.",100,100;GOTO MAIN
ItemLoc[C2]=RM
 IF RM <> 4 OR C2 <> 6 THEN GOTO COMPMESEG
PRINT "The rats devour the candy and get sleepy.",100,100
TD$[1]="SLEEPY RATS"
ItemLoc[6]=-1
RatFight=0
GOTO COMPMESEG

// Inventory
// INVENTORY was Line 2000
INVENTORY:
K=0;PRINT "You are carrying:",100,100
FOR I = 1 TO NT
IF ItemLoc[i]=0 THEN PRINT TD$[i], 200,200 ;K=1
NEXT
IF K=0 THEN PRINT "Nothing.",100,100
GOTO COMPROUTINE

// Mount
// MOUNT was Line 2100
MOUNT:
IF C2=0 THEN GOTO COMPMESEG5
IF C2<>2 THEN GOTO COMPMESEG1
IF RM<>10 OR MT<>0 THEN GOTO COMPMESEG2
ItemLoc[2]=RM
MT=-1
GOTO COMPMESEG

// Read
// PEER was Line 2200
PEER:
IF C2=0 THEN GOTO COMPMESEG5
IF C2=3 THEN PRINT "'Insert Coin'",100,100;GOTO COMPROUTINE
IF C2 <> 10 THEN PRINT "Nothing is written on it.",100,100;GOTO COMPROUTINE
PRINT "'...User ID is Road...'",100,100
PRINT "'Type DIR for list of commands...'",100,100
PRINT "The rest is illegible.",100,100;GOTO COMPROUTINE

// Fight
// FIGHT was line 2300
FIGHT:
PRINT "That won't work",100,100;GOTO COMPROUTINE

// Start
// START was Line 2400
START:
IF C2=0 THEN GOTO COMPMESEG5
IF C2=7 THEN GOTO COMPMESEG2
GOTO COMPMESEG1

// Open
// OPEN was LINE 2500
OPEN:
IF C2=0 THEN GOTO COMPMESEG5
IF C2<>9 THEN GOTO COMPMESEG1
IF MF <> 0 THEN PRINT "it Already is.",100,100;GOTO COMPROUTINE
PRINT "inside it is a manual.",100,100;ItemLoc[10]=RM;MF=-1;GOTO COMPROUTINE

// Look
// LOOK was Line 2600
LOOK:
IF C2 <> 0 THEN GOTO COMPMESEG4
WD=-1; GOTO COMPROUTINE

// Wind
// WIND was Line 2700
WIND:
IF C2 <> 11 THEN GOTO COMPMESEG1
IF BT=0 THEN PRINT "It's fully wound.",100,100;GOTO COMPROUTINE
PRINT "the clock chimes loudly and something flies past.",100,100
BT=0
ItemLoc[8]=-1
GOTO COMPROUTINE

// Examine
// EXAMINE was Line 2800
EXAMINE:
IF C2=3 OR C2=10 THEN PRINT "something is written there.",100,100;GOTO COMPROUTINE
IF C2=9 AND MF=0 THEN PRINT "it is closed.",100,100;GOTO COMPROUTINE
IF C2=4 THEN PRINT "it looks beyond repair.",100,100;GOTO COMPROUTINE
IF C2=7 THEN PRINT "this is an ancient Mainframe with a console.",100,100;GOTO COMPROUTINE
IF C2=11 THEN PRINT "there is a large handle for winding the clock.",100,100;GOTO COMPROUTINE
IF C2=2 AND MT<>0 THEN PRINT "it is mounted on the computer.",100,100;GOTO COMPROUTINE
PRINT "You see nothing special.",100,100;GOTO COMPROUTINE

// TAPEUNIT was Line 1700
TAPEUNIT:
CP=0;IF C2 <= 12 THEN PRINT "'No Such File.'", 100,100; GOTO COMPROUTINE
IF MT=0 THEN PRINT "'Error Tape not Mounted'" ,100,100; GOTO COMPROUTINE
PRINT "'The TAPE Spins...'",100,100;
FOR I = 1 TO 500 ;
NEXT
PRINT "'File Copied.'",100,100
IF C2=14 THEN PRINT "'Congratulations, You've done it!'",100,100; END
GOTO COMPROUTINE

// Completion Messages
// COMPMESEG was Line 8000
COMPMESEG:
PRINT "OK.",100,100;GOTO COMPROUTINE
// COMPMESEG1 was Line 8010
COMPMESEG1:
PRINT "That's Silly!",100,100;GOTO MAIN
// COMPMESEG2 was Line 8020
COMPMESEG2:
PRINT "Nothing Happens.",100,100;GOTO COMPROUTINE
// COMPMESEG3 was Line 8030
COMPMESEG3:
PRINT "You can't do that now.",100,100;GOTO COMPROUTINE
// COMPMESEG4 was Line 8040
COMPMESEG4:
PRINT "Who's your English Teacher?",100,100;GOTO MAIN
// COMPMESEG5 was Line 8050
COMPMESEG5:
PRINT "Please give an object.",100,100;GOTO MAIN
// Completion Routines
// COMROUTINE was Line 8200
COMPROUTINE:
IF CA=0 THEN GOTO COMPROUTINE2
CT=CT+1;IF CT < 10 THEN GOTO COMPROUTINE2
IF RM = 10 THEN PRINT "The Computer dies with a loud pop and puff of blue smoke.",100,100
CD=-1
CA=0
TD$[7]="Dead Computer"
// COMRUT2 was Line 8300
COMPROUTINE2:
IF RM=ItemLoc[8] THEN PRINT "A Hoard of Rats carries you out.",100,100;
RM=1
WD=-1
GOTO MAIN
// Moved Data from end of program into arrays
// FIN was Line 9999
FIN:
END
EDIT by Schranz0r:

Please use the codetag:


(code) some code (/code), just replace  ( ) with [ ] !!

Thx

Offline Schranz0r

  • Premium User :)
  • Administrator
  • Prof. Inline
  • *******
  • Posts: 5077
  • O Rly?
    • View Profile
Shortest bug ever?
« Reply #8 on: 2008-Jan-15 »
AHHHHHHHHH to many GOTO's AHHHHHHHHHHHH

I'm confused and hungry........hmmm i dont know, Spagetti ?

;)
I <3 DGArray's :D

PC:
AMD Ryzen 7 1700 @3.9GHz, 16GB HyperX Fury 3000MHz Ram, ASUS ROG GTX 1060 STRIX 6GB, Windows 10 Pro 64Bit, MSi Tomahawk B350 Mainboard

Offline Kitty Hello

  • code monkey
  • Administrator
  • Prof. Inline
  • *******
  • Posts: 10760
  • here on my island the sea says 'hello'
    • View Profile
    • http://www.glbasic.com
Shortest bug ever?
« Reply #9 on: 2008-Jan-15 »
You define RM$ as a GLOBAL. But you use it as an array.
You must define it as GLOBAL RM$[]
Maybe others as well.
Code: (glbasic) [Select]
GLOBAL RatFight, BatFight, AC[], FT, I, K, L, X, A, A$, NR, NT, NP, NV, NO, MT
GLOBAL RM, CT, CF, RT, CA, MF, CD, WD, LI,  CP, BT, VB$[], OB$[], RM$[], TD$[], VN[], TLL, ItemFlag[], ItemLoc[]
GLOBAL C1, C2, C3, C4, C$, C1$, C2$, ItemLocF, AccessF, ROOMARRAY
Then DIM AC[14][6] - no spaces between [] and [].
Code: (glbasic) [Select]
DIM AC[14][6]

 AC [0][0] = 2
 AC [1][0] = 3
 AC [11][0] = 11
 AC [1][1] = 1
 AC [2][1] = 2
 AC [12][1] = 12
 AC [3][2] = 5
 AC [5][2] = 7
 AC [6][2] = 8
 AC [8][2] = 10
 AC [11][2] = 13
 AC [12][2] = 14
 AC [4][3] = 4
 AC [6][3] = 6
 AC [7][3] = 7
 AC [9][3] = 9
 AC [12][3] = 12
 AC [13][3] = 13
 AC [1][4] = 7
 AC [3][4] = 3
 AC [6][4] = 9
 AC [8][4] = 12
 AC [2][5] = 4
 AC [6][5] = 2
 AC [8][5] = 7
 AC [11][5] = 9
Fixed code:
Code: (glbasic) [Select]
// --------------------------------- //
// Project: Tower of Mystery
// Start: Tuesday, November 06, 2007
// IDE Version: 5.062
// Upgraded to IDE Version: 5.129
//
// declare constants
//
// NR number of rooms
// NT number of things/items
// NP number of Pseudo-Objects (all other Objects)
// NO number of objects of all kinds
// NV number of verbs
//
// declare Flags
//
// CA Computer Active (in-game)
// CD Computer is Dead
// LI Character is logged into computer
// CP COPY of program is running on computer
// MF Computer Manual Found
// MT Tape mounted
// CF Coin Found
// WD Room description request flag
// RatFight  Rats are Trouble (was RT)
// BatFight Bats are trouble (was BT)
// CT Time since computer was started
//
// General Variables
//
// C$  Command input
// C1$ First word of command
// C2$ Second Word of command
// C1  Verb token
// C2 Object token
// RM Room currently occupied
//
// Arrays
//
// AC[NR][6] Access Array
// VB$[NV] Verb array
// OB$[NO] Object Array
// RM$[NR] Room description array
// TD$[NT] Item description array
// VN[NV]  Verb token array
// ItemLoc[NT]  Item Location Array (Initially was TL[nt])
// ItemFlag[NT]  Item Flag array (for can item be carried) )(Initially was TF[nt])
//
// Directions can be numeric or alpha
//
// 1 N  North
// 2 S  South
// 3 E  East
// 4 W  West
// 5 U  Up
// 6 D  Down
//
//
GLOBAL RatFight, BatFight, AC[], FT, I, K, L, X, A, A$, NR, NT, NP, NV, NO, MT
GLOBAL RM, CT, CF, RT, CA, MF, CD, WD, LI,  CP, BT, VB$[], OB$[], RM$[], TD$[], VN[], TLL, ItemFlag[], ItemLoc[]
GLOBAL C1, C2, C3, C4, C$, C1$, C2$, ItemLocF, AccessF, ROOMARRAY
NR=14
NT=11
NP=11
NV=29
NO=NT+NP
// DIM AC[NR-1][5]
// DIM VB$[NV]
// DIM OB$[NO]
// DIM RM$[NR]
// DIM TD$[NT]
// DIM VN[NV]
// DIM ItemLoc[NT]
// DIM ItemFlag[NT]
// Initialization of Variables
RM = 1
CT= 0
CF= 0
INTEGER (RatFight)
RatFight=-1
CA= 0
MF= 0
CD= 0
WD= -1
LI= 0
INTEGER (BatFight)
BatFight=-1
FOR I = 1 TO NR
DIM RM$[i]
DIMDATA RM$[], "You are in the front of an old factory with a Clock tower." ,"You are at the bottom of a stairwell." ,"You are at the top of the basement steps." ,"You are in a damp cellar." ,"You are in a storeroom." ,"You are in the cafeteria." ,"You are at a landing on the stairs." ,"Around you is a manufacturing area." ,"You are at a landing on the third floor." ,"You are in the Computer room." ,"You are inside the Clock Tower." ,"You are at the top of the stairs." ,"You are in a long corridor going east." ,"You are at the east end of the corridor."

NEXT
FOR I = 1 TO NV
// READ VB$[i],VN[i];
DIM VB$[i]
DIMDATA VB$[], "N","S","E","W","U","D","GO","EAT","KICK","INSERT","DEPOSIT","TYPE","TAKE","GET","DROP","THROW","INVENTORY","I","INV","MOUNT","READ","FIGHT","KILL","START","POWER","OPEN","QUIT","LOOK","WIND","EXAMI","EXAMINE"
DIM VN[i]
DIMDATA VN[], 1,2,3,4,5,6,7,8,9,10,10,11,12,12,13,13,14,14,14,15,16,17,17,18,18,19,20,21,22,23,23
// DATA N,1,S,2,E,3,W,4,U,5,D,6,"GO",7,"EAT",8,"KICK",9,"INSERT",10,"DEPOSIT",10,"TYPE",11
// DATA "TAKE",12,"GET",12,"DROP",13,"THROW",13,"INVENTORY",14,I,14,"INV",14,"MOUNT",15,"READ",16
// DATA "FIGHT",17,"KILL",17,"START",18,"POWER",18,"OPEN",19,"QUIT",20,"LOOK",21
// DATA "WIND",22,"EXAMI",23,"EXAMINE",23
 NEXT
FOR I = 1 TO NO;
// READ OB$[i];
DIM OB$[i]
DIMDATA OB$[] ,"RATS","TAPE","MACHINE","TERMINAL","COIN","CANDY","COMPUTER","BATS","DESK","MANUAL","CLOCK","ROAD","DIR","ADVEN","COPY","LOGOUT","NORTH","SOUTH","EAST","WEST","UP","DOWN"
// DATA "RATS","TAPE","MACHINE","TERMINAL","COIN","CANDY","COMPUTER","BATS","DESK","MANUAL","CLOCK","ROAD"
// DATA "DIR","ADVEN","COPY","LOGOUT","NORTH","SOUTH","EAST","WEST","UP","DOWN"
 NEXT
FOR I = 1 TO NT
// READ TD$[i],ItemLoc[i],ItemFlag[i]
DIM TD$[i]
DIMDATA TD$[] ,"HUNGRY RATS", "COMPUTER TAPE", "VENDING MACHINE", "BROKEN-DOWN TERMINAL", "COIN", "CANDY BAR", "COMPUTER","BATS","DESK","COMPUTER MANUAL","ELABORATE CLOCKWORK"
DIM ItemLoc[i]
DIMDATA ItemLoc[] ,4 ,5 ,6 ,8 ,-1 ,-1 ,10 ,13 ,14 ,-1 , 11
DIM ItemFlag[i]
DIMDATA ItemFlag[] ,0,1,0,1,1,1,1,0,0,1,0
// DATA "HUNGRY RATS",4,0,"COMPUTER TAPE",5,1,"VENDING MACHINE",6,0
// DATA "BROKEN-DOWN TERMINAL",8,1,"COIN",-1,1,"CANDY BAR",-1,1,"COMPUTER",10,1
// DATA "BATS",13,0,"DESK",14,0,"COMPUTER MANUAL",-1,1,"ELABORATE CLOCKWORK",11,0
 NEXT

DIM AC[14][6]

 AC [0][0] = 2
 AC [1][0] = 3
 AC [11][0] = 11
 AC [1][1] = 1
 AC [2][1] = 2
 AC [12][1] = 12
 AC [3][2] = 5
 AC [5][2] = 7
 AC [6][2] = 8
 AC [8][2] = 10
 AC [11][2] = 13
 AC [12][2] = 14
 AC [4][3] = 4
 AC [6][3] = 6
 AC [7][3] = 7
 AC [9][3] = 9
 AC [12][3] = 12
 AC [13][3] = 13
 AC [1][4] = 7
 AC [3][4] = 3
 AC [6][4] = 9
 AC [8][4] = 12
 AC [2][5] = 4
 AC [6][5] = 2
 AC [8][5] = 7
 AC [11][5] = 9

// DATA 2,0,0,0,0,0
// DATA 3,1,0,0,7,0
// DATA 0,2,0,0,0,4
// DATA 0,0,5,0,3,0
// DATA 0,0,0,4,0,0
// DATA 0,0,7,0,0,0
// DATA 0,0,8,6,9,2
// DATA 0,0,0,7,0,0
// DATA 0,0,10,0,12,7
// DATA 0,0,0,9,0,0
// DATA 0,12,0,0,0,0
// DATA 11,0,13,0,0,9
// DATA 0,0,14,12,0,0
// DATA 0,0,0,13,0,0
// NEXT
// MAIN LOOP - Room Description
// MAIN was line 200
MAIN:
IF WD = 0 THEN GOTO MAINCOM
WD = 0
PRINT RM$[RM] ,100,100
SHOWSCREEN
K = 0
FOR I = 1 TO NT STEP 1
ItemLoc[i] = ItemLocF
IF ItemLocF > 1 THEN
GOTO MAIN2
IF ItemLocF < 1 THEN
GOTO MAIN2
IF K = 0 THEN
PRINT "You See:" ,100,100
SHOWSCREEN
K=1
PRINT TD$[i] ,100,100
SHOWSCREEN

// MAIN2 was line 270
MAIN2:
NEXT
PRINT "Exits are:" , 100,100
SHOWSCREEN
FOR I = 1 TO 6 STEP 1
// IF AC(RM,I)<>0 THEN PRINT VB$(I);"  ";
AC [RM][i] = AccessF
IF AccessF <> 0 THEN
PRINT VB$[i] ,100,100
SHOWSCREEN
NEXT
// PRINT " " 100,100
// MAIN LOOP - command input and parser
// MAINCOM was line 400
MAINCOM:
INPUT C$ ,100,100
// L= LEN(C$); IF L=0 THEN MAINCOM
L = LEN (C$); IF L = 0  THEN GOTO MAINCOM
C1$=""; C2$="";C2=0;X=0
// FOR I = 1 TO L STEP 1
FOR I = 1 TO L STEP 1
A$ = MID$ (C$ ,I ,1 ); A=ASC(A$);IF A >= 97 AND A <= 122 THEN A$=CHR$(A-32)
IF A$<>" " THEN GOTO MAINCOM2
IF C2$<>"" THEN GOTO MAINCOM4
X=1
GOTO MAINCOM3
//MAINCOM2 was line 460
MAINCOM2:
IF X=0 THEN C1$=C1$+A$; GOTO MAINCOM3
C2$=C2$+A$
// MAINCOM3 was line 490
MAINCOM3:
NEXT
//MAINCOM4 was line 500
MAINCOM4:
IF C1$="" THEN PRINT "Excuse me?" ,100,100; GOTO MAINCOM
// C1$=LEFT$(C1$,5); C2$=LEFT$(C2$,5); Left$ not a function
C1$=MID$(C1$,0, C1); C2$=MID$(C2$,0, C2);
FOR C1 = 1 TO NV STEP 1
IF VB$[C1]=C1$ THEN C1=VN[C1]; GOTO MAINCOM5
NEXT
// Fix this line // PRINT "I don't know the verb " C1$; GOTO MAINCOM
PRINT "I don't know the verb " , 100,100;PRINT C1$ ,100,100; GOTO MAINCOM
//MAINCOM5 was line 600
MAINCOM5:
IF C2$="" THEN GOTO PREFIL
FOR C2=1 TO NO
IF OB$[C2]=C2$ THEN GOTO PREFIL
NEXT
IF C1=11 THEN C2=1; GOTO PREFIL

// NOOBJ was line 640
NOOBJECT:
// Fix this line //PRINT "I don't know the object"; C2$
PRINT "I don't know the object" ,100,100; PRINT C2$ ,100,100
SHOWSCREEN
GOTO MAINCOM5

// Prelimiary filtering of commands
// PREFIL was line 700
PREFIL:
IF C2 > (NT+5) AND C1 <> 7 AND C1 <> 11 THEN GOTO NOOBJECT
IF C2 > NT AND C2 < NT+5 THEN IF C1 <> 11 THEN GOTO COMPMESEG1
IF C2 > NT THEN GOTO PREFIL2
TLL=ItemLoc[C2]
IF C1 <> 11 AND TLL <> RM AND TLL <> 0 THEN PRINT "It isn't here.", 100,100;GOTO MAINCOM

// PREFIL2 was line 750
PREFIL2:
// IF C1=1 THEN GOTO DIRECT
// IF C1=2 THEN GOTO DIRECT
// IF C1=3 THEN GOTO DIRECT
// IF C1=4 THEN GOTO DIRECT
// IF C1=5 THEN GOTO DIRECT
// IF C1=6 THEN GOTO DIRECT
// IF C1=7 THEN GOTO GO
// IF C1=8 THEN GOTO EAT
// IF C1=9 THEN GOTO BOOT
// IF C1=10 THEN GOTO INSERT
// IF C1=11 THEN GOTO KEYIN
// IF C1=12 THEN GOTO TAKE
// IF C1=13 THEN GOTO DROP
// IF C1=14 THEN GOTO INVENTORY
// IF C1=15 THEN GOTO MOUNT
// IF C1=16 THEN GOTO PEER
// IF C1=17 THEN GOTO FIGHT
// IF C1=18 THEN GOTO START
// IF C1=19 THEN GOTO OPEN
// IF C1=20 THEN GOTO FIN
// IF C1 = 21 THEN GOTO LOOK
// IF C1 = 22 THEN GOTO WIND
// IF C1 = 23 THEN GOTO EXAMINE
SELECT C1
 CASE 1 TO 6
   GOTO DIRECT
 CASE 7
   GOTO GO
 CASE 8
   GOTO EAT
 CASE 9
  GOTO BOOT
 CASE 10
  GOTO INSERT
 CASE 11
  GOTO KEYIN
 CASE 12
  GOTO TAKE
 CASE 13
  GOTO DROP
 CASE 14
  GOTO INVENTORY
 CASE 15
  GOTO MOUNT
 CASE 16
  GOTO PEER
 CASE 17
  GOTO FIGHT
 CASE 18
  GOTO START
 CASE 19
  GOTO OPEN
 CASE 20
  GOTO FIN
 CASE 21
  GOTO LOOK
 CASE 22
  GOTO WIND
 CASE 23
  GOTO EXAMINE
ENDSELECT


// ON C1 GOTO DIRECT,DIRECT,DIRECT,DIRECT,DIRECT,DIRECT,GO,EAT,BOOT,INSERT
// ON C1-10 GOTO KEYIN,TAKE,DROP,INVENTORY,MOUNT,PEER,FLIGHT,START,OPEN,FIN
// ON C1-20 GOTO LOOK,WIND,EXAMINE

// Directions renamed Direct
// COMPASS was line 1000
DIRECT:
// IF AC[RM][C1]=0 THEN PRINT "You can't go that way.", 100,100;GOTO MAIN
ROOMARRAY = AC [RM][C1]
IF ROOMARRAY = 0 THEN PRINT "You can't go that way.", 100,100;GOTO MAIN
IF RM=4 AND RatFight <> 0 AND C1=3 THEN PRINT "The rats look too fierce.",100,100;GOTO COMPROUTINE
RM=ROOMARRAY
WD=-1
GOTO COMPROUTINE

// Go
// GO was Line 1100
GO:
IF C2=0 THEN GOTO COMPMESEG5
IF C2 <= 16 THEN GOTO COMPMESEG4
C1 = (C2-16);GOTO DIRECT

// Eat
// EAT was Line 1200
EAT:
IF C2 <> 6 THEN GOTO COMPMESEG2
TLL=-1
 PRINT "It tastes stale." ,100,100; GOTO COMPROUTINE

// Kick
// BOOT was line 1300
BOOT:
IF C2=0 THEN GOTO COMPMESEG5
IF C2 <> 7 OR CD <> 0 THEN GOTO COMPMESEG2
IF CA <> 0 THEN
CT=9
GOTO COMPROUTINE

// Insert
// INSERT was line 1400
INSERT:
IF C2=0 THEN GOTO COMPMESEG5
IF C2<>5 THEN GOTO COMPMESEG1
IF RM<>6 THEN GOTO COMPMESEG3
ItemLoc[5]=-1
ItemLoc[6]=RM
PRINT "A Candy bar comes out.",100,100;GOTO COMPROUTINE

// Type
// KEYIN was line 1500
KEYIN:
IF C2 = 0 THEN GOTO COMPMESEG5
IF RM <> 10 THEN GOTO COMPMESEG3
IF CA = 0 THEN PRINT "The Computer isn't running.",100,100;GOTO COMPROUTINE
IF LI <> 0 THEN GOTO COMPLOGIN

// LOGIN was line 1600
COMPLOGIN:
IF CP = 0 THEN GOTO TAPEUNIT
IF C2 <= 12 THEN PRINT "'Invalid Command'",100,100;GOTO COMPROUTINE
IF C2 = 13 THEN PRINT "'Copy Logu Adven'",100,100;GOTO COMPROUTINE
IF C2 = 14 THEN PRINT "'Welcome to Adventure w#uld y#$*'" ,100,100;CT=9;GOTO COMPROUTINE
IF C2 = 5 THEN PRINT "'Mount Tape then type file name'" ,100,100;CP=-1;GOTO COMPROUTINE
PRINT "'logged out.'" ,100,100; LI =0 ;GOTO COMPROUTINE



// Take

// TAKE was line 1800
TAKE:
IF C2 = 0 THEN GOTO COMPMESEG5
IF ItemFlag[C2]=0 THEN
PRINT "That's beyond your ability.",100,100;GOTO COMPROUTINE
IF ItemLocF = 0 THEN
PRINT "you've already got it!",100,100;GOTO MAIN
IF C2=4 AND CF=0 THEN
PRINT "'There was a coin under it.'",100,100;
ItemLoc[5]=RM
CF=-1
IF C2=2 THEN MT=0
ItemLoc[C2]=0
GOTO COMPMESEG

// Drop
// DROP was Line 1900
DROP:
IF C2=0 THEN GOTO COMPMESEG5
IF ItemLocF <>0 THEN PRINT "You Don't have it.",100,100;GOTO MAIN
ItemLoc[C2]=RM
 IF RM <> 4 OR C2 <> 6 THEN GOTO COMPMESEG
PRINT "The rats devour the candy and get sleepy.",100,100
TD$[1]="SLEEPY RATS"
ItemLoc[6]=-1
RatFight=0
GOTO COMPMESEG

// Inventory
// INVENTORY was Line 2000
INVENTORY:
K=0;PRINT "You are carrying:",100,100
FOR I = 1 TO NT
IF ItemLoc[i]=0 THEN PRINT TD$[i], 200,200 ;K=1
NEXT
IF K=0 THEN PRINT "Nothing.",100,100
GOTO COMPROUTINE

// Mount
// MOUNT was Line 2100
MOUNT:
IF C2=0 THEN GOTO COMPMESEG5
IF C2<>2 THEN GOTO COMPMESEG1
IF RM<>10 OR MT<>0 THEN GOTO COMPMESEG2
ItemLoc[2]=RM
MT=-1
GOTO COMPMESEG

// Read
// PEER was Line 2200
PEER:
IF C2=0 THEN GOTO COMPMESEG5
IF C2=3 THEN PRINT "'Insert Coin'",100,100;GOTO COMPROUTINE
IF C2 <> 10 THEN PRINT "Nothing is written on it.",100,100;GOTO COMPROUTINE
PRINT "'...User ID is Road...'",100,100
PRINT "'Type DIR for list of commands...'",100,100
PRINT "The rest is illegible.",100,100;GOTO COMPROUTINE

// Fight
// FIGHT was line 2300
FIGHT:
PRINT "That won't work",100,100;GOTO COMPROUTINE

// Start
// START was Line 2400
START:
IF C2=0 THEN GOTO COMPMESEG5
IF C2=7 THEN GOTO COMPMESEG2
GOTO COMPMESEG1

// Open
// OPEN was LINE 2500
OPEN:
IF C2=0 THEN GOTO COMPMESEG5
IF C2<>9 THEN GOTO COMPMESEG1
IF MF <> 0 THEN PRINT "it Already is.",100,100;GOTO COMPROUTINE
PRINT "inside it is a manual.",100,100;ItemLoc[10]=RM;MF=-1;GOTO COMPROUTINE

// Look
// LOOK was Line 2600
LOOK:
IF C2 <> 0 THEN GOTO COMPMESEG4
WD=-1; GOTO COMPROUTINE

// Wind
// WIND was Line 2700
WIND:
IF C2 <> 11 THEN GOTO COMPMESEG1
IF BT=0 THEN PRINT "It's fully wound.",100,100;GOTO COMPROUTINE
PRINT "the clock chimes loudly and something flies past.",100,100
BT=0
ItemLoc[8]=-1
GOTO COMPROUTINE

// Examine
// EXAMINE was Line 2800
EXAMINE:
IF C2=3 OR C2=10 THEN PRINT "something is written there.",100,100;GOTO COMPROUTINE
IF C2=9 AND MF=0 THEN PRINT "it is closed.",100,100;GOTO COMPROUTINE
IF C2=4 THEN PRINT "it looks beyond repair.",100,100;GOTO COMPROUTINE
IF C2=7 THEN PRINT "this is an ancient Mainframe with a console.",100,100;GOTO COMPROUTINE
IF C2=11 THEN PRINT "there is a large handle for winding the clock.",100,100;GOTO COMPROUTINE
IF C2=2 AND MT<>0 THEN PRINT "it is mounted on the computer.",100,100;GOTO COMPROUTINE
PRINT "You see nothing special.",100,100;GOTO COMPROUTINE

// TAPEUNIT was Line 1700
TAPEUNIT:
CP=0;IF C2 <= 12 THEN PRINT "'No Such File.'", 100,100; GOTO COMPROUTINE
IF MT=0 THEN PRINT "'Error Tape not Mounted'" ,100,100; GOTO COMPROUTINE
PRINT "'The TAPE Spins...'",100,100;
FOR I = 1 TO 500 ;
NEXT
PRINT "'File Copied.'",100,100
IF C2=14 THEN PRINT "'Congratulations, You've done it!'",100,100; END
GOTO COMPROUTINE

// Completion Messages
// COMPMESEG was Line 8000
COMPMESEG:
PRINT "OK.",100,100;GOTO COMPROUTINE
// COMPMESEG1 was Line 8010
COMPMESEG1:
PRINT "That's Silly!",100,100;GOTO MAIN
// COMPMESEG2 was Line 8020
COMPMESEG2:
PRINT "Nothing Happens.",100,100;GOTO COMPROUTINE
// COMPMESEG3 was Line 8030
COMPMESEG3:
PRINT "You can't do that now.",100,100;GOTO COMPROUTINE
// COMPMESEG4 was Line 8040
COMPMESEG4:
PRINT "Who's your English Teacher?",100,100;GOTO MAIN
// COMPMESEG5 was Line 8050
COMPMESEG5:
PRINT "Please give an object.",100,100;GOTO MAIN
// Completion Routines
// COMROUTINE was Line 8200
COMPROUTINE:
IF CA=0 THEN GOTO COMPROUTINE2
CT=CT+1;IF CT < 10 THEN GOTO COMPROUTINE2
IF RM = 10 THEN PRINT "The Computer dies with a loud pop and puff of blue smoke.",100,100
CD=-1
CA=0
TD$[7]="Dead Computer"
// COMRUT2 was Line 8300
COMPROUTINE2:
IF RM=ItemLoc[8] THEN PRINT "A Hoard of Rats carries you out.",100,100;
RM=1
WD=-1
GOTO MAIN
// Moved Data from end of program into arrays
// FIN was Line 9999
FIN:
END
Phew ;)

Offline shaf

  • Mc. Print
  • *
  • Posts: 18
    • View Profile
Shortest bug ever?
« Reply #10 on: 2008-Jan-20 »
Silly me, I thought that I had declared all globals.

Yes it's Spagetti code., an attempt to replace an old Basic Program written in 1983 to run in GLbasic.
it's mor of a proof if concept before cleaning up the code and making it more modular.
My idea is to create a simple text adventure game for younger gamers that can be easily modified.

I appreciate all the help.

Shaf

Offline Kitty Hello

  • code monkey
  • Administrator
  • Prof. Inline
  • *******
  • Posts: 10760
  • here on my island the sea says 'hello'
    • View Profile
    • http://www.glbasic.com
Shortest bug ever?
« Reply #11 on: 2008-Jan-22 »
A "good" progammer can produce FORTRAN code in any language ;)