在商品64基本版中的Redim'd数组错误?

时间:2014-03-24 02:46:26

标签: arrays multidimensional-array basic commodore

我的商品64基础项目中出现了redim'd数组错误

然而,我并没有重新设计我的二维数组,也不会多次查看代码行!

错误在第1140行

任何人都可以帮助我吗?

谢谢!

代码:

10 print "start"
20 rem: go to line 1100 in order to fill board with "."s because this is
30 rem: the board's initialization
40 gosub 1100
50 rem: looping from i to x allows for horizontal aspect of board to be printed
60 rem: x represents the width dimension of board, in this case, 8
70 for i = 1 to x
80 rem: looping from j to x allows for vertical aspect of board to be printed
90 rem: x represents the height dimension of board, in this case, 8
100 for j = 1 to x
110 rem: board initialized with "."s is printed
120 print b3$(i,j), 
130 rem: end of first for loop, looping from i to x put on 130; , USED 4 TAB
140 next
150 print
160 rem: end of second for loop, looping from j to x
170 next
180 rem: checks what at the random number is equal to; places word vertically
190 rem: if rand is < 50 and places the word horizontally if rand is > 50
200 if r1 < 50 then gosub 1510
210 if r1 > 50 then print "no"

1000 rem: random num generator generates a random integer
1050 rem: between 0 and 100
1040 rem: values between 0 and 100, inclusive
1050 r1 = int(100*rnd(1))+1


1060 rem: Subroutine Fill 
1070 rem: Purpose: read and data construct which fills b3$(x,x) with
1080 rem: either "."s or other random words depending on whether or not
1090 rem: the subroutine has been run before.
1100 x = 8
1110 rem: x represents the dimension for the board; in this case,8
1120 rem: took out 
1130 rem: array b3 = board = specifications for width and height (8)
1140 dim b3$(x, x)
rem: i to x allows the horizontal aspect of board to be filled with "."s
1150 for i = 0 to x 
1160 rem: j to x allows the vertical aspect of board to be filled with "."s
1170 for j = 0 to x
1180 rem: board filled with dots horizontally and vertically
1190 b3$(i, j) = "."
1200 rem: end of first nested for loop
1210 next
1220 rem: end of second nested for loop
1230 next
1240 return

3 个答案:

答案 0 :(得分:5)

在子程序之前需要end语句。为了确保你不干涉其他任何事情,例如:

1099 end

否则,您的程序“完成”,然后再次运行所有子程序代码,只是为了好玩。

答案 1 :(得分:0)

这是因为1140行之后的行rem: i to x allows the horizontal aspect of board to be filled with "."s没有任何数字。要解决此问题,您可以删除该行或在之前输入数字1145(例如)。

答案 2 :(得分:0)

第200行看起来很可疑,因为第1510行不存在。

200 if r1 < 50 then gosub 1510