From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,XPRIO autolearn=ham autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,CP1252 X-Google-Thread: 103376,503ed97855902ab,start X-Google-Attributes: gid103376,public From: "Robert C. Leif, Ph.D." Subject: Rational A.5 Command Line and HTML Date: 1999/12/04 Message-ID: X-Deja-AN: 557161724 Content-Transfer-Encoding: 8bit To: "Comp. Lang. Ada" , "Team-Ada" X-Priority: 3 (Normal) Content-Type: text/plain; charset="Windows-1252" X-MimeOLE: Produced By Microsoft MimeOLE V5.00.2314.1300 X-Complaints-To: usenet@enst.fr Importance: Normal X-Trace: menuisier.enst.fr 944464779 27433 137.194.161.2 (6 Dec 1999 07:19:39 GMT) Organization: ENST, France X-BeenThere: comp.lang.ada@ada.eu.org X-MSMail-Priority: Normal Mime-Version: 1.0 Reply-To: comp.lang.ada@ada.eu.org NNTP-Posting-Date: 6 Dec 1999 07:19:39 GMT Newsgroups: comp.lang.ada Date: 1999-12-06T07:19:39+00:00 List-Id: 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,
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 rleif@rleif.com 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 --------------------------------------------------- Com_Line_Small Test