Solved

# Procedure~~~~

Posted on 2003-02-24
Medium Priority
186 Views
==================================
uses crt;
procedure proce(var a:array of integer);
begin
a[1]:=1;
end;
var a:array[1..9] of integer;
i:integer;
begin
for i:= 1 to 9 do
a[i]:=999;
proce(a);
end.
==================================
in the above program, it is possible to set a by reference-array in the procedure and process.

but if we set the array be [1..9,1..2] ,then i can't work....just like the program below...
==================================
uses crt;
procedure proce(var a:array of integer);
begin
a[1][1]:=1;
end;
var a:array[1..9,1..2] of integer;
i:integer;
begin
for i:= 1 to 9 do
a[i][1]:=999;
proce(a);
end.
==================================
it says "invalid qualifier" and don't allow the programe to run....can anyone tell me the method to solve this problem???~~~THXXXXXXX
0
Question by:msssyau

LVL 1

Expert Comment

ID: 8007867
ok try to define the array at the begining of the program using
ex.
type arr=array[1..10] of integer;
arrr=array[1..10,1.4] of integer;

an u can't define an array without defining how big it is [1..x]

--3ler
0

Author Comment

ID: 8008311
i know...but it still can't work ~~
0

LVL 1

Expert Comment

ID: 8008924
1:
procedure proce(var a:array[1..9] of integer);
begin
a[1]:=1;
end;
var a:array[1..9] of integer;
i:integer;
begin
for i:= 1 to 9 do
a[i]:=999;
proce(a);
end.

2:
procedure proce(var a:array[1..9,1..2] of integer);
begin
a[1][1]:=1;
end;
var a:array[1..9,1..2] of integer;
i:integer;
begin
for i:= 1 to 9 do
a[i][1]:=999;
proce(a);
end.

this does what you want...

bye
0

LVL 22

Expert Comment

ID: 8009514
You cant use a long-form anonymous type in a parameter declaration.   You have to give the type a name:

type
MyArrayType = array[1..9] of integer;

procedure proce(var a: MyArrayType );

0

LVL 1

Expert Comment

ID: 8010423
o crap forgot that :\$

sorry.

--3ler
0

LVL 101

Expert Comment

ID: 8010722
As 3ler says you will need two procedures.  one for the 1-D array the other for the 2-D array.

Type
OneD = Array[1..9] of integer;
TwoD = Array[1..9,1..2] of integer;

procedure proc1D(var a:OneD );
begin
a[1]:=1;
end;
procedure proc2D(var a:TwoD );
begin
a[1][1]:=1;
end;

var a:OneD ;
b:TwoD;
i,j:integer;

begin
for i:= 1 to 9 do
begin
a[i]:=999;
for j= 1 to 2 do
b[i,j]= 888;
end;
proc1D(a);
proc2D(b);
end.

mlmcc
0

Accepted Solution

COMPILER earned 200 total points
ID: 8011861
hello msssyau,
i did not get you problem quite right. but i think i have a little understanding of it. use this modified version of your code. now this compiler, runs and WORKS. without any errors.

program test;
uses crt;
type
line = array[1..10,1..10] of integer;
var
a:line;
i:integer;

procedure proce(var a:line);
begin
a[1][1]:=1;
end;

begin
for i:= 1 to 9 do
a[i][1]:=999;
proce(a);
end.

enjoy.
COMPILER.
0

## Featured Post

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In my humble opinion (IMHO), TouchDown from Symantec is the best in class for this type of application, but Symantec has end-of-lifed it and although one can keep using it, it will no longer be supported or upgraded.  Time to look for alternatives t…
MySQLTuner is a script written in Perl that allows you to review a MySQL installation quickly and make adjustments to increase performance and stability. The current configuration variables and status data is retrieved and presented in a brief forma…
Enter Foreign and Special Characters Enter characters you can't find on a keyboard using its ASCII code ... and learn how to make a handy reference for yourself using Excel ~ Use these codes in any Windows application! ... whether it is a Micr…
This video tutorial shows you the steps to go through to set up what I believe to be the best email app on the android platform to read Exchange mail.  Get the app on your phone: The first step is to make sure you have the Samsung Email app on your …
###### Suggested Courses
Course of the Month9 days, 9 hours left to enroll