Embedded text file as a "Resource"
Posted: Thu Dec 01, 2016 3:14 am
I'm a noob from a coddled DBPro background who would like to know if i can embed a simple text file in my PB executable as readable data instead of making 30,000 data statements or going to compiler resourcing (yet). This would be a large text file with chr(13) chr(10) lines of varying length that will be used to populate a list structure. I need to be able to read in each line so that I can subsequently parse, and populate the list.
I've looked at many relevant posts but the examples usually center on embedding images or reading a few strings. If I attempt the oft- suggested IncludeBinary, I am not presently able to read line by line. If I use IncludeFile, PB treats it as code and of course fails.
Here is some flawed example code. Any and all suggestions are appreciated, even if "just use compiler resourcing" or totally different approaches. I could pad the file strings to a standard width if it helps. The parsing will not be a problem, I just need to be able to extract Unicode text per line.
The text file I want to embed, "textfile.txt":
And a test block:
Thanks for looking!
I've looked at many relevant posts but the examples usually center on embedding images or reading a few strings. If I attempt the oft- suggested IncludeBinary, I am not presently able to read line by line. If I use IncludeFile, PB treats it as code and of course fails.
Here is some flawed example code. Any and all suggestions are appreciated, even if "just use compiler resourcing" or totally different approaches. I could pad the file strings to a standard width if it helps. The parsing will not be a problem, I just need to be able to extract Unicode text per line.
The text file I want to embed, "textfile.txt":
Code: Select all
hey
Pure Basic
is
amazing
and wonderful to know,
don't
you think?Code: Select all
For Index = 0 To ?DataEnd - ?DataStart
Debug Hex(PeekA(?DataStart + Index))
Next Index
DataSection
DataStart:
IncludeBinary "textfile.txt"
DataEnd:
EndDataSection