I'm a big fan of embedding data in DataSections in order to avoid shipping a bunch of files around. I currently do this for sounds and JSON, with CatchSound and CatchJSON. However, now I want to store a plane text file inside my app. I can do it just fine like I always do, with two labels in a DataSection with an IncludeBinary nested between them, but I can't figure out how to read it. I've tried PeekS(?Label, ?EndLabel - ?Label) as well as Restore Label Read.s MyValue$, but both produce weird binary output and aren't what I want. Is this possible?
Thanks.
Storing text files inside executables
Re: Storing text files inside executables
No code no help.
Hint:
Have you used #PB_UTF8 flag inside of PeekS()?
Or is the text file really in unicode?
Hint:
Have you used #PB_UTF8 flag inside of PeekS()?
Or is the text file really in unicode?
Re: Storing text files inside executables
Code: Select all
DataSection
Start:
IncludeBinary #PB_Compiler_Home + "Examples\Sources\Date.pb"
Stop:
EndDataSection
Debug PeekS(?Start, ?Stop - ?Start, #PB_UTF8|#PB_ByteLength)
Last edited by infratec on Wed Dec 11, 2024 7:51 am, edited 1 time in total.
Re: Storing text files inside executables
Yup, you got it. It was the missing #PB_UTF8 flag.infratec wrote: Tue Dec 10, 2024 9:48 pmCode: Select all
DataSection Start: IncludeBinary #PB_Compiler_Home + "Examples\Sources\Date.pb" Stop: EndDataSection Debug PeekS(?Start, ?Stop - ?Start, #PB_UTF8)
Re: Storing text files inside executables
Don't forget #PB_ByteLength
{Home}.:|:.{Dialog Design0R}.:|:.{Codes}.:|:.{History Viewer Online}.:|:.{Send a Beer}
Re: Storing text files inside executables
You are right.
Corrected my example above.
And you have also to check for a BOM.
Corrected my example above.
And you have also to check for a BOM.
Re: Storing text files inside executables
Work without len ...
Code: Select all
DataSection
Start:
IncludeBinary #PB_Compiler_Home + "Examples\Sources\Date.pb"
Data.w 0 ; End
EndDataSection
Debug PeekS(?Start, -1, #PB_UTF8)
My Projects ThreadToGUI / OOP-BaseClass / EventDesigner V3
PB v3.30 / v5.75 - OS Mac Mini OSX 10.xx - VM Window Pro / Linux Ubuntu
Downloads on my Webspace / OneDrive
PB v3.30 / v5.75 - OS Mac Mini OSX 10.xx - VM Window Pro / Linux Ubuntu
Downloads on my Webspace / OneDrive

