From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.5-pre1 (2020-06-20) on ip-172-31-74-118.ec2.internal X-Spam-Level: X-Spam-Status: No, score=-1.9 required=3.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.5-pre1 Date: 17 Apr 92 20:00:20 GMT From: wdl39!mab@ford-wdl1.arpa (Mark A Biggar) Subject: Re: loop indices Message-ID: <1992Apr17.200020.26094@wdl.loral.com> List-Id: In article <70482@ut-emx.uucp> hasan@emx.utexas.edu (David A. Hasan) writes: >Suppose I have a matrix manipulation routine which must >loop over the elements of several different ARRAYs. >My question stems from the observation that unless the >ARRAYs have the same bounds on their indices, I won't >be able to index into all of them using a single FOR-LOOP >index. Consider this example: > DECLARE > TYPE Vector IS ARRAY( Positive RANGE <> ) OF Integer; > p1 : CONSTANT Positive := 21; > p2 : CONSTANT Positive := 51; > size : Natural := 5; > > v1 : Vector( p1 .. (p1+size-1) ); > v2 : Vector( p2 .. (p2+size-1) ); > BEGIN > FOR i IN 1..size LOOP > v2(i) := v1(i); -------------------(!) > END LOOP; > END; >Obviously, I'll have constraint error problems here. >The problem is not solve, either, if I replace the FOR >LOOP by > FOR i IN v2'RANGE LOOP >since the index *still* won't work in . What's wrong with using: FOR i IN 1..size LOOP v2(p1+i-1) := v2(p2+i-1); END LOOP; or FOR i IN v2'RANGE LOOP v2(i) := v1(i-p2+p1); END LOOP; -- Mark Biggar mab@wdl1.wdl.loral.com