package HW8_SCREEN_IO is procedure PUT_CHAR ( LINE : in INTEGER ; COLUMN : in INTEGER ; PLOT_STR : in STRING ) ; procedure CLEAR_SCREEN ; end HW8_SCREEN_IO ; with SPECIAL_IO ; package body HW8_SCREEN_IO is procedure PUT_CHAR ( LINE : in INTEGER ; COLUMN : in INTEGER ; PLOT_STR : in STRING ) is L , C : INTEGER ; LCH , CCH : INTEGER := 1 ; begin -- Validate the value passed for the line number - between 1 and 23 -- 23 is needed because when program terminates it scrools screen if -- at bottom as is the case here. -- Don't raise, a fuss - just clip at top and bottom L := LINE ; if L < 1 then L := 1 ; elsif L > 23 then L := 23 ; end if ; -- Validate the value passed for the column number - between 0 and 79 -- Don't raise a fuss, just clip at each edge C := COLUMN ; if C < 1 then C := 1 ; elsif C + PLOT_STR'LENGTH > 80 then C := 80 - PLOT_STR'LENGTH ; end if ; -- Now output the whole string, prefixed with [ and terminated with "f" SPECIAL_IO.PUT ( ASCII.ESC & "[" ) ; SPECIAL_IO.PUT ( L , 0 ) ; SPECIAL_IO.PUT ( ";" ) ; SPECIAL_IO.PUT ( C , 0 ) ; SPECIAL_IO.PUT ( "f" & PLOT_STR ) ; end PUT_CHAR ; procedure CLEAR_SCREEN is begin SPECIAL_IO.PUT ( ASCII.ESC & "[2J" ) ; -- Clear the screen and home cursor end CLEAR_SCREEN ; end HW8_SCREEN_IO ;