Include syntax..?

Blitz3D Forums/Blitz3D Programming/Include syntax..?

Include was never ment to load data. You may however write your own Include function that does the job, something like:

function MyInclude#(filename$)
if filetype(filename$)<>1 then return 0 ; error, file not found
re=readfile(filename$)
value#=readfloat(re)
closefile re
return value
end function

you may then simply use it like this:

character#=MyInclude#("character.xyz")

(using floats in this example). you need to write the value to the file like this:

wr=writefile(filename$)
writefloat wr, somevalue#
closefile wr

you may however use WriteLine or ReadLine instead, blitz will automaticly convert it to the required variable type.

If you want to access multiple values in one file then you can use the SEEK command (if the exact postion is known), or as you said, string-compare (maybe use descriptors, eg:
WIDTH=1.34
HEIGHT=4.77
)

Personally I prevere to write data line by line (writeline), using description strings for each parameter, then load them into an String Array (DIM) and comfortly parse the array using FOR loops.