What are you using brackets for?

by (Login burger2227)
R

If you say an array, then you are on to something. DIM the array at the start of the program. The number specifies how many values it can hold.

DIM A(100)

100 X = X + 1 'I bet there is a GOTO 100 somewhere or you'll never be back :-)
110 A(X) = 0 'sets index number X to zero
120 IF X < 100 THEN GOTO 100 'will GOTO 100, 100 times

First, you don't need line numbers in QB unless you are using GOTO to move around. Do yourself a favor and try to do things with loops instead.
GOTO will cripple your programming abilities!

Z1 = 100
X = 1
A = Z(X)

In your second example, Z1 has NOTHING to do with the Z array as far as Qbasic is concerned. You MUST reference an index inside of the brackets.

Z(1) = 100
X = 1
A = Z(X)

PRINT A 'displays 100

Ted


Posted on Dec 20, 2010, 7:21 PM

Respond to this message   

Return to Index