UNIT GI; INTERFACE {---------------------------------------------------------------------------} USES CRT,GRAPH; {---------------------------------------------------------------------------} CONST XMax=640; YMax=480; {---------------------------------------------------------------------------} TYPE Location = OBJECT X:1..XMax; Y:1..YMax; END;{Location} GUI=OBJECT(Location) Coor:Location; PROCEDURE SetupScreen(Path:STRING); {initialize the screen to graphic mode Parameter: in: path Out: none precondtion: none postconditon: screen initialize in graphic mode or print error msg} PROCEDURE WriteInt( Num:LongInt; Field:Integer); {write integer data in graphic mode at x,y and with field parameter: IN: num,field OUT: none pre: in graphic mode Post: num displayed with field } PROCEDURE WriteReal( Num:Real; DecField:Integer); {write integer data in graphic mode at x,y and with Integer field and decimal field parameter: IN: num,Intfield,Decfield OUT: none pre: in graphic mode Post: num displayed with integer field and decimal field } PROCEDURE Init( NewX,NewY:Integer; Path:STRING); {initialize the parameters Parameter: IN: NewX,NewY OUT: None Pre: none Post: NewX=> X NewY=> Y} PROCEDURE GWrite( Prompt: STRING); {write a text string on the screen Parameter: IN: Prompt OUT: none Pre: 0GrOK THEN BEGIN Writeln ('Graphics error: ',GraphErrorMsg(GError)); Readln; END; UNTIL GError=grOK; END;{SetupScreen} {---------------------------------------------------------------------------} PROCEDURE GUI.Init; {initialize the parameters Parameter: IN: NewX,NewY,Patn OUT: None Pre: none Post: NewX=> X NewY=> Y screen in graphic mode} BEGIN{Init} X:=NewX; Y:=NewY; Coor.X:=NewX; Coor.Y:=NewY; SetupScreen('C:\TP\BGI'); END; {---------------------------------------------------------------------------} PROCEDURE GUI.ChkPos; {put the cursor at the end of the msg Parameter: IN: none OUT: none Pre: none Post: Coor.X incremented or Coor.X:=X } BEGIN{NxtPos} IF Coor.X<(640-TextWidth(Prompt+'x')) THEN INC(Coor.X,TextWidth(Prompt)) ELSE NxtLn; END;{NxtPos} {---------------------------------------------------------------------------} PROCEDURE GUI.GWrite; {write a text string on the screen Parameter: IN: Prompt OUT: none Pre: 0