Cls
 
Clears the screen in both text modes and graphics modes

Syntax

Declare Sub Cls ( ByVal mode As Integer = 0 )

Usage

Cls mode

Parameters

mode
A optional numeric variable with a value from 0 to 2.

Description

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, if a text viewport has been defined, it is cleared. Otherwise, the entire screen is cleared.

If 0, clears the entire screen

If 1, clears the graphics viewport if defined. Otherwise, clears the entire screen.

If 2, clears the text viewport


Example

Color , 1
Cls
Locate 12, 35
Print "Hello Universe!"


Using C's memset instead of CLS might give you a speed boost:

#include "crt.bi"
Const x_res = 640, y_res = 480, bpp = 32
Dim scrbuf As Any Ptr, scrsize As Integer
Dim i As Integer, j As Integer

ScreenRes x_res, y_res, bpp
scrbuf = ScreenPtr
scrsize = x_res * y_res * bpp / 8

Do
    ScreenLock
        memset scrbuf, 0, scrsize
        Circle (320, 240), i
    ScreenUnlock
   
    If j = 0 Then
        i = i + 1
        If i >= 100 Then j = 1
    ElseIf j = 1 Then
        i = i - 1
        If i <= 0 Then j = 0
    End If
   
    Sleep 1, 1
Loop While Inkey=""


Differences from QB

  • None

See also