with Ada.Float_Text_IO; use Ada.Float_Text_IO; with Ada.Text_IO; use Ada.Text_IO; with Ada.Strings; use Ada.Strings; with Ada.Strings.Unbounded; use Ada.Strings.Unbounded; with Ada.Integer_Text_IO; use Ada.Integer_Text_IO; with Interfaces; use Interfaces; Procedure calc is gkeepgoing, gfisnumberentering:Boolean; gdisplaystr, parsestr, tmpbuf :Unbounded_String; gax, gbx:Long_Float; gFRectx1, gFRecty1, gFRectx2, gFRecty2, gRectx1, gRecty1, gRectx2, gRecty2 : Unsigned_16; gtextx, gtexty : array (0..1) of Unsigned_16; gcmdtext : array (0..1) of String(1..3) := ("C$ ", "R$ "); kbdcolor : array (0..19) of String(1..8) := ("02628095","02628095","02628095","01015567","00986895","00986895","00986895","01015567","00986895","00986895","00986895","01015567","00986895","00986895","00986895","01015567","00986895","00986895","00986895","01015567"); kbdstr : array (0..19) of String(1..3) := ("Off"," C "," Begin buildstr( To_Unbounded_String(kbdstr(rowcol)(((kbdstr(rowcol)'First+kbdstr(rowcol)'Last)/2)..((kbdstr(rowcol)'First+kbdstr(rowcol)'Last)/2))) ); displaystr( 0, gdisplaystr, RGB(92,92,127) ); End; when 0 => Begin concat_Line( "O 0 0 0" ); gkeepgoing:=False; End; when 1 => Begin gdisplaystr:=To_Unbounded_String(""); displaystr( 0, To_Unbounded_String("0"), RGB(92,92,127) ); gfisnumberentering:=False; End; when 2 => Begin If ( Length(gdisplaystr) > 0 ) then If ( Length(gdisplaystr) = 1 ) then displaystr( 0, To_Unbounded_String("0"), RGB(92,92,127) ); End If; Delete(gdisplaystr,Length(gdisplaystr),1); If ( Length(gdisplaystr) > 0 ) then displaystr( 0, gdisplaystr, RGB(92,92,127) ); End If; End If; End; when 18 => Begin If ( Length(gdisplaystr) > 0 ) then If ( To_String(gdisplaystr)(To_String(gdisplaystr)'First) = '-' ) then Delete( gdisplaystr, 1, 1 ); Else If ( Length(gdisplaystr) < ( 24 - 1 ) ) then parsestr:=To_Unbounded_String("-"); eatwhitespace(gdisplaystr); Append(parsestr,gdisplaystr); gdisplaystr:=parsestr; End If; End If; displaystr( 0, gdisplaystr, RGB(92,92,127) ); End If; End; when 3 | 7 | 11 | 15 => Begin gbinop:=rowcol; gax:=Long_Float'Value(To_String(gdisplaystr)); gfisnumberentering:=False; End; when 19 => Begin If ( gfisnumberentering ) then gbx:=Long_Float'Value(To_String(gdisplaystr)); gfisnumberentering:=False; End If; case ( gbinop ) is when 3 => gax:= gax * gbx; when 7 => gax:= gax / gbx; when 11 => gax:= gax + gbx; when 15 => gax:= gax - gbx; when others => null; End case; gdisplaystr:=To_Unbounded_String(Long_Float'Image(gax)); displaystr( 0, gdisplaystr, RGB(92,92,127) ); End; when others => null; End case; End key_to_exe; Procedure drawapp is tmpbuf:Unbounded_String; Begin concat_Line( "Fo 0 611 3" ); concat_Line( "Fo 2 140 3" ); concat_Line( "F 0 16777215" ); cached_frectangle_server( 0, 0, 0, 10000, 10000 ); concat( "F 0 " ); tmpbuf:=To_Unbounded_String(Unsigned_32'Image(Unsigned_32(RGB(192,192,192)))); eatwhitespace(tmpbuf);concat_Line( To_String(tmpbuf) ); For rowcol in 0 .. 19 loop cached_frectangle_server(0, Unsigned_16((rowcol mod 4)*2000+190), Unsigned_16((rowcol/4)*1200+1190), Unsigned_16(((rowcol mod 4)+1)*2000+110), Unsigned_16(((rowcol/4)+1)*1200+1110) ); End loop; concat( "F 0 " ); tmpbuf:=To_Unbounded_String(Unsigned_32'Image(RGB(15,15,15)));eatwhitespace(tmpbuf); concat_Line(To_String(tmpbuf)); For rowcol in 0 .. 19 loop cached_rectangle_server(0, Unsigned_16((rowcol mod 4)*2000+200), Unsigned_16((rowcol/4)*1200+1200), Unsigned_16(((rowcol mod 4)+1)*2000+100), Unsigned_16(((rowcol/4)+1)*1200+1100) ); End loop; concat_Line( "B 0 12632256" ); concat_Line( "F 0 986895" ); For rowcol in 0 .. 19 loop If ( kbdcolor(rowcol) = "00986895" ) then cached_text_server( 0, 0, Unsigned_16((rowcol mod 4)*2000+1100), Unsigned_16((rowcol/4)*1200+1700), To_Unbounded_String(kbdstr(rowcol)) ); End If; End loop; concat_Line( "F 0 2628095" ); For rowcol in 0 .. 19 loop If ( kbdcolor(rowcol) = "02628095" ) then cached_text_server( 0, 0, Unsigned_16((rowcol mod 4)*2000+1100), Unsigned_16((rowcol/4)*1200+1700), To_Unbounded_String(kbdstr(rowcol)) ); End If; End loop; concat_Line( "F 0 1015567" ); For rowcol in 0 .. 19 loop If ( kbdcolor(rowcol) = "01015567" ) then cached_text_server( 0, 0, Unsigned_16((rowcol mod 4)*2000+1100), Unsigned_16((rowcol/4)*1200+1700), To_Unbounded_String(kbdstr(rowcol)) ); End If; End loop; concat_Line( "F 0 255" ); concat_Line( "C$ 0 5000 800 ""Ada cloud app""" ); concat_Line( "F 2 255" ); concat_Line( "C$ 2 5000 7200""Corrie Zucker Technologies LLC.""" ); concat_Line( "C$ 2 5000 7340""d/b/a CZ Technologies""" ); concat_Line( "Z " ); If ( Length(gdisplaystr) = 0 ) then displaystr( 0, To_Unbounded_String("0"), RGB(92,92,127) ); Else displaystr( 0, gdisplaystr, RGB(92,92,127) ); End If; End drawapp; Function eatnumber(iobuffer:in out Unbounded_String) return Integer_16 is ret : Integer_16 := 0; sign : Integer_16 := 1; Begin Append(iobuffer,' '); --make sure a space is last to aid in getting all the digits. If ( To_String(iobuffer)(To_String(iobuffer)'First) = '-' ) then sign:=-1; iobuffer:=To_Unbounded_String(To_String(iobuffer)( To_String(iobuffer)'First+1 .. To_String(iobuffer)'Last)); End If; While ( To_String(iobuffer)'First < To_String(iobuffer)'Last ) and ( To_String(iobuffer)(To_String(iobuffer)'First) /= ' ' ) loop ret:=10*ret; case ( To_String(iobuffer)(To_String(iobuffer)'First) ) is when '1' => ret:=ret+1; when '2' => ret:=ret+2; when '3' => ret:=ret+3; when '4' => ret:=ret+4; when '5' => ret:=ret+5; when '6' => ret:=ret+6; when '7' => ret:=ret+7; when '8' => ret:=ret+8; when '9' => ret:=ret+9; when others => null; End case; iobuffer:=To_Unbounded_String(To_String(iobuffer)( To_String(iobuffer)'First+1 .. To_String(iobuffer)'Last)); End loop; return ret*sign; End eatnumber; Begin gkeepgoing:=True; button:=0; x:=0; y:=0; While gkeepgoing loop if End_Of_File then exit; end if; buffer:=To_Unbounded_String(Get_Line); If buffer = "drawapp" then drawapp; Else If buffer = "QUERY_REMOTE" then concat_Line( "Rz 1200 900" ); Else button:=eatnumber(buffer); eatwhitespace(buffer); x:=eatnumber(buffer); eatwhitespace(buffer); y:=eatnumber(buffer); If ( ( x >= 0 ) and ( button = 1 ) ) then row:=Integer((y-1200)/1200); col:=Integer((x-200)/2000); if ( ( row >= 0 ) and ( row < 5 ) and ( col >= 0 ) and ( col < 4 ) ) then key_to_exe( row*4+col ); End If; Else If ( x = -4 ) then concat("Rz "); tmpbuf:=To_Unbounded_String(Integer'Image(Integer(button))); eatwhitespace(tmpbuf); concat( To_String(tmpbuf) ); concat(" "); tmpbuf:=To_Unbounded_String(Integer'Image(Integer(button))); eatwhitespace(tmpbuf); concat_line( To_String(tmpbuf) ); Else If ( x = -5 ) then concat("Mv "); tmpbuf:=To_Unbounded_String(Integer'Image(Integer(button))); eatwhitespace(tmpbuf); concat( To_String(tmpbuf) ); concat(" "); tmpbuf:=To_Unbounded_String(Integer'Image(Integer(button))); eatwhitespace(tmpbuf); concat_line( To_String(tmpbuf) ); drawapp; Else If ( x = -2 ) then case ( button ) is when 79 | 111 => key_to_exe(0); when 67 | 99 => key_to_exe(1); when 8 => key_to_exe(2);when 42 => key_to_exe(3);when 46 => key_to_exe(17); when 48 => key_to_exe(16); when 55 => key_to_exe(4);when 56 => key_to_exe(5);when 57 => key_to_exe(6); when 52 => key_to_exe(8);when 53 => key_to_exe(9);when 54 => key_to_exe(10); when 49 => key_to_exe(12);when 50 => key_to_exe(13);when 51 => key_to_exe(14); when 47 => key_to_exe(7);when 43 => key_to_exe(11);when 45 => key_to_exe(15); when 73 | 105 => key_to_exe( 18 ); when 61 => key_to_exe( 19 ); when others => null; End case; Else If ( x = -98 ) then delay Duration(0.001*Float(y)); End If; End If; End If; End If; End If; End If; End If; End loop; End calc;