再问问题
由 shanshan81 于 周五, 2006-10-27 06:50 提交。
一个程序
procedure try is
begin
procedure 1;
statement 2;
end try;
其中statement 1 是调用另外一个package里面的程序。 它的功能是产生一个界面,用gtkada做的。编译成功。然后运行的时候,执行procedure 1出现一个界面,但是statement 2 就不再被执行了。程序一旦运行到产生界面那一句,就停止了,不在往后继续运行了,很郁闷,为什么??

不理解你为什么还要
不理解你为什么还要第二次输出那个温度?
package Inputdialog is
Austemp: Float;
procedure Window;
end Inputdialog;
------------------------------------------------------------------
with Gtk.Main;
use Gtk.Main;
with Gtk.Box;
use Gtk.Box;
with Gtk.Label;
use Gtk.Label;
with Gtk.Window;
use Gtk.Window;
with Gtk.Button;
use Gtk.Button;
with Gtk.Gentry;
use Gtk.Gentry;
with Gtk.Handlers;
use Gtk.Handlers;
with Gtk.Widget;
use Gtk.Widget;
with Ada.Float_Text_Io;
use Ada.Float_Text_Io;
with Ada.Text_Io;
use Ada.Text_Io;
package body Inputdialog is
procedure Window is
type T_Objects is
record
Window : Gtk_Window;
Zone : Gtk_Hbox;
Button : Gtk_Button;
Text : Gtk_Entry;
Mylabel : Gtk_Label;
end record;
type T_Obj_Acc is access T_Objects;
Obj : T_Obj_Acc :=
new T_Objects;
package Button_Callback is new
Gtk.Handlers.User_Callback(Gtk_Button_Record, T_Obj_Acc);
package Text_Callback is new
Gtk.Handlers.Callback(Gtk_Entry_Record);
procedure Btncallback (
Object : access Gtk_Button_Record'Class;
Data_Obj : T_Obj_Acc) is
pragma Unreferenced (Object);
begin
Austemp:=Float'Value(Get_Text(Data_Obj.Text));
Set_Text(Data_Obj.Text,"Aussentemperature is to: " & Get_Text(
Data_Obj.Text));
Put("Aussentemperature is to: ");
Put(Austemp);
New_Line;
exception
when others =>
Put_Line("INPUT ERROR!");
Set_Text(Data_Obj.Text,"Input Error!");
end Btncallback;
procedure Txtcallback (
T : access Gtk_Entry_Record'Class) is
begin
Set_Text(T,"");
end Txtcallback;
begin
Init;
Gtk_New(Obj.Window);
Set_Title(Obj.Window, "InputDialog");
Set_Size_Request(Obj.Window,200,80);
Gtk_New_Vbox(Obj.Zone, False,0);
Add(Obj.Window, Obj.Zone);
Gtk_New(Obj.Mylabel, "Aussentemperature eingeben: ");
Pack_Start(Obj.Zone,Obj.Mylabel,True,True,0);
Gtk_New(Obj.Text);
Pack_Start(Obj.Zone,Obj.Text,True,True,0);
Gtk_New(Obj.Button, "OK");
Pack_End(Obj.Zone, Obj.Button, True, True,0);
Show_All(Obj.Window);
Button_Callback.Connect(Obj.Button, "clicked",
Button_Callback.To_Marshaller(Btncallback'access),Obj);
Text_Callback.Connect(Obj.Text,"grab_focus",Txtcallback'access,
True);
Main;
end Window;
end Inputdialog;
-----------------------------------------------------------------------------------------------
with Inputdialog; use Inputdialog;
with ada.Float_Text_IO; use ada.Float_Text_IO;
procedure Testdialog is
begin
Inputdialog.Window;
end Testdialog;