【问题标题】:Redim'd array error in commodore 64 basic?commodore 64 basic中的Redim'd数组错误?
【发布时间】:2014-03-24 02:46:26
【问题描述】:

在我的 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

【问题讨论】:

    标签: arrays multidimensional-array basic commodore


    【解决方案1】:

    您需要在子例程之前使用end 语句。为了确保您不会干扰其他任何事情,例如:

    1099 end
    

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

    【讨论】:

      【解决方案2】:

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

      【讨论】:

      • 这只是一个评论?
      【解决方案3】:

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

      200 if r1 < 50 then gosub 1510
      

      【讨论】:

        猜你喜欢
        • 2016-11-19
        • 2011-04-24
        • 1970-01-01
        • 1970-01-01
        • 2015-10-30
        • 1970-01-01
        • 2020-11-05
        • 2014-04-26
        • 2014-05-08
        相关资源
        最近更新 更多