The ability to work with data buffers is still there, for input and output. Memory buffers can contain
any data you want, including Byte data and Ascii characters.
Code: Select all
Structure AsciiArr : a.a[0] : EndStructure
Length = 1024
*Buffer.Ascii = AllocateMemory(Length)
*pointer.AsciiArr = *buffer
If *pointer
*pointer\a[0] = 'A'
*pointer\a[1] = 'B'
*pointer\a[2] = 'C'
Debug PeekS(*pointer, -1, #PB_Ascii)
PokeS(*pointer, "Hello World", -1, #PB_Ascii)
For i = 0 To 12
Debug " Dec: " + *pointer\a[i] +
" Hex: " + Hex( *pointer\a[i] ) +
" Chr: " + Chr( *pointer\a[i] )
Next
EndIf
CompilerIf 0
;--------------------------------------------------------------------------------------------------------------
; Data functions ; String functions
;--------------------------------------------------------------------------------------------------------------
; ;
; ;
; Serial Port ;
; ;
WriteSerialPortData(#SerialPort, *Buffer, Length) ; WriteSerialPortString(#SerialPort, String$ [, Format])
ReadSerialPortData (#SerialPort, *Buffer, Length) ;
;--------------------------------------------------------------------------------------------------------------
; ;
; ;
; Process ;
; ;
WriteProgramData(Program, *Buffer, Length) ; PB 5.2x: WriteProgramString (Program, String$) -- optional [, Format] missing (use data functions)
; WriteProgramStringN(Program, String$) -- optional [, Format] missing (use data functions)
; PB 5.3+: WriteProgramString (Program, String$ [, Flags])
; WriteProgramStringN(Program, String$ [, Flags])
;
ReadProgramData (Program, *Buffer, Length) ; PB 5.2x: ReadProgramString(Program) -- optional [, Format] missing (use data functions)
; PB 5.3+: ReadProgramString(Program [, Flags])
;--------------------------------------------------------------------------------------------------------------
; ;
; Network ;
; ;
SendNetworkData (Connection, *Buffer, Length) ; SendNetworkString(Connection, String$ [, Format])
ReceiveNetworkData(Connection, *Buffer, Length) ;
;--------------------------------------------------------------------------------------------------------------
; ;
; File ;
; ;
WriteData(#File, *Buffer, Length) ; WriteString (#File, Text$ [, Format])
; WriteStringN(#File, Text$ [, Format])
ReadData (#File, *Buffer, Length) ; ReadString (#File [, Flags [, Length]])
;--------------------------------------------------------------------------------------------------------------
; ;
; Console ;
; ;
WriteConsoleData(*Buffer, Length) ; Print (Text$) -- optional [, Format] missing (use data functions)
; PrintN(Text$) -- optional [, Format] missing (use data functions)
ReadConsoleData (*Buffer, Length) ; String$ = Input() -- optional [, Format] missing (use data functions)
;--------------------------------------------------------------------------------------------------------------
CompilerEndIf