Data and Variables

Blitz3D Forums/Blitz3D Beginners Area/Data and Variables

OwlEpicurus(Posted 2009) [#1]
Have you ever tried putting a variable in a data section? Something along these lines:

.someLabel
Data test,0,0,0,0


I was curious to see if you could do something like. Apparently not, but it does not cause the program to crash immediately. Instead it prompts the user to open a .bb file, and then crashes afterwards.

Has anyone else noticed this? Why does this happen?


Warner(Posted 2009) [#2]
Data fields are stored in the executable. That is why they should be constant. Basically, you can't use variables as a Data field. You could however, use a String:
Data "test", 0, 0, 1, 0

For i = 1 To 5
   Read d$
   Select d$
   Case "test"
       val = test
   Default
       val = d$
   End Select
   Print "value:" + d$
Next



OwlEpicurus(Posted 2009) [#3]
That answers part of the question, but why would it want to open a .bb file?


Floyd(Posted 2009) [#4]
but why would it want to open a .bb file?

This sort of thing has been known in various forms for years. If a Data statement is malformed then a file requester may pop up. Nobody knows why.


OwlEpicurus(Posted 2009) [#5]
Thanks. I'm relatively new to programming, so I hadn't heard about that before.


big10p(Posted 2009) [#6]
Yarp. Old bug.