How to close graphical window/widget using Ada code?

Viewed 89

I am running a sample code written in Ada. The code's task is to plot a function using plplot library. It is set to use xcairo driver. When I execute the program in linux (opensuse), the program displays terminal shell and then another window (widget-xcairo?) with graphical display of plot. How do I close that another window with ada command without closing running terminal shell? I can close that another window with a click on close icon with a mouse but I would like to know how to close that another window with ada code for programming purpose. The command End_PLplot in ada binding for PLplot has plend command which probably ends the plplot execution but not closing that another window. Below is the sample code,

 with
  Ada.Strings,
  Ada.Strings.Unbounded,
  PLplot_Auxiliary,
  PLplot_Standard;

 use
  Ada.Strings,
  Ada.Strings.Unbounded,
  PLplot_Auxiliary,
  PLplot_Standard;


 procedure speedplot is
  driver : Unbounded_String;
  x, y : Real_Vector(0 .. 100);
  x_Min, y_Min : constant := 0.0;
  x_Max : constant := 1.0;
  y_Max : constant := 100.0;
 begin
-- Prepare data to be plotted.
 for i in x'range loop
    x(i) := Long_Float(i) / Long_Float(x'length - 1);
    y(i) := y_Max * x(i)**2;
 end loop;

-- Parse and process command line arguments.

    driver := To_Unbounded_String("xcairo");
    Set_Device_Name(To_String(driver));

 -- Initialize plplot.
   Initialize_PLplot;

 -- Create a labelled box to hold the plot.
  Set_Environment(x_Min, x_Max, y_Min, y_Max,
    Justification => Not_Justified,
    Axis_Style    => Linear_Box_Plus);
  Write_Labels
   (X_Label     => "x",
    Y_Label     => "y=100 x#u2#d",
    Title_Label => "Simple PLplot demo of a 2D line plot");

  -- Plot the data that was prepared above.
  Draw_Curve(x, y);

 -- Close PLplot library.
 End_PLplot; --  <-- problem is here. Would like to continue running code below this line.  
  end speedplot;
1 Answers

I solved it by adding a code line Set_Pause(False) to existing code,

 -- Stop waiting for user response
 Set_Pause(False);
 -- Close PLplot library.
  End_PLplot;
Related