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=-0.9 required=5.0 tests=BAYES_00,FORGED_GMAIL_RCVD, FREEMAIL_FROM autolearn=no autolearn_force=no version=3.4.4 X-Google-Thread: 103376,49ddd117f54c2d,start X-Google-Attributes: gid103376,public X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!postnews.google.com!g49g2000cwa.googlegroups.com!not-for-mail From: mike.martelli@gmail.com Newsgroups: comp.lang.ada Subject: New to Ada, noticing something strange. Date: 29 Sep 2005 10:20:42 -0700 Organization: http://groups.google.com Message-ID: <1128014442.343461.185800@g49g2000cwa.googlegroups.com> NNTP-Posting-Host: 166.77.6.4 Mime-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" X-Trace: posting.google.com 1128014447 28907 127.0.0.1 (29 Sep 2005 17:20:47 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Thu, 29 Sep 2005 17:20:47 +0000 (UTC) User-Agent: G2/0.2 X-HTTP-UserAgent: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.7.10) Gecko/20050716 Firefox/1.0.6 (ax),gzip(gfe),gzip(gfe) Complaints-To: groups-abuse@google.com Injection-Info: g49g2000cwa.googlegroups.com; posting-host=166.77.6.4; posting-account=2Kx9Xw0AAADNctxkDMILsC-KEZIDvZ3h Xref: g2news1.google.com comp.lang.ada:5272 Date: 2005-09-29T10:20:42-07:00 List-Id: Here is an excerpt of my code. Every function works as it should, the program is set up correct, and the correct values are being passed to all functions. The idea of the program is perform arithmetic on arbitrarily long integers that are inputted as strings using the paper and pencil approach (digit by digit, from right from right to left, with a carry digit). The user will enter a base, operand1, and operan2 via command line arguments. (if you need more explanation let me know). with Ada.Text_IO; with Ada.Integer_Text_IO; with Ada.Command_Line; with Ada.Strings.Unbounded; with Ada.Characters.Handling; use Ada.Text_IO; use Ada.Integer_Text_IO; use Ada.Command_Line; use Ada.Strings.Unbounded; procedure BigInts is ... charMap: array (Character) of Integer; charMap('0') := 0; charMap('1') := 1; charMap('2') := 2; ... charMap('E') := 14; charMap('F') := 15; function C2C(strChar: String) return Character is begin Put_Line(strChar); case Integer'Value(strChar) is when 10 => return 'A'; when 11 => return 'B'; when 12 => return 'C'; when 13 => return 'D'; when 14 => return 'E'; when 15 => return 'F'; when others => return strChar(1); end case; end C2C; function AddDigits(op1, op2: Character) return Character is begin charDigit:=C2C(Integer'Image(charMap(op1)+charMap(op2)+carry)); Put("Print1: "); Put(C2C(Integer'Image(charMap(op1)+charMap(op2)+carry))); if(charMap(op1)+charMap(op2)+carry)>(charMap(charBase)-1) then Put_Line("here1: "); --Set the digit to the highest possible values charDigit:=C2C(Integer'Image(charMap(charBase)-1)); --carry is all of the rest carry:=(charMap(op1)+charMap(op2)+carry)-(charMap(charBase)-1); else Put_Line("here2: "); carry:=0; --there is no carry end if; Put("Digit: "); Put(charDigit); New_Line; Put("Carry: "); Put(carry); New_Line; return charDigit; end AddDigits; ... end BigInts; (I removed some extra white space so it would align better in the post) I have some Put()/Put_Line() statements in AddDigits() for debugging purposes. The problem is in Convert2Character(), nothing was ever being returned by that function. I added the Put_Line(strChar) to make sure a correct value was being passed to it. Once I added that Put_Line() a value was being returned by the function and it was correct. It seems that a Put_Line() is needed for some reason or it does not do what it is supposed to do.