# AdaCGI "Screenshot"

Many people like to see ``screenshots,'' but how do you show a screenshot of a CGI interface library? Well, here's my attempt. Below is a demonstration form, followed by the code that created it (the code is available in the file demo.adb). This basically demonstrates how the AdaCGI library can be used to create programs that work with the World Wide Web. The form is not active at this time, so selecting "submit" won't do anything useful. If you want to learn more, see the AdaCGI documentation.

# AdaCGI Demonstration Form

This form demonstrates an Ada 95 binding to CGI.

What is your name:

What topping would you like on your pizza?

1. Pepperoni.
2. Sausage.
3. Anchovies.

Would you like us to call ahead?

  Yes.
  No.

    with CGI, Text_IO; use CGI, Text_IO;

    procedure Demo is
    -- Demonstrate CGI interface.   See the examples at
    -- http://www.ncsa.uiuc.edu/SDG/Software/Mosaic/Docs/fill-out-forms/overview.html

    -- To run this program directly (without an HTTP server), set the
    -- environment variable REQUEST_METHOD to "GET" and the variable
    -- QUERY_STRING to either "" or "name=David&topping=anchovies&callfirst=no".

    begin
      Put_CGI_Header;

      if CGI.Input_Received then
        Put_HTML_Head("Form Result of Demo Ada 95 Binding to CGI");
        Put_HTML_Heading("Form Result of Demo", 1);
        Put_Line("<P>Your name is <I>" & Value("name") & "</I>");
        Put_Line("<P>The keys and values sent were:<P>");
        Put_Variables;
      else
        Put_HTML_Head("Demonstration of Ada 95 Binding to CGI");
        Put_HTML_Heading("AdaCGI Demonstration Form", 1);
        Put_Line("<P>This form demonstrates an Ada 95 binding to CGI.<P>");

        Put_Line("<FORM METHOD=POST>");

        Put_Line("What is your name: <INPUT NAME=""name"" SIZE=40>");

        Put_Line("<P>What topping would you like on your pizza?<P><OL>");
        Put_Line("<LI><INPUT TYPE=""checkbox"" NAME=""topping"" " &
                 "VALUE=""pepperoni"" CHECKED>Pepperoni.");
        Put_Line("<LI><INPUT TYPE=""checkbox"" NAME=""topping"" " &
                 "VALUE=""sausage"">Sausage.");
        Put_Line("<LI><INPUT TYPE=""checkbox"" NAME=""topping"" " &
                 "VALUE=""anchovies"">Anchovies.");
        Put_Line("</OL>");

        Put_Line("Would you like us to call ahead?");
        Put_Line("<DL>");
        Put_Line("<DD> <INPUT TYPE=""radio"" NAME=""callfirst"" VALUE=""yes"" " &
                 "CHECKED> <I>Yes.</I>");
        Put_Line("<DD> <INPUT TYPE=""radio"" NAME=""callfirst"" VALUE=""no""> " &
                 "<I>No.</I>");
        Put_Line("</DL>");

        Put_Line("<P> <INPUT TYPE=""submit""> <INPUT TYPE=""reset""> ");
        Put_Line("</FORM>");
      end if;

      Put_HTML_Tail;
    end Demo;