Read from .txt?

Blitz3D Forums/Blitz3D Beginners Area/Read from .txt?

Sph!nx(Posted 2009) [#1]
Hello everybody!

I've read about the create file and readfile commands, but what I want is something different.

Is there a way to have blitz read small .txt files and use it in its actions?

The text files would be small code snippets written in Blitz code language.

I would like to set things up, so I can edit small parts of the code (the snippets) and then test it without having to recompile my app.


Thanks a lot!


Sph!nx(Posted 2009) [#2]
I thought Include would work, but then it compiles it with the app.


(Sorry for the double post)


Nate the Great(Posted 2009) [#3]
unless you plan on making a compiler then the answer is you cant


Ginger Tea(Posted 2009) [#4]
blitz compiles where as what you want would be interpreted
you can parse text to set paramaters, like config files, character sheets and levels, but not blitz basic commands


Sph!nx(Posted 2009) [#5]
Ok, thanks you both!


grindalf(Posted 2009) [#6]
you could set up a system where you parse the text and then pass it into a command

for instance
1:dude:0:0:5

then you parse the string to get the four variables in this case 1 would be your command then the following 3 would be your variables
so once parsed it would run like this

if command=1 then
moveentity var1$,var2$,var3$,var4$
end if

i think you can run it with string$ instead of variables but if not it would be easy enough to convert them first

this just wouldent be super fast because every command would be parsed as its read, but it should work,(i think)


Adam Novagen(Posted 2009) [#7]
Unless of course someone were to make a kind of mini-Blitz, a Blitz-within-Blitz that has its own realtime compiler built into the program... Which would make for some pretty nifty plugin support... HMM... >:)


Ross C(Posted 2009) [#8]
Isn't this what Blitz Virtual Machine does?

http://www.blitzbasic.com/toolbox/toolbox.php?tool=43


Adam Novagen(Posted 2009) [#9]
Probably, but the link's broken.


Warner(Posted 2009) [#10]
Try GameScript, it is very user friendly.
http://www.blitzbasic.com/Community/posts.php?topic=69531


jfk EO-11110(Posted 2009) [#11]
BVM may still be available directly from shareit, if they host the fullversion file:
https://secure.shareit.com/shareit/product.html?productid=186252

Too bad Koriolis' server vanished :.(


DheDarkhCustard(Posted 2009) [#12]
I made a level editor for a game once, and it saved the level data as a binary file, you could do the same with a text file. The easiest way (not the more effective) is to save a text file like this:

variable 1
54
variable 2
555
character name
John
mobile number
45345345435345

and then you'd read the file, ignoring every second line by reading it and not using the variable:

null=readline(file)
var1=readline(file)
null=readline(file)
var2=readline(file)
null=readline(file)
charname=readline(file)

etc.