Difference between revisions of "Clear"

From MiniScript Wiki
Jump to navigation Jump to search
m
(added usage notes)
 
Line 1: Line 1:
In [[Mini Micro]], <c>clear</c> is a commonly-used function to clear the screen and reset the [[Display|displays]] to their default modes, as shown below.
+
In [[Mini Micro]], <c>clear</c> is a commonly-used function to clear the screen and reset the [[Display|displays]] to their default [[displayMode|modes]], as shown below.
  
 
[[File:DisplayLayout.png]]
 
[[File:DisplayLayout.png]]
Line 7: Line 7:
 
The <c>clear</c> method is defined in <c>[[startup.ms|/sys/startup.ms]]</c>.
 
The <c>clear</c> method is defined in <c>[[startup.ms|/sys/startup.ms]]</c>.
  
 +
== Usage Notes ==
 +
 +
Because <c>clear</c> changes all eight display modes back to their default modes, it makes no sense to set up some other display type (for example a [[TileDisplay]]) that you want to use and ''then'' call clear.  Doing so would just switch off the display you had set up.  Moreover, <c>clear</c> does not clear non-standard displays; it only turns them off.
 +
 +
As a result of the above, in most programs <c>clear</c> should be called very early in the program, and certainly before you start setting up any [[Display|displays]].
 +
 +
[[PixelDisplay]], [[TextDisplay]], [[TileDisplay]], and [[SpriteDisplay]] all have a <c>.clear</c> method you can call to clear/reset just that one display.
  
 
[[Category:Mini Micro]]
 
[[Category:Mini Micro]]

Latest revision as of 13:32, 21 May 2021

In Mini Micro, clear is a commonly-used function to clear the screen and reset the displays to their default modes, as shown below.

DisplayLayout.png

clear also reassigns the text and gfx globals to display(3) and display(5) respectively, and moves the text cursor to row 25 (top of the screen).

The clear method is defined in /sys/startup.ms.

Usage Notes

Because clear changes all eight display modes back to their default modes, it makes no sense to set up some other display type (for example a TileDisplay) that you want to use and then call clear. Doing so would just switch off the display you had set up. Moreover, clear does not clear non-standard displays; it only turns them off.

As a result of the above, in most programs clear should be called very early in the program, and certainly before you start setting up any displays.

PixelDisplay, TextDisplay, TileDisplay, and SpriteDisplay all have a .clear method you can call to clear/reset just that one display.