reading files

Blitz3D Forums/Blitz3D Beginners Area/reading files

The forum is locked. These are the original blitzbasic.com forums, kept so they can still be read. No new topics, replies or edits can be made here. To join in, head over to the Blitz3D+ forums.

Goober,
you read the info you need from the file, assuming that the file contains the values - strings, integers, bytes - in the right order.

The info you read, you want to be displayed at each main loop, right ?

The problem in your code, is that you print the text just before the main loop, and then, in the main loop is cleared from the UpdateWorld command, because this command clears the screen too.

So you should:
- before the main loop, read the data from the file, as you already do, and close the file
- in your main loop, where you write "3D Wiever", you should also print out the data you need:

.
updateworld
renderworld
text 320,0,"3D Wiever"

Write "Name = " 
Print Name 
Write "extension = " 
Print extension 
Write "other = " 
Print other 

flip


Note that the print command slows down the loop, so I would strongly suggest to use Text instead.

More, make a function that prints (using the text command !) the info out, so you would have a more readable main loop, instead of a loads of statements:

;main loop
updateworld
renderworld
print_info()
flip


Bare in mind that if you make a function and call it from the main loop, then the variable that you use (name, extension, others...) should be declared Global.

Hope this has sense for you,
Sergio.