Computer Science Canada

Error When Passing Array Into Procedure

Author:  Jeffmagma [ Fri Dec 25, 2015 9:03 pm ]
Post subject:  Error When Passing Array Into Procedure

What is it you are trying to achieve?
I'm trying to pass an array into a procedure, inside an array


What is the problem you are having?
It's giving me the error: Too few subscripts for <arrayName>, even though I'm only trying to pass the higher level of the array


Describe what you have tried to solve this problem
<Answer Here>


Post any relevant code (You may choose to attach the file instead of posting the code if it is too long)
Here is an example program that can be used to replicate the problem

Turing:
var a : array 1 .. 2, 1 .. 2 of int := init (1, 1, 1, 1)
%It doesn't matter if you initialise it or not^
proc hi (b : array 1 .. * of int)
    %do stuff
end hi
hi(a (1))


Please specify what version of Turing you are using
OpenTuring 1.0.1

Author:  Insectoid [ Fri Dec 25, 2015 9:15 pm ]
Post subject:  RE:Error When Passing Array Into Procedure

This is a weird quirk of Turing. You need to declare your 2d array as an array of arrays.

var a : array 1 .. 2 of array 1 .. 2 of int

I think it gets implemented differently if you declare it the way you did.

Author:  Jeffmagma [ Fri Dec 25, 2015 9:26 pm ]
Post subject:  RE:Error When Passing Array Into Procedure

ok thanks so much! i was planning to save my bits, but you've been too helpful...


: