Program calc; uses Crt, Linux, BaseUnix, SysUtils; Var gdisplaystr:String[24]; gfisnumberentering:Boolean; parsestr:String; gbinop:String; gax, gbx:real; gFRectx1, gFRecty1, gFRectx2, gFRecty2:Integer; gRectx1, gRecty1, gRectx2, gRecty2:Integer; gCentertextx, gCentertexty:Integer; gLefttextx, gLefttexty:Integer; gRighttextx, gRighttexty:Integer; kbdcolor: array [0..19] of String = ('2628095','2628095','2628095','1015567','986895','986895','986895','1015567','986895','986895','986895','1015567','986895','986895','986895','1015567','986895','986895','986895','1015567'); kbdstr: array [0..19] of String = ('Off','C',' 0 ) then Begin kahncat( 'L ' ); kahncat_int( f ); kahncat( ' ' ); kahncat_int( x1 ); kahncat( ' ' ); kahncat_int( y1 ); kahncat( ' ' ); kahncat_int( x2 ); kahncat( ' ' ); kahncat_int( y2 ); klush(); End; End; Procedure cached_centertext_server( f, x, y:Integer; str:String ); Begin kahncat( 'C$ ' ); kahncat_int( f ); gCentertextx:=cond_star_number_server( x, gCentertextx ); gCentertexty:=cond_star_number_server( y, gCentertexty ); kahncat( '"' ); kahncat( str ); kahncat( '"' ); klush(); End; Procedure cached_righttext_server( f, x, y:Integer; str:String ); Begin kahncat( 'R$ ' ); kahncat_int( f ); gRighttextx:=cond_star_number_server( x, gRighttextx ); gRighttexty:=cond_star_number_server( y, gRighttexty ); kahncat( '"' ); kahncat( str ); kahncat( '"' ); klush(); End; Procedure displaystr( font:Integer; psz:String; color:Integer ); Begin kahncat( 'F ' ); kahncat_int( font ); kahncat( ' ' ); kahncat_int( RGB(255,255,255) ); klush(); cached_frectangle_server( font, 0, 0, 9900, 600 ); kahncat( 'F ' ); kahncat_int( font ); kahncat( ' ' ); kahncat_int( color ); klush(); cached_rectangle_server( font, 100, 100, 9800, 500 ); cached_righttext_server( font, 9800, 520, psz ); kahncat_Line( 'Z ' ); End; Procedure negatestr; Begin If ( byte(gdisplaystr[0]) > 0 ) then Begin If ( gdisplaystr[1] = '-' ) then Delete( gdisplaystr, 1, 1 ) Else If ( byte(gdisplaystr[0]) < ( 24 - 1 ) ) then Insert( '-', gdisplaystr, 1 ); displaystr( 0, gdisplaystr, RGB(92,92,127) ) End End; Procedure backspacestr; Begin If ( byte(gdisplaystr[0]) > 0 ) then Begin If ( byte(gdisplaystr[0]) = 1 ) then Begin displaystr( 0, '0', RGB(92,92,127) ); End; Delete(gdisplaystr,byte(gdisplaystr[0]),1); If ( byte(gdisplaystr[0]) > 0 ) then Begin displaystr( 0, gdisplaystr, RGB(92,92,127) ); End; End; End; Procedure buildstr( ch:String ); Begin If ( gfisnumberentering ) then Begin If ( byte(gdisplaystr[0]) < ( 24 - 1 ) ) then Begin gdisplaystr:=Concat(gdisplaystr,ch); End; End Else Begin gdisplaystr:=ch; gfisnumberentering:=True; End; End; Procedure binop( rowcol: Integer ); Var code:Integer; Begin gbinop:=kbdstr[rowcol]; Val( gdisplaystr,gax,code ); If ( code <> 0 ) then Begin gax:=0; End; gfisnumberentering:=False; End; Procedure equals; Var code:Integer; Begin If ( gfisnumberentering ) then Begin Val( gdisplaystr,gbx,code ); If ( code <> 0 ) then Begin gbx:=0; End; gfisnumberentering:=False; End; case ( gbinop ) of '*': gax *= gbx; '/': gax /= gbx; '+': gax += gbx; '-': gax -= gbx; End; Str(gax,gdisplaystr); displaystr( 0, gdisplaystr, RGB(92,92,127) ); End; Function key_to_exe( rowcol: Integer ):Integer; Begin case ( rowcol ) of 4, 5, 6, 8, 9, 10, 12, 13, 14, 16, 17: Begin buildstr( kbdstr[rowcol] ); displaystr( 0, gdisplaystr, RGB(92,92,127) ) End; 0: Begin kahncat_Line( 'O 0 0 0' ); End; 1: Begin gdisplaystr:=''; displaystr( 0, '0', RGB(92,92,127) ); gfisnumberentering:=False; End; 2: backspacestr; 18: negatestr; 3, 7, 11, 15: binop(rowcol); 19: equals End; key_to_exe:=rowcol End; Function handleui( button,x,y:Int16 ):Integer; Var row, col, rowcol:Integer; Begin rowcol:=20; If ( ( x >= 0 ) and ( button = 1 ) ) then Begin row:=TRUNC(TRUNC(TRUNC(y)-TRUNC(200)-TRUNC(1000))/TRUNC(1200)); col:=TRUNC(TRUNC(TRUNC(x)-TRUNC(200))/TRUNC(2000)); if ( ( row >= 0 ) and ( row < 5 ) and ( col >= 0 ) and ( col < 4 ) ) then rowcol:=key_to_exe( row*4+col ) End Else case ( x ) of -2: case ( button ) of 79,111: rowcol:=key_to_exe( 0 ); 67,99: rowcol:=key_to_exe( 1 ); 8: rowcol:=key_to_exe( 2 ); 42: rowcol:=key_to_exe( 3 ); 55: rowcol:=key_to_exe( 4 ); 56: rowcol:=key_to_exe( 5 ); 57: rowcol:=key_to_exe( 6 ); 47: rowcol:=key_to_exe( 7 ); 52: rowcol:=key_to_exe( 8 ); 53: rowcol:=key_to_exe( 9 ); 54: rowcol:=key_to_exe( 10 ); 43: rowcol:=key_to_exe( 11 ); 49: rowcol:=key_to_exe( 12 ); 50: rowcol:=key_to_exe( 13 ); 51: rowcol:=key_to_exe( 14 ); 45: rowcol:=key_to_exe( 15 ); 48: rowcol:=key_to_exe( 16 ); 46: rowcol:=key_to_exe( 17 ); 73,105: rowcol:=key_to_exe( 18 ); 61: rowcol:=key_to_exe( 19 ); End; -4: Begin kahncat( 'Rz ' ); kahncat_int( button ); kahncat( ' ' ); kahncat_int( y ); klush(); End; -5: Begin kahncat( 'Mv ' ); kahncat_int( button ); kahncat( ' ' ); kahncat_int( y ); klush(); End; -92: If ( x = -92 ) then Delay(y); End; handleui:=rowcol; End; Procedure drawapp; Var rowcol:integer; Begin kahncat_Line( 'Fo 0 611 3' ); kahncat_Line( 'Fo 1 360 3'); kahncat_Line( 'Fo 2 140 3'); kahncat_Line( 'F 0 16777215'); kahncat_Line( 'FR 0 0 0 10000 10000' ); displaystr( 0, '0', RGB(92,92,127) ); kahncat( 'F 0 ' ); kahncat_int_Line( RGB(192,192,192) ); kahncat_Line( 'B 0 12632256' ); For rowcol:=0 to 19 do Begin cached_frectangle_server(0, (rowcol MOD 4) * 2000 + 190, (rowcol DIV 4) * 1200 + 1190, ((rowcol MOD 4) + 1) * 2000 + 110, ((rowcol DIV 4) + 1) * 1200 + 1110 ); End; kahncat( 'F 0 ' ); kahncat_int_Line( RGB(15,15,15) ); For rowcol:=0 to 19 do Begin cached_rectangle_server(0, (rowcol MOD 4) * 2000 + 200, (rowcol DIV 4) * 1200 + 1200, ((rowcol MOD 4) + 1) * 2000 + 100, ((rowcol DIV 4) + 1) * 1200 + 1100 ); End; kahncat_Line( 'F 0 986895' ); For rowcol:=0 to 19 do Begin If ( kbdcolor[rowcol] = '986895' ) then Begin cached_centertext_server( 0, (rowcol MOD 4) * 2000 + 1100, (rowcol DIV 4) * 1200 + 1700, kbdstr[rowcol] ) End; End; kahncat_Line( 'F 0 2628095' ); For rowcol:=0 to 19 do Begin If ( kbdcolor[rowcol] = '2628095' ) then Begin cached_centertext_server( 0, (rowcol MOD 4) * 2000 + 1100, (rowcol DIV 4) * 1200 + 1700, kbdstr[rowcol] ) End; End; kahncat_Line( 'F 0 1015567' ); For rowcol:=0 to 19 do Begin If ( kbdcolor[rowcol] = '1015567' ) then Begin cached_centertext_server( 0, (rowcol MOD 4) * 2000 + 1100, (rowcol DIV 4) * 1200 + 1700, kbdstr[rowcol] ) End; End; kahncat_Line( 'F 1 255' ); kahncat_Line( 'L$ 1 20 900 "pascal cloud app transparent shell stdinout"' ); kahncat_Line( 'F 2 255' ); kahncat_Line( 'C$ 2 5000 7200"Corrie Zucker Technologies LLC."' ); kahncat_Line( 'C$ 2 5000 7340\"d/b/a CZ Technologies"' ); kahncat_Line( 'Z ' ); if ( byte(gdisplaystr[0]) = 0 ) then Begin displaystr( 0, '0', RGB(92,92,127) ); End Else Begin displaystr( 0, gdisplaystr, RGB(92,92,127) ); End; End; Begin button:=0; rowcol:=1; x:=0; y:=0; While rowcol <> 0 do Begin Readln( buffer ); If buffer = 'drawapp' then Begin drawapp; rowcol:=20 End Else If buffer = 'QUERY_REMOTE' then Begin kahncat_Line( 'Rz 1200 900' ); rowcol:=20 End Else Begin parsestr:=Copy(buffer,1,pos( ' ',buffer)-1); Val(parsestr,button); Delete( buffer, 1, pos( ' ', buffer ) ); parsestr:=Copy(buffer,1,pos( ' ',buffer)-1); Val(parsestr,x); Delete( buffer, 1, pos( ' ', buffer ) ); Val(buffer,y); rowcol:=handleui( button, x, y ) End End End.