PDA

View Full Version : data statements in old console programs



sandyrepope
14-06-2008, 01:07
In trying to convert some old qbasic programs there is something called data statements. These are simply data that can be read into variables when the program is run.

Why was it done this way?
Was there an advantage to this way?

Since thinbasic doesn't have this ability, what alternatives are there to handle this? Which would be best?

Thanks
Sandy

kryton9
14-06-2008, 02:00
Sandy, it is funny you mention this as Petr and I discussed this earlier in the week as I asked a similar question.

We can do the same thing in thinBasic in 2 ways.

Use an array.

So instead of:

10 DATA 1,2,3,4,5,6,7,8,9
20 FOR I=1 TO 9
30 READ A(I):NEXT I

We could have:
Dim A() as Long
ARRAY ASSIGN A(1) = 1,2,3,4,5,6,7,8,9

You can also use a string variable, but that makes it a bit more complicated.
I think the array above works pretty nicely to translate from the old Data statement and Read.

sandyrepope
15-06-2008, 01:38
I've tried just writing out the assignments of the data like this example:


D$(1) = "AN ENTRANCE CAVE LEADING TO THE NORTH.A NOTE ON THE WALL SAYS 'BRING YOUR TREASURES HERE'"
I(1) = 0
N(1) = 2
S(1) = 0
E(1) = 0
W(1) = 0
D$(2) = "A RECTANGLE SHAPED ROOM."
I(2) = 1
I$(2,1) = "THERE IS A GLOWING GLASS PYRAMID HERE."
N(2) = 17
S(2) = 1
E(2) = 3
W(2) = 0

But this is a lot of work. It takes hours just to type it in.

After thinking about it further I'm wondering if it might be a better idea to just put the data in data files. For example, I could put room descriptions in a room file, object descriptions in their own file and the map data in its own file. Then all the script would have to do is read the files. I'm just not sure how good this idea is and would appreciate comments and thoughts about it.

Thanks
Sandy

kryton9
15-06-2008, 01:44
If you are working on a text adventure, you should check out catventure's program. It is made for playing and creating just such games.
http://tab.thinbasic.com/

catventure
15-06-2008, 12:17
sandyrepope wrote:



For example, I could put room descriptions in a room file, object descriptions in their own file and the map data in its own file. Then all the script would have to do is read the files. I'm just not sure how good this idea is and would appreciate comments and thoughts about it.


Hi Sandy,
That old text adventure looks familiar :)
Is it a Scott Adams one?

Yes this is how I did it too. Lots of arrays holding adventure data - eg. rooms, objects, characters, messages and other data and then saving into a file.
You also have to decide how you will present your game - console or window.
I used window with richedit control to present the game.

Anyways you can check out the source code if it can be of help
http://tab.thinbasic.com/TABSource.zip

Best wishes,
catventure.

sandyrepope
15-06-2008, 15:33
catventure


That old text adventure looks familiar
Is it a Scott Adams one?

No, it is 'the endless tomb' by anthony wood.


Anyways you can check out the source code if it can be of help
http://tab.thinbasic.com/TABSource.zip

Thank you. I'll take a look at it.

One of my reasons for doing projects like this is to learn more about programming and, also, to encourage others to get involved in using ThinBassic. One of the things I'd like to do is write tutorials about using the console but to do that I'll have to, first, learn how to use it myself. Second, I'll have to learn how to write tutorials. I'm working on that. So much to do and so little time to do it!

Thanks
Sandy