clear
Depending on the parameter provided, this function specifies a part of the screen. You need to make sure that all cursor positions are inside the screen. Attempting to go beyond the screen will not lead to scrolling any contents.
1st parameter | 2nd parameter | Description |
---|---|---|
all | not applicable | Clears the entire screen, but in contrast to cls() the buffer above the screen window will be preserved. Applicable if no parameter sepcified. |
all below | not applicable | Clears the entire screen, but all contents on the screen will be preserved in the buffer above the screen window. This is implemented by scrolling down one full screen size, followed by a clear(all) function call. |
left | horizontal offset | Clears the row contents from the first column to the cursor position and possibly shifted by the offset value. Offset = 0 includes clearing the contents underneath the cursor. Positive (and negative) offsets shift the position to the right (and left). Example: clear( left, 3 ); with cursor position at column 40 clears columns 1-43 in the current row. |
right | horizontal offset | Clears the row contents from the cursor position and possibly shifted by the offset value till end of row. Offset = 0 includes clearing the contents underneath the cursor. Positive (and negative) offsets shift the position to the right (and left). Example: clear( left, -5 ); with cursor position at column 20 clears columns 15 till end of row. |
above | vertical offset | Clears row 1 till current row and possibly shifted by the offset value. Offset = 0 includes clearing the current row. Positive (and negative) offsets shift the position a specified number of rows down (and up). Ëxample: clear( above, -2 ); with cursor on row 10 clears rows 1-8. |
below | vertical offset | Clears the current row and possibly shifted by the offset value till end of screen. Offset = 0 includes clearing the current row. Positive (and negative) offsets shift the position a specified number of rows down (and up). Ëxample: clear( below, 1 ); clears the next row below the cursor position. clear( below, -1 ); also clears the current row and one row above. |
left above | horizontal offset | Combination of 'left' and 'above'. All rows above the current row will be cleared. The vertical offset is 0. clear(left above, -1); clears all characters to the left without the character underneath the cursor, and all rows above. |
right below | horizontal offset | Combination of 'right' and 'below'. All rows below the current row will be cleared. The vertical offset is 0. clear(right below, 1); clears all characters to the right without the character underneath the cursor, and all rows below. |
row | vertical offset | The current row, and possibly shifted by the offset value, will be cleared. clear(row, 3); clears the entire row which is 3 rows below the cursor position. Negative numbers refer to rows above the current cursor position. Positive numbers refer to rows below the current cursor position. |
rows above | row count | A specified number of rows above the current row will be cleared. The current row remains untouched. clear(rows above, 5); clears 5 rows above the current row. |
rows below | row count | A specified number of rows below the current row will be cleared. The current row remains untouched. clear(rows below, 5); clears 5 rows belowthe current row. |
alt | not applicable | Activates the alternative screen buffer and clears the screen. The alternative screen has only one full screen size without scrollable buffer space. This feature is often used in LINUX when starting a text editor (like vi and manpages under LINUX) and the original screen returns when leaving that editor. Note: Calling clear(alt) for a 2nd time has no effect. Note: Colors and other settings such as underscore continue to be effective. |
back | not applicable | Returns from the alternative screen buffer to the main buffer, making all previous contents and work visible again. Note: Calling clear(back) without alternative screen activated before has no impact. Note: Colors and other settings such as underscore continue to be effective, even if set or changed in the alternative screen buffer.. |
Indirect parameter passing is disabled
The consoles under Windows, LINUX and MacOS and even different console or terminal programs may show some deviating behaviors.
0-2
No. | Type | Description |
---|---|---|
Opt. 1. input |
string | Option The options indicate the rows and/or screen areas to be cleared. See the table above for details. Default value: all |
Opt. 2 input |
numeral | Offset or count For the options 'left', 'right', 'left above' and 'right above', the value refers to the horizontal offset. Negative values point leftward from
the cursor, and positive values point rightward from the cursor. 0 refers to the current cursor position.
|
none
savecode
clear( row ); // Clears current row
clear( right below, 1); // Clears rest of line (but not the character underneath the cursor) and the rest of the screen.