Code: Select all
Macro PrintConsoleAscii(Text)
*Ptr.Character = @Text
While *Ptr\c
WriteConsoleData(*Ptr,1)
*Ptr + SizeOf(Character)
Wend
EndMacro
; test code
OpenConsole()
TestText$="Test String"
PrintConsoleAscii(TestText$)
Input()
Code: Select all
Macro PrintConsoleAscii(Text)
*Ptr.Character = @Text
While *Ptr\c
WriteConsoleData(*Ptr,1)
*Ptr + SizeOf(Character)
Wend
EndMacro
; test code
OpenConsole()
TestText$="Test String"
PrintConsoleAscii(TestText$)
Input()
Code: Select all
; Program: TestStringToConsole.pb
;
; Purpose:
; Writes string to Console in Unicode and "Ascii" formats
;
; Notes:
; 1) Create Unicode executable
; 2) Set executable format to "Console"
; 3) Create executable "TestStringToConsole.exe"
; 4) Made with Purebasic v5.31 Windows x86
;
; Usage:
; 1) Open Console Window
; 2) type: TestStringToConsole > test.txt
;
; Macro to write only lower byte of Unicode character to console
Macro PrintConsoleAscii(Text)
*Ptr.Character = @Text
While *Ptr\c
WriteConsoleData(*Ptr,1)
*Ptr + SizeOf(Character)
Wend
EndMacro
OpenConsole()
TestString.s="Test String to Console"
; write unicode string to console
PrintN("Unicode string:")
PrintN(TestString)
; write lower byte of unicode character only to console
OutText.s="Ascii string:"+#CRLF$
PrintConsoleAscii(OutText)
PrintConsoleAscii(TestString)
CloseConsole()
End
Code: Select all
U n i c o d e s t r i n g :
T e s t S t r i n g t o C o n s o l e
Ascii string:
Test String to Console