Console_Write
<< Click to Display Table of Contents >> Navigation: ThinBASIC Modules > Console > Console_Write |
Description
Write text to the console screen.
Syntax
Console_Write(sText [, sText2 [, ...]] [In lColor] [At x, y] ) [( ... ) [(...)])
Returns
Return a number
If the function succeeds, the return value is nonzero and is the number of bytes written.
If the function fails, the return value is zero.
Parameters
Name |
Type |
Optional |
Meaning |
sText |
String |
No |
The text to print |
lColor |
Number |
Yes |
If present, text attribute will be changed before writing text. See standard console color equates |
x |
Number |
Yes |
If present, cursor location will be moved to x before writing text |
y |
Number |
Yes |
If present, cursor location will be moved to y before writing text |
Remarks
Text is written from the current cursor position and with the current attribute.
Optional lColor and optional cursor position are temporary and changed only for the execution of the function:
•before start writing text, current color and cursor position are saved
•text writing takes place
•previous color and old position are restored
Parenthesis are optional.
Multiple blocks of text/color/position can be indicated into a single command just putting them into a () pairs
Restrictions
Alias
See also
Console Module, Console_Read, Console_WriteLine, StdIn
Examples
Uses "Console"
'---Bright cyan text on a blue background
Long cBrightCyanBGBlue = %CONSOLE_FOREGROUND_BLUE | %CONSOLE_FOREGROUND_GREEN | %CONSOLE_FOREGROUND_INTENSITY | %CONSOLE_BACKGROUND_BLUE
Long cBrightRed = %CONSOLE_FOREGROUND_RED | %CONSOLE_FOREGROUND_INTENSITY
Long lCount
Long lColor1, lColor2
lColor1 = cBrightCyanBGBlue
lColor2 = cBrightRed
For lCount = 1 To 30
'---Changing of color and cursor position will effect only current Printl
Print lCount, "Hi there" In lColor1 At 25 + lCount, lCount
Print lCount, "Hi there" In lColor2 At 25 + lCount, 31 - lCount
'---Firing other Printl are not effected from previous color and curso position
PrintL lCount, "Hi there"
Swap lColor1, lColor2
Next
WaitKey