All pastes #210031 Raw Edit

b-rog

public text v1 · immutable
#210031 ·published 2006-10-19 13:53 UTC
rendered paste body
% 7. Write a procedure called follow that allows the user to use the mouse to
%    click on the screen. When they click on the screen it draws a circle with
%    radius 10, and a line to the last spot clicked (no line if its the first
%    click).When the user clicks for the fourth time the procedure will erase
%    the first circle and line. From then on, whenever a new circle and line are
%    drawn the oldest one will be erased. The procedure will end when the user
%    clicks on both buttons at once. The colour of all the drawing is supplied
%    by a single integer parameter. Save as array7.t

View.Set ("graphics:max,max")
proc follow (x, y : array 1 .. 4 of int)
    var count : int := 0
    var mx, my, mb : int
    loop
        for i : 1 .. upper (x)
            mousewhere (mx, my, mb)
            if mb = 1 then
                drawfilloval (mx - 5, my - 5, 10, 10, black)
                count += 1
                exit when count = 4
            end if
        end for
        delay (100)

    end loop
end follow

var x, y : array 1 .. 4 of int

follow (x, y)