Repository navigation
Cls
Home › Console Functions › Cls
Clears the screen, or only the text or graphics viewport.
Declare Sub Cls ( ByVal mode As Long = 1 )mode
An optional mode parameter may be given,
If omitted, Cls clears either the text or graphics viewport. If a graphics viewport has been defined using the View (Graphics) statement, the graphics viewport is cleared. Otherwise, the text viewport, defined by View Print, is cleared. (If there is no explicit text viewport defined, the entire screen is cleared.)
If 0, clears the entire screen
If 1, clears the graphics viewport if defined. Otherwise, clears the text viewport
If 2, clears the text viewport
Cls mode
- None
'' set the color to light grey text on a blue background
Color 7, 1
'' clear the screen to the background color
Cls
'' print text in the center of the screen
Locate 12, 33
Print "Hello Universe!"In graphics modes, if you want to clear the entire screen to color 0, it can be faster using Clear to write zeroes to the screen memory than calling Cls.
Dim scrbuf As Byte Ptr, scrsize As Integer
Dim As Long scrhei, scrpitch
Dim As Integer r = 0, dr = 1
ScreenRes 640, 480, 8
scrbuf = ScreenPtr: Assert( scrbuf <> 0 )
ScreenInfo( , scrhei, , , scrpitch )
scrsize = scrpitch * scrhei
Do
'' lock the screen (must do this while working directly on screenbuffer)
ScreenLock
'' clear the screen (could use Cls here):
Clear *scrbuf, 0, scrsize
'' draw circle
Circle (320, 240), r
ScreenUnlock
'' grow/shrink circle radius
r += dr
If r <= 0 Then dr = 1 Else If r >= 100 Then dr = -1
'' short pause in each frame (prevents hogging the CPU)
Sleep 1, 1
'' run loop until user presses a key
Loop Until Len(Inkey) > 0Category: Console Functions
Kind: sub
Reproduced from the FreeBASIC Wiki Manual under the GNU Free Documentation License 1.3 — with no Invariant Sections, no Front-Cover Texts and no Back-Cover Texts. Copyright © the FreeBASIC project and wiki contributors. See License.
tiko-lang · Home · Feature Index · Keyword Index · License
FreeBASIC manual pages reproduced under the GNU FDL 1.3.
- Generics
- Interfaces
- For Each
- Iterators
- Tuples
- Array Results
- Defer
- Lambdas
- Block Strings
- String Slices
- Embed
- Typed Variadics
- C Header Import
- Foreign Library Linking
- UString
- Fixed-Width Types
- Nullptr
- String Library
- Format
- Array
- Map
- Set
- LinkedList
- OrderedMap
- OrderedSet
- Sorting
- Optional
- Result
- Smart Pointers
- Date and Time (Chrono)
- Filesystem
- File Streams
- Config (INI and TOML)
- Codec
- Hash
- UUID
- OS
- Process
- Net
- HTTP and TLS
- Math Library
- Finance
- Logging
- Terminal TUI Library
- PsControls
- tkControls
- sys/win
- Goroutines and Channels
- LLVM Backend
- tiko build
- TIKO_COMPILER
- Variable Declarations
- Standard Data Types
- User Defined Types
- Procedures
- Operators
- Control Flow Statements
- Converting Data Types
- Array Functions
- String Functions
- Mathematical Functions
- Bit Manipulation
- Date and Time Functions
- File I/O Functions
- Console Functions
- User Input (Runtime Library)
- User Input Functions (Graphics Library)
- Screen Functions
- 2D Drawing Functions
- Graphics Library Reference
- Graphics Keyword List
- Memory Functions
- Threading Support Functions
- Error Handling Functions
- Operating System Functions
- Preprocessor
- Intrinsic Defines
- Miscellaneous Keywords
- Modularizing