TEAM-ADA Archives

Team Ada: Ada Programming Language Advocacy

TEAM-ADA@LISTSERV.ACM.ORG

Options: Use Forum View

Use Monospaced Font
Show Text Part by Default
Condense Mail Headers

Message: [<< First] [< Prev] [Next >] [Last >>]
Topic: [<< First] [< Prev] [Next >] [Last >>]
Author: [<< First] [< Prev] [Next >] [Last >>]

Print Reply
Sender:
"Team Ada: Ada Advocacy Issues (83 & 95)" <[log in to unmask]>
X-To:
"Robert C. Leif, Ph.D." <[log in to unmask]>
Date:
Sat, 4 Dec 1999 20:10:47 -0500
Reply-To:
"Richard L. Conn" <[log in to unmask]>
Subject:
From:
"Richard L. Conn" <[log in to unmask]>
Content-Transfer-Encoding:
8bit
In-Reply-To:
Content-Type:
text/plain; charset="Windows-1252"
MIME-Version:
1.0
Parts/Attachments:
text/plain (235 lines)
But why use the GET method as opposed to POST?
The HTML/Ada interface demo on my website uses the
POST method, which sends the enctype date into the
program via stdin, and this eliminates the command
line problem entirely.

See:
  http://unicoi.kennesaw.edu/~rconn/index.html

POST is what I use for all of my websites.  The O'Reilly
books even say that it is preferred.

----------------------------------
Richard Conn, ASE and PAL Manager
http://xenadu.home.mindspring.com/

