Seite 1 von 1

Space() mit 8Bit

Verfasst: 27.02.2025 11:15
von PIC18F2550
Hallo,
wie kann ich Space() dazu bewegen das mein sBuffer in ASCII Code (8Bit) gerüllt wird?

Code: Alles auswählen

sBuffer = Space(#BlockSize)
Danke.

Re: Space() mit 8Bit

Verfasst: 27.02.2025 12:11
von mk-soft
Mit String Funktionen überhaupt nicht, da PureBasic Strings ab Version 5.x Unicode (16Bit) ist

Code: Alles auswählen

;-TOP

Structure ArrayOfAscii
  a.a[0]
EndStructure

*text = Ascii("Hello World!")

*buffer.ArrayOfAscii = AllocateMemory(101) ; One byte more for Null Terminated
FillMemory(*buffer, 100, ' ', #PB_Ascii)
CopyMemory(*text, *buffer + 10, MemorySize(*text) - 1); Copy without Null Terminat

Debug "[" + PeekS(*buffer, 40, #PB_Ascii) + "]"
For i = 0 To 100
  Debug "Index: " + i +": Dec =" + *buffer\a[i] + " AscII = [" + PeekS(*buffer + i, 1, #PB_Ascii) + "]"
Next

FreeMemory(*text)
FreeMemory(*Buffer)

Re: Space() mit 8Bit

Verfasst: 27.02.2025 15:30
von PIC18F2550
Danke.