Concerning Configuration Files.

Blitz3D Forums/Blitz3D Beginners Area/Concerning Configuration Files.

WERDNA(Posted 2009) [#1]
Hey everyone,

I have a question concerning configuration files!


Sometimes with programs, I've noticed that they include a text
file usually called something or other, .config
By opening the text file and modifying some of the numbers,
you can change how the program works.

How can I do this in Blitz?

I've tried making a program where the code goes like this,

;Start of Code
Include "Main Code File.bb"
;End Of Code

And then I put "Main Code File" in the same folder and create a
.exe


What this SHOULD do, is make it so you can modify "Main Code File"
and still be able to run the .exe with the newly modified code.
But it doesn't work :(

Whenever I run the .exe it just runs my program how it WAS, not
how it IS after modifying "Main Code File"



Why is this, and how can I fix it?

Do I need to use some kind of .dat file?


Thanks if anyone can answer this,

WERDNA


Gabriel(Posted 2009) [#2]
I have no idea what you think these configuration files are doing, but they're not doing it. It almost seems as if you think a compiled exe is dynamically recompiling itself according to some arbitrary file you have laying around.

Config files are just text files. You read them with ReadLine and ReadFile and you write them with WriteLine and WriteFile. What effect they have on the program is entirely up to you, which is to say you have to write the code to read them and do something based on what it reads in your game before you compile the exe. Once you've made an exe, you're not changing it, and Blitz3D is a compiled language, not interpreted, so nothing in any .BB source file is going to be understood automatically at that stage.


WERDNA(Posted 2009) [#3]
Ohhhhhhhhhhhhhh.

Guess I'm still a noob with Blitz, lol

Thanks for the help Gariel ^_^


I appreciate it greatly.


Drak(Posted 2009) [#4]
Werdna, what those config files do is what you program it to do. You can read any information from any text file using the read commands. It doesn't actually manipulate the code, what they are doing is getting variables FROM the config file.


Warner(Posted 2009) [#5]
Here is an example, it reads a file called "config.txt", if it exists.
You should first create a file "config.txt" and save it in the same folder as this program.
"config.txt" should be this:
width=1024
height=768
depth=0
mode=2

And this is the example:



WERDNA(Posted 2009) [#6]
OH!

I get it now.


Thanks for the example Warner, and thanks everyone else for your
help as well!

WERDNA