Include non-images in the executable

Just starting out? Need help? Post your questions and find answers here.
User avatar
marcoagpinto
Addict
Addict
Posts: 940
Joined: Sun Mar 10, 2013 3:01 pm
Location: Portugal
Contact:

Include non-images in the executable

Post by marcoagpinto »

Hello!

Is there a way of compiling and have files get built-in into the executable?

I am thinking about .txt files and others.

For example:
x3d/header.txt
x3d/footer.txt

To create x3d files, I open both files above and append them at the start and end of my data, but it would be great if I could store them in the executable.

Is it possible?

Thanks!
DontTalkToMe
Enthusiast
Enthusiast
Posts: 334
Joined: Mon Feb 04, 2013 5:28 pm

Re: Include non-images in the executable

Post by DontTalkToMe »

:?:

Where is the problem with the fact it's not an image ?

You can do it the same way: IncludeBinary "name.txt"

Then you Peek* or CopyMemory() from the right memory address using a label and read back.
User avatar
marcoagpinto
Addict
Addict
Posts: 940
Joined: Sun Mar 10, 2013 3:01 pm
Location: Portugal
Contact:

Re: Include non-images in the executable

Post by marcoagpinto »

DontTalkToMe wrote::?:

Where is the problem with the fact it's not an image ?

You can do it the same way: IncludeBinary "name.txt"

Then you Peek* or CopyMemory() from the right memory address using a label and read back.
Buaaaaaaaaaa... I was looking at the PB help and it doesn't explain how to convert to string an included UTF-8 text file :oops:

It just refers the INCLUDE command but no examples.
Bitblazer
Enthusiast
Enthusiast
Posts: 733
Joined: Mon Apr 10, 2017 6:17 pm
Location: Germany
Contact:

Re: Include non-images in the executable

Post by Bitblazer »

This is what i do for arbitrary binary data.

Code: Select all

DataSection
  SomeBinaryData:
    IncludeBinary "somedata.bin"
  SomeBinaryDataEnd:
    Data.l 0
EndDataSection

  ; to get the size of the data

  Size.i    = ?SomeBinaryDataEnd - ?SomeBinaryData
For Text, you could just use Peeks(?SomeBinaryData).
webpage - discord chat links -> purebasic GPT4All
ccode
User
User
Posts: 99
Joined: Sat Jun 23, 2018 5:21 pm

Re: Include non-images in the executable

Post by ccode »

Hello:

Code: Select all

Restore Txt

l.i = MemoryStringLength(?Txt, #PB_UTF8)
Debug l
Debug PeekS(?Txt, l, #PB_UTF8)

DataSection
  Txt:
  IncludeBinary "ReadMeUTF8"
EndDataSection


;Create a File: "ReadMeUTF8"

;Example-Text:

; Ich bin eine UTF-Text-Datei.
; I am a UTF text file.
; Je suis un fichier texte UTF.
; Ek is 'n UTF-tekslêer.
; Jeg er en UTF-tekstfil.
; 我是一个UTF文本文件。
; Mi estas UTF-dosiero-dosiero.
; Is comhad téacs UTF mé.
; Jestem plikiem tekstowym UTF.
; Jsem textový soubor UTF.
; 私はUTFテキストファイルです。
; Είμαι ένα αρχείο κειμένου UTF.
; Я текстовый файл UTF.
; Ik ben een UTF-tekstbestand.
; Ben bir UTF metin dosyasıyım.
; Ik bin in UTF-teksttriem.

User avatar
marcoagpinto
Addict
Addict
Posts: 940
Joined: Sun Mar 10, 2013 3:01 pm
Location: Portugal
Contact:

Re: Include non-images in the executable

Post by marcoagpinto »

Thanks, my friends!
User avatar
minimy
Enthusiast
Enthusiast
Posts: 344
Joined: Mon Jul 08, 2013 8:43 pm

Re: Include non-images in the executable

Post by minimy »

; Ich bin eine UTF-Text-Datei.
; I am a UTF text file.
; Je suis un fichier texte UTF.
; Ek is 'n UTF-tekslêer.
; Jeg er en UTF-tekstfil.
; 我是一个UTF文本文件。
; Mi estas UTF-dosiero-dosiero.
; Is comhad téacs UTF mé.
; Jestem plikiem tekstowym UTF.
; Jsem textový soubor UTF.
; 私はUTFテキストファイルです。
; Είμαι ένα αρχείο κειμένου UTF.
; Я текстовый файл UTF.
; Ik ben een UTF-tekstbestand.
; Ben bir UTF metin dosyasıyım.
; Ik bin in UTF-teksttriem.

; Yo soy un archivo UTF

Little spanish please.. :)
If translation=Error: reply="Sorry, Im Spanish": Endif
Post Reply