Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
An equipment screen for my RPG game
#7
Yes, I modified ReDim to try it out.
An array created with ReDim is automatically declared as a dynamic array. So far so good. Now when I comment out Data I get an error saying "Read..." and I don't know why. Why is it “Out of Data” now?

The part with the for loop is clear, but the top part is not clear to me.
I'm afraid I'll have to create a corresponding program to understand what's going on.  Sad

Code: (Select All)

Screen _NewImage(800, 600, 32)
ReDim num(1000) As Integer

Do
  Read num(count)
  Print num
  If num(count) <> -1 Then count = count + 1 Else Exit Do
Loop

ReDim _Preserve num(count) As Integer

Print "There were "; count;
Print "numbers counted and stored in our array (with end of data marker of -1)"
Print "They were:"
Print "(Index)", "(Value)"

For i = 0 To UBound(num)
  Print i, num(i)
Next
End

'Data 1,2,3,4,5,6,7,8,9,-1

[Image: Out-Of-Data2024-03-26-194516.jpg]
Reply


Messages In This Thread
An equipment screen for my RPG game - by Delsus - 03-26-2024, 09:41 AM
RE: An equipment screen for my RPG game - by Kernelpanic - 03-26-2024, 06:47 PM



Users browsing this thread: 4 Guest(s)