Incbin Question

BlitzMax Forums/BlitzMax Beginners Area/Incbin Question

klepto2(Posted 2005) [#1]
Well, I've searched the forum alot, but the didn't find the answer.

In my Project I have a lot (about 2000) of small text files with only readable data and I want to include them to my EXE because it should not be accessible to everyone. Here are my questions :

a) Can I include normal text files like at the beginning of my code:
Pseudocode:
dir = Readdir("c:\abcdef\")
Repeat

file$ = Nextfile(dir)
Incbin file$

Forever

b) if a) = yes then is it possible to use the same functions as for normal files:
ie: While not EOF("incbin::abcdef.txt") or
f_open = Readfile("incbin::abcdef.txt") or
n$ = Readline(f_open)

Thx


FlameDuck(Posted 2005) [#2]
a) Can I include normal text files like at the beginning of my code:
No. Includes must all be able to resolve to absolute values at compile time. But you can write a small program that generates the .bmx source code you can include.

Although maybe you can use wildcards, and/or make a feature request for an IncBinDir command. :o>

b) if a) = yes then is it possible to use the same functions as for normal files:
This is actually possible, since loading can be done at runtime.


klepto2(Posted 2005) [#3]
Thx, I've just tried it and have also found out that it doesn't work this way. Now i will to try a codegenerator.

Again thx for the fast answer.


ImaginaryHuman(Posted 2005) [#4]
Or you could just cut and paste and then modify the numbers a bit, if all the filenames are similar.


klepto2(Posted 2005) [#5]
Thx AngelDaniel but cut and paste more than 2000 files and rename them is too much work without a code generator.

This code gen is ready, but now i have to find something to check if the incbin file exist. I have tried it with filetype but that haven't work.
And yes, the pathes works correctly, because the prog prints it correctly. but the prog also returns 0 everytime i call
filetype.

Any Ideas?


klepto2(Posted 2005) [#6]
I have now written my own little function to get if an IncBin file exist or not : (maybe it will help)

Function inc_filetype:Byte(incfile$)
if not Readfile(incfile$) then
Return False
else
Return True
endif
Endfunction

I know it is not much but it works.


FlameDuck(Posted 2005) [#7]
You forgot to close the file ... and you should be able to use FileType.

But why not just traverse the directory and include all files ending in .txt?


klepto2(Posted 2005) [#8]
It seems that it doesn't need to close the file.
And it is a project for with more people who are writing the source files.
Filetype definetly works not on my computer with Incbin files.

but my code works good.