> -----Original Message-----
> From: Team Ada: Ada Advocacy Issues (83 & 95)
> [mailto:[log in to unmask]]On Behalf Of Robert C. Leif, Ph.D.
> Sent: Saturday, December 04, 1999 5:58 PM
> To: [log in to unmask]
> Subject: Rational A.5 Command Line and HTML
>
>
> From: Bob Leif
> To: Readers of Comp.Lang.Ada and Team-Ada
>
> Disclaimer: Although, I had this problem with an ObjectAda compiler, it is
> neither a bug or a design error. It is an Ada problem and
> therefore relevant
> to these forums.
>
> There is now obvious interest in XML-HTML. In fact, concerning
> the presently
> popular subject, "What the competition looks like". There will
> and probably
> are now more individuals conversant with HTML-XML than any of the present
> programming languages. The tools to build web-pages will have a very large
> market compared to any programming language development system.
>
> One major impediment to interfacing with HTML is in the package
> Ada.Command_Line. The HTML statement,
> <FORM method="Get" action="file:///C:\Ada_Work/com_line.exe"> is a
> reasonable key to this problem. It produces a Command_Line string and does
> invoke the com_line program shown below. Unfortunately,
> Command_Line.Argument_Count does not work with the Command_Line string.
> The Get method concatenates a '?' directly after the program name.
> ----------------------------------------------------------------
> HTML 4.01 Specification
> W3C Proposed Recommendation
> This version:
> http://www.w3.org/TR/1999/PR-html40-19990824
> (plain text [786Kb], gzip’ed tar archive of HTML files [367Kb], a .zip
> archive of
> HTML files [400Kb], gzip’ed Postscript file [740Kb, 387 pages], a PDF file
> [3Mb])
> 17.13.3 Processing form data, Page 247
>
> "However, HTML 4.01 user agents must support
> the established conventions in the following cases:
> If the method is "get" and the action is an HTTP URI, the user agent takes
> the value of action, appends a ‘?’ to it, then appends the form data set
> [p.246] ,encoded using the "application/x-www-form-urlencoded"
> content type
> [p.247] .The user agent then traverses the link to this URI. In this
> scenario, form data are restricted to ASCII codes."
> --------------------------------------------------------------
> I have included a very simple HTML Form (Com_Line_Small) below.
> It produces
> the equivalent of "C:\Ada_Work\com_line.exe?TEST=Hello".
> I proved under Windows that this did not work with a Com_line.Bat batch
> program with the line above as its only text. However, the simple
> insertion
> of a space between the program and the '?' works.
> C:\Ada_Work\com_line.exe ?TEST=Hello
>
> The output of my com_line_small.Bat is as follows:
>
> C:\Ada_Work\com_line_Small.exe?TEST=Hello
> The DOS Window shows: Bad command or file name
>
> However, the program does run when actuated through the HTML
> form; with the
> number of arguments equal to 0.
> C:\Ada_Work\com_line.exe equals the Command_Line
> This Program is Com_Line
>
> The number of arguments =  0
> -----------------------------------------------
>
> C:\Ada_Work>C:\Ada_Work\com_line.exe ?TEST=Hello
> The DOS Window shows that the program has executed
>
> C:\ADA_WORK\COM_LINE.EXE equals the Command_Line
> The number of arguments =  1
> Argument  1 is ?TEST=Hello
>
> I do not believe this is the fault of the ObjectAda compiler.
> The Ada 95 LRM really does not define what a command line is. The
> Rationale
> on page A-32 states:
> A:5 Command Line
> "The package Ada.Command_Line provides an Ada program with a
> simple means of
> accessing any arguments of the command which invoked it. The package also
> enables the program to set a return status. Clearly the interpretation of
> these facilities depends very much on the underlying operating system."
>
> The question is which operating system, Windows or HTTP? The above problem
> is neither a bug nor a design mistake. It is correct for its intended use,
> Windows. However, it does not work with HTTP. I do believe in
> hindsight that
> a function that returns the entire command_line including the program name
> should be added. In view of the significance of HTML-XML, I
> believe that it
> would be worthwhile to modify the Aonix Command_Line or any other Ada
> compiler to work with the output of HTML Get.
>
> Can any of the Ada compilers read and process a command_line that does NOT
> have a space after the name of the executable? If you wish to test this,
> please feel fee to use the Ada program and HTML page below.
>
> ----------------------------------------------------------
> --Robert C. Leif, Ph.D & Ada_Med
>
> --2 Dec. 1999
> --Last update 3 Dec. 1999
>
> --File name Com_Line_Small.Adb
>
> --e-mail [log in to unmask]
>
> with Ada.Text_Io;
> with Ada.Exceptions;
> with Ada.Command_Line;
> with Interfaces.C.Strings;
> procedure Com_Line_Small is
>   Prog_Location : constant String := "Com_Line_Small";
>   package T_Io renames Ada.Text_Io;
>   package Command_Line renames Ada.Command_Line;
>   Num_Args : Natural := 1;
>   --Com_Line_Var : String    := Command_Line.Command_Name;
>   Exit_Char : Character := 'x';
>   ------------------------------------------------------------------
>   --sugested by Randy Brukardt
>   function Get_Command_Line return Interfaces.C.Strings.Chars_Ptr;
>   pragma Import (
>     Convention    => Win32,
>     Entity        => Get_Command_Line,
>     External_Name => "GetCommandLineA");
>   ----------------------------------------------------------------
> begin --Com_Line_Small
>   --then Call:
>   T_Io.Put_Line("Windows way (Randy Brukardt) to get the Command_Line:");
>   T_Io.Put_Line(Interfaces.C.Strings.Value(Get_Command_Line));
>   --returns a string
>
>   Num_Args := Command_Line.Argument_Count;
>   T_Io.Put_Line("");
>   T_Io.Put_Line("Ada way to get the Command_Line:");
>   T_Io.Put_Line(Command_Line.Command_Name);
>   T_Io.Put_Line("This Program is " & Prog_Location);
>   T_Io.Put_Line("");
>   T_Io.Put_Line("The number of arguments = "
>     & Natural'Image(Num_Args));
>
>   if Num_Args >= 1 then
>     for I in 1..Num_Args loop
>       T_Io.Put_Line("Argument "  & Natural'Image(I) & " is "
>         & Command_Line.Argument (Number => I));
>     end loop;
>   end if;
>   T_Io.Put_Line("Ending Com_Line_Small Test program");
>   T_Io.Put_Line("Ending " & Prog_Location);
>   T_Io.Get(Exit_Char);
> exception
>   when O: others  =>
>     T_Io.Put_Line(Ada.Exceptions.Exception_Information (O));
>     T_Io.Put_Line(Ada.Exceptions.Exception_Message (O));
>
> end Com_Line_Small;
> ----------------------------------------------------------------
> Output:
>
> Windows way (Randy Brukardt) to get the Command_Line:
> "C:\Ada_Work\com_line_small.exe"
>
> Ada way to get the Command_Line:
> C:\Ada_Work\com_line_small.exe
> This Program is Com_Line_Small
>
> The number of arguments =  0
> Ending Com_Line_Small Test program
> Ending Com_Line_Small
> ---------------------------------------------------
> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
> <HTML>
>         <HEAD>
>                 <TITLE>
>                         Com_Line_Small Test
>                 </TITLE>
>                 <meta http-equiv="Content-Type" content="text/html;
>                 charset=Latin1">
>
>                 <meta http-equiv="Content-Language" content="en-us">
>
>                 <base  href="C:\Ada_Work">
>         </HEAD>
>         <BODY aLink=#ff0000 background="" bgColor=#ffffff link=#0000ff
>                 text=#000000 vLink=#800080>
>
>                 <!--How do I get the string named test into the-->
>                 <!--command line of HTML_Ada?-->
>                 <OBJECT classid="File:///C:\Ada_Work\com_line_Small.exe"
>                         height=40 width=40 title=Com_Line>
>                         <PARAM NAME="TEST" VALUE="Hello">
>                 </OBJECT>
>
>                 <FORM method="Get"
>                         action="file:///C:\Ada_Work/com_line_Small.exe">
>
>                         <p>
>                         <input TYPE="text" NAME="TEST" SIZE="10"
> MAXLENGTH="15"
>                         VALUE="Hello">
>                         </p>
>
>
>                         <INPUT type=submit value="Submit Form">
>                         <INPUT name=Reset type=reset value="Reset Form">
>
>                 </FORM>
>         </BODY>
> </HTML>

ATOM RSS1 RSS2