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.8 required=5.0 tests=BAYES_00,INVALID_DATE autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,e947872b350ada8e X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 1994-12-07 20:20:52 PST Newsgroups: comp.lang.ada Path: bga.com!news.sprintlink.net!howland.reston.ans.net!swrinde!sgiblab!uhog.mit.edu!news.mathworks.com!noc.near.net!inmet!dsd!bobduff From: bobduff@dsd.camb.inmet.com (Bob Duff) Subject: Re: GNAT-Problem '+'-operator with Count Message-ID: Sender: news@inmet.camb.inmet.com Organization: Intermetrics, Inc. References: <3bn74o$go5@tucs6.rz.tu-cottbus.de> <2ee30bbc.4a534e4f4445@jsnode.equinox.gen.nz> Date: Wed, 7 Dec 1994 22:54:58 GMT Date: 1994-12-07T22:54:58+00:00 List-Id: In article <2ee30bbc.4a534e4f4445@jsnode.equinox.gen.nz>, Joseph Skinner wrote: >In article <3bn74o$go5@tucs6.rz.tu-cottbus.de>, >Andreas Krohn wrote: >> 148. procedure solve_matrix(source: in matrix;target: in out matrix) is >> 149. x,y,i,j:Count; --akt. Pos. in Matrix >> 150. nachbarn:INTEGER; --Anzahl der Nachbarn jeder Zelle >> 151. a,b:Count; >> 152. >> 153. begin >> 154. for i in feldmin..feldmax loop >> 155. for j in feldmin..feldmax loop >> 156. nachbarn:=0; --neue Zelle 0 setzen >> 157. for x in 1..3 loop --nachbarn ermitteln >> 158. for y in 1..3 loop >> 159. a:=i+x-2; >> | >> invalid operand types for operator "+" >>z >>z 160. b:=j+y-2; >> | >> invalid operand types for operator "+" >>z >>z 161. if source(a,b)=TRUE then nachbarn:=nachbarn+1; >> 162. end if; >> 163. end loop; The program fragment doesn't show enough to be sure. In particular, what type are feldmin and feldmax? This type will be used as the type of i and j. However, x and y are of type Integer, since there's a special rule saying that if the bounds are universal_integer (e.g. literals), then it uses Integer. So if feldmin and feldmax are not of type Integer, then you've got a type mismatch. If that's the problem, try this: for x in Whatever_Type_It_Is range 1..3 loop ... I've gotten into the habit of *always* giving the type name in a for loop, since I think the default-to-Integer rule confuses things, and anyway it makes the code more readable. >At a guess the problem is that the definitions for '+' is not visible to >the program. Check out your with and use statements to make sure that >the definition is visible. > >On the other hand I may be spouting BS and I'm sure that someone else >will tell me if I am. Hard to say. My answer's a guess, too. Anyway, in an extremely polite forum such as this, who would ever accuse anyone of "spouting BS"? Instead, I respectfully submit that my guess is more likely correct than yours. ;-) - Bob -- Bob Duff bobduff@inmet.com Oak Tree Software, Inc. Ada 9X Mapping/Revision Team (Intermetrics, Inc.)