FLUSH

From Liberty BASIC Family
Jump to navigation Jump to search
Supported in Just BASIC Supported in Liberty BASIC Not supported in Liberty BASIC 5 Not supported in Run BASIC

Description

For use with graphics windows and graphic-boxes, FLUSH saves a list of the drawing commands so they will persist whenever your graphics window is minimized, covered over, or resized. Without a flush command, any of those actions could cause the graphics to be 'lost'. The flush process is often called 'sticking' the graphics.
FLUSH also creates a new current drawing segment and gives it the next higher ID number.
Some commands used when 'sticking' graphics are:
segment
delsegment
cls
discard
redraw

Syntax

This command is NOT case sensitive.
  1. #handle "flush" - a graphics window
  2. #handle.ext "flush" - a graphicbox

Hints

Often, you will not be concerned with a segment name. For example, you may only want to be sure that the fill color of the graphics window is preserved if a user minimizes it. In that case, all you need to do is flush the graphics. At other times, you may want to refresh the window with a particular group of graphics, say with game play. These commands assign a name to the group of graphics that are flushed so you can refer to the group at any time.
#handle "flush segmentName" - a graphics window
#handle.ext "flush segmentName" - a graphicbox

Example

An example of the command in a graphics window.

nomainwin

    WindowWidth=400
    WindowHeight=300

    open "Flush Demo" for graphics_nsb_nf as #g
    #g "trapclose [quit]"

    'put the pen down
    #g "down; place 10 10"
    'draw a blue box
    #g "backcolor blue"
    #g "boxfilled 100 100"

    'make graphics stick
    #g "flush"

    wait

[quit]
    close #g
    end

An example of the command in a graphicbox.

nomainwin

    WindowWidth=400
    WindowHeight=300

    graphicbox #g.gb 0, 0, 390, 270
    open "Flush Demo" for window_nf as #g
    #g "trapclose [quit]"

    'put the pen down
    #g.gb "down; place 10 10"
    'draw a blue box
    #g.gb "color blue"
    #g.gb "box 100 100"

    'make graphics stick
    #g.gb "flush"

    wait

[quit]
    close #g
    end

Useful Procedures

' Place a useful function or sub using this keyword here