PEEK CONSOLE Function Windows
Returns the current character/attribute pair stored at a specified location on the console screen.
Syntax: PEEK([#pagenum,] address)
A% = PEEK(2000) '-- Peek location 2000 on current page
A% = PEEK(1, 2000) '-- Peek location 2000 on page 1
Details:
To understand how to compute the address, use this handy function:
Char$ = CHR$(PEEK((Row%-1)*160+(Col%-1)*2))
Attr = PEEK((Row%-1)*160+(Col%-1)*2+1)
As you may notice, all the even memory addresses contain the character,
and all the odd numbered addresses contain the attribute. The attribute
contains information about the foreground and background color.
ForeGround% = Attr AND &HF
BackGround% = Attr SHR 4
Why all the trouble? This is implemented for compatibility with QBasic.
The only difference is that you don't use DEF SEG under Rapid-Q, and PEEK
only works at the console level.
POKE CONSOLE Statement Windows
Writes a byte to the console page.
Syntax: POKE [#pagenum,] address, byte
POKE 2000, ASC("A") '-- Pokes an "A" character at location 2000
POKE 2001, 95 '-- Pokes attribute 95 to location 2000
POKE 1, 2001, 95 '-- Same as above but pokes to page 1
Details:
To understand how to compute the address, use this handy function:
ChAddress = (Row%-1)*160+(Col%-1)*2
AttrAddress = (Row%-1)*160+(Col%-1)*2+1
As you may notice, all the even memory addresses contain the character,
and all the odd numbered addresses contain the attribute. The attribute
contains information about the foreground and background color.
To calculate the attribute, try this:
Attr = (BackGround% SHL 4) OR ForeGround%
Why all the trouble? This is implemented for compatibility with QBasic.
The only difference is that you don't use DEF SEG under Rapid-Q, and POKE
only works at the console level.
POS CONSOLE Function Windows/Unix
Returns the current horizontal (column) position of the cursor.
Syntax: POS(0)
Column% = POS(0)
Details:
Please note that I did not make this function up (ie. its weird syntax), it's implemented for
compatibility with QBasic.
PRINT CONSOLE Statement Windows/Unix
PRINT outputs data to the screen (or standard output).
Syntax: PRINT [#pagenum,][expressions][{;|,}]
PRINT "Number: "; 45
PRINT A$
PRINT #1, "This prints to screen page 1"
Details:
Expressions can be any string, number, or function. You can optionally
use ; or , to print out more expressions. Under QBasic, PRINT can format your data
if you use the comma, however, under Rapid-Q the comma and semi-colon have the same effect.
Again, under Windows, PRINT is implemented as a CONSOLE function. Under Linux/Unix you do not need
to compile as CONSOLE.
SCREEN CONSOLE Function Windows
Returns the ASCII character or attribute at (row, col) on the current console screen.
Syntax: SCREEN(row, col [, colorflag])
A% = SCREEN(1, 1) '-- Get character located on the first row and column
A% = SCREEN(5, 3, 1) '-- Get attribute of character located at (5,3)
Details:
The SCREEN function is very similar to the PEEK function, except that it's much easier to use.
If you supply the function with a colorflag parameter, the function returns the attribute (ie. color), otherwise
it returns the ASCII character.
The SCREEN function only works on the current console screen and not on any hidden pages.
SETCONSOLETITLE CONSOLE Statement Windows
SetConsoleTitle is implemented as a WinAPI call to SetConsoleTitle but is called as a statement
rather than a function (ie. no return value). If you would like a return value, you'll have to
call the API function directly.
Syntax: SETCONSOLETITLE string-expression
SETCONSOLETITLE "Hello World!"
SLEEP CONSOLE Statement Windows/Unix
Suspends execution of the application for a specified amount of time.
Syntax: SLEEP seconds
SLEEP .5 '-- Delay for half a second
Details:
SLEEP requires a parameter, unlike QBasic. SLEEP waits until the number of
seconds specified has elasped. You cannot break out of it by pressing a
key (unlike QBasic). Under Windows, SLEEP is implemented as a console function.
Under Linux/Unix, you do not need to compile as CONSOLE.