Chr(0) = nothing? So I have a problem.

Just starting out? Need help? Post your questions and find answers here.
Marcos.exe
Posts: 3
Joined: Mon Nov 08, 2021 2:39 pm

Chr(0) = nothing? So I have a problem.

Post by Marcos.exe »

Hi!
I need to create a file that writes a string.
Would be:

WriteString(#file, Chr(0)+Chr(0)+Chr(0)+Chr(6))

When the file is opened, the result is just "♠"
building in another language, I get " ♠"
But I need to build for the web, and I'm trying to do it in SB.
In PureBasic the result is the same.
I tried to save the file with various encoding types, but nothing.
Does anyone know how to do this?
plouf
Posts: 124
Joined: Tue Feb 25, 2014 6:01 pm
Location: Athens,Greece

Re: Chr(0) = nothing? So I have a problem.

Post by plouf »

using POKEB

Code: Select all

  Procedure Callback(Status, Filename$, File, SizeRead)
    Select Status
      Case #PB_Status_Saved
        ; File correctly saved
        
      Case #PB_Status_Error
        ; File saving has failed
    EndSelect
  EndProcedure

CreateFile(0, "dataFile.hex", @Callback()) 

*Buffer = AllocateMemory(4)
PokeB(*Buffer,0,0)
PokeB(*Buffer,1,0)
PokeB(*Buffer,2,0)
PokeB(*Buffer,3,6)

WriteData(0,*Buffer,0,4)

ExportFile(0, "text/plain")
Christos
Marcos.exe
Posts: 3
Joined: Mon Nov 08, 2021 2:39 pm

Re: Chr(0) = nothing? So I have a problem.

Post by Marcos.exe »

It works perfectly! A problem eliminated.
Thank you very much for the solution and speed!
Post Reply