Results 1 to 6 of 6

Thread: data statements in old console programs

  1. #1

    data statements in old console programs

    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

  2. #2
    thinBasic MVPs kryton9's Avatar
    Join Date
    Nov 2006
    Location
    Naples, Florida & Duluth, Georgia
    Age
    67
    Posts
    3,869
    Rep Power
    404

    Re: data statements in old console programs

    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.

    Acer Notebook: Win 10 Home 64 Bit, Core i7-4702MQ @ 2.2Ghz, 12 GB RAM, nVidia GTX 760M and Intel HD 4600
    Raspberry Pi 3: Raspbian OS use for Home Samba Server and Test HTTP Server

  3. #3

    Re: data statements in old console programs


    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

  4. #4
    thinBasic MVPs kryton9's Avatar
    Join Date
    Nov 2006
    Location
    Naples, Florida & Duluth, Georgia
    Age
    67
    Posts
    3,869
    Rep Power
    404

    Re: data statements in old console programs

    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/
    Acer Notebook: Win 10 Home 64 Bit, Core i7-4702MQ @ 2.2Ghz, 12 GB RAM, nVidia GTX 760M and Intel HD 4600
    Raspberry Pi 3: Raspbian OS use for Home Samba Server and Test HTTP Server

  5. #5

    Re: data statements in old console programs

    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.
    http://tab.thinbasic.com - Home Of The ThinBasic Adventure Builder Project. (Interactive Fiction/Text Adventure Maker)

  6. #6

    Re: data statements in old console programs

    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

Similar Threads

  1. Wrong descripton of come CONSOLE statements
    By Petr Schreiber in forum Fixed or cleared errors in help material
    Replies: 1
    Last Post: 24-09-2005, 21:38

Members who have read this thread: 1

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •