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.3 required=5.0 tests=BAYES_00,INVALID_MSGID autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,aeb3845dd355cf6c X-Google-Attributes: gid103376,public From: "David C. Hoos, Sr." Subject: Re: Sequential_IO Date: 1999/08/19 Message-ID: #1/1 X-Deja-AN: 514642812 Content-Transfer-Encoding: 7bit References: <0a0133f8.48529b21@usw-ex0102-014.remarq.com> <11f733ec.81e1abff@usw-ex0102-014.remarq.com> Content-Type: text/plain; charset="iso-8859-1" X-MimeOLE: Produced By Microsoft MimeOLE V5.00.2314.1300 X-Trace: typ11.nn.bcandid.com 935062759 216.180.14.175 (Thu, 19 Aug 1999 07:39:19 EDT) MIME-Version: 1.0 NNTP-Posting-Date: Thu, 19 Aug 1999 07:39:19 EDT Newsgroups: comp.lang.ada Date: 1999-08-19T00:00:00+00:00 List-Id: Shawn Barber wrote in message news:11f733ec.81e1abff@usw-ex0102-014.remarq.com... > Ok, I forgot this last time. I'm working on NT4 with the > GNAT3.11p compiler. Here are the peices of code which apply > to this problem: > Well... actually, you did _not_ supply all of "the pieces of code which apply to this problem." However, I will make some assumptions (which I will state), and we'll try to get to the bottom of this problem. The fundamental error is that you have passed the NVM_Input_File_Name string to One_Word_IO.Open. Thus, the length of the filename passed is whatever is the length of NVM_Input_File_Name (of which the declaration is one piece of missing code). You should have passed NVM_Input_File_Name (NVM_Input_File_Name'First .. NVM_Input_File_Name'First + Length_Of_NVM_Name - 1) as the actual Name => parameter. You did not supply the identification of Fixed.Move (e.g., by showing your "use" clauses), so I assume this is Ada.Strings.Fixed.Move, -- in which case the filename you passed has some number of trailing spaces. A couple of other technical points: 1. You notice I used the 'First attribute in defining the slice of the string to be passed. This is always good practice when you don't know the bounds of a string -- e.g., when inside a procedure which has a string out mode (or in out mode) parameter. In other words, you _cannot_ assume the first index of every string to be 1. 2. You assumed the equivalence of 'Last and the length of an array. This is only true if the array has a numeric index and the 'First attribute = 1. A better course is to actually use the 'Length attribute when what you want is the length. When you deal with arrays having non-numeric indices, 'Last won't even be a number. When writing a generic unit, for example. in which an array index type is a generic formal parameter of type (<>), whether the array index is numeric is not even known inside the generic unit, so the distinction between index values and numeric attributes such as 'Length is important. One way to have avoided the use of Ada.Strings.Fixed.Move, and eliminated altogether the need for the Get_Command_Line_Parameters procedure, yet providing the better readability of meaningful names for the command line parameters would have been to use a renaming declaration, viz.: NVM_Input_File_Name : String renames Command_Line.Argument (1); Then, you can pass the NVM_Input_File_Name argument directly to Open. I realize this doesn't work with the optional debug file name, and the supplying of a default, but it's just another technique available in Ada.