Recent

Author Topic: How to use an embedded resource as a text file  (Read 846 times)

CyberFilth

  • Jr. Member
  • **
  • Posts: 88
    • My github account
How to use an embedded resource as a text file
« on: September 23, 2021, 12:20:17 pm »
I have a small program that loads a text file and outputs a scrambled version, using a 'pseudo-Markov chain' text generator. There's a GUI version at https://github.com/cyberfilth/travesty
Now I'd like to take that code and use it in a game that I'm writing. The idea being that it can produce scrambled text for fragments of scrolls, books, etc.

I've got a text only version working at https://github.com/cyberfilth/Travesty-CLI but for the finished version I don't want to distribute it with a source text file. I'd like to add the text file as a resource in Lazarus and then load it into the subprogram when needed.

Adding it as a resource and then loading it into a string is easy using Lazarus, I just don't know the syntax for loading the resource as a text file and parsing it with the above program.
Running Windows 10 & Xubuntu 20.04 | Lazarus 2.0.12 | FPC 3.2.0

PascalDragon

  • Hero Member
  • *****
  • Posts: 5444
  • Compiler Developer
Re: How to use an embedded resource as a text file
« Reply #1 on: September 23, 2021, 01:33:18 pm »
Look at the example I did for another thread.

CyberFilth

  • Jr. Member
  • **
  • Posts: 88
    • My github account
Re: How to use an embedded resource as a text file
« Reply #2 on: September 23, 2021, 04:50:41 pm »
Thanks, that put me on the right track.
Running Windows 10 & Xubuntu 20.04 | Lazarus 2.0.12 | FPC 3.2.0

 

TinyPortal © 2005-2018