Liberty BASIC Help Online |
A Simple Example
In Liberty BASIC windows are treated like files, and anything in this class is refered to as a BASIC 'Device'. The OPEN statement is used to OPEN a window and the CLOSE statement is used to close it. The window is controled with PRINT statements, just as a file is controlled by PRINT statements. (The Print statement may be omitted when sending commands. See Sending Commands.) The commands are sent as strings to the device. The following simple example, opens a graphics window, centers a pen (like a Logo turtle), and draws a simple spiral. When the user attempts to CLOSE the window, he is asked to confirm the exit, and if he agrees, the window is closed.
button #graph, "Exit", [exit], LR, 35, 20'window will have a button
open "Example" for graphics as #graph 'open graphics window
print #graph, "up" 'make sure pen is up
print #graph, "home" 'center the pen
print #graph, "down" 'make sure pen is down
for index = 1 to 30 'draw 30 spiral segments
print #graph, "go "; index 'go foreward 'index' places
print #graph, "turn 118" 'turn 118 degrees
next index 'loop back 30 times
print #graph, "flush" 'make the image 'stick'
[inputLoop]
input b$ : goto [inputLoop] 'wait for button press
[exit]
confirm "Close Window?"; answer$ 'dialog to confirm exit
if answer$ = "no" then [inputLoop] 'if answer$ = "no" loop back
close #graph
end
Copyright (C) 2003 Shoptalk Systems
Liberty BASIC - http://www.libertybasic.com/