|
Prev: Compiler Bug
Next: ObjectAda and Long_Long_Float
From: Charles H. Sampson on 4 Dec 2007 22:34 I've been using GNAT 3.15p for a long time to write DOS-like project utiities to run on my Wintel desktop. I've just come up with a case where I'd like to implement optional parameters. Since the utility is DOS-like, I want to use the DOS form of optional parameters: attached to the name of the command, separated by the '/' character. I don't see how to do this. Command_Line.Argument doesn't accept a value of 0, which I remember as being the substring of the command line from the first non-blank up to the first suceeding blank. The note in A.15 says that Command_Name is the equivalent of argv (0), but in GNAT that's really just the command name, options stripped off. Does anybody have any suggestions? Charlie -- For an email response, insert "0824" between the 'c' and the 's'.
From: Jeffrey Creem on 5 Dec 2007 00:15 Charles H. Sampson wrote: > I've been using GNAT 3.15p for a long time to write DOS-like > project utiities to run on my Wintel desktop. I've just come up with a > case where I'd like to implement optional parameters. Since the utility > is DOS-like, I want to use the DOS form of optional parameters: attached > to the name of the command, separated by the '/' character. > > I don't see how to do this. Command_Line.Argument doesn't accept a > value of 0, which I remember as being the substring of the command line > from the first non-blank up to the first suceeding blank. The note in > A.15 says that Command_Name is the equivalent of argv (0), but in GNAT > that's really just the command name, options stripped off. > > Does anybody have any suggestions? > > Charlie > I don't know what you mean about remembering 0 being the first substring of the command line? Remember from where? ada.command_line.argument(1) certainly returns the first argument to the program regardless of whether it is DOS, Unix, etc. It even appears to handle the degenerate case of no space between the command and the argument. Perhaps I am missing the point of your question. since my_command /option_1 /option_2 and even my_command/option_1 /option_2 work such that ada.command_line.argument(1) returns /option_1 and ada.command_line.argument(2) returns /option_2 But since this is the most obvious thing I assume I am not really understanding your problem.
From: gautier_niouzes on 5 Dec 2007 05:06 On 5 Dez., 04:34, csamp...(a)inetworld.net (Charles H. Sampson) wrote: > I've been using GNAT 3.15p for a long time to write DOS-like > project utiities to run on my Wintel desktop. I've just come up with a > case where I'd like to implement optional parameters. Since the utility > is DOS-like, I want to use the DOS form of optional parameters: attached > to the name of the command, separated by the '/' character. > > I don't see how to do this. Command_Line.Argument doesn't accept a > value of 0, which I remember as being the substring of the command line > from the first non-blank up to the first suceeding blank. The note in > A.15 says that Command_Name is the equivalent of argv (0), but in GNAT > that's really just the command name, options stripped off. > > Does anybody have any suggestions? Yes: try... You will see that the option attached to the command name appears in Argument(1), the OS does the separation for you; nothing specific to GNAT or Ada... If you want an example, here is one: http://homepage.sunrise.ch/mysunrise/gdm/uza_html/unzipada__adb.htm The commands unzipada/t test.zip or unzipada /t test.zip or unzipada -t test.zip work as expected HTH G.
From: Stephen Leake on 5 Dec 2007 05:19 csampson(a)inetworld.net (Charles H. Sampson) writes: > I've been using GNAT 3.15p for a long time to write DOS-like > project utiities to run on my Wintel desktop. I've just come up with a > case where I'd like to implement optional parameters. Since the utility > is DOS-like, I want to use the DOS form of optional parameters: attached > to the name of the command, separated by the '/' character. > > Does anybody have any suggestions? > > Charlie You'll have to post some specific examples, both of actual command lines that you want to handle, and of the Ada code you have tried to use to handle those parameters. I don't use the DOS command line, but I have dealt with several different styles of command-line parameter parsers. -- -- Stephe
From: Charles H. Sampson on 5 Dec 2007 09:51
Well, it look like it's back to the drawing board when I get to the office tomorrow. It never occurred to me that command line parsing would split off the slash-headed options and present them as it presents the "regular" parameters. When I saw that they weren't there, still attached, as part of Command_Name, I thought they were lost and didn't look any further. Thanks to all for straightening me out. To answer Jeffrey's question, I used the word "remember" carefully, not meaning to imply that my memory was faultless. So far in my career, I've only had to write one piece of C code, it was about 10 lines long, and it didn't solve the problem that forced me to try it. Thus it never went into production. So I've got a serious deficiency in hands-on C experience, which I wear as a badge of honor. Charlie -- For an email response, insert "0824" between the 'c' and the 's'. |