?
Solved

Procedure~~~~

Posted on 2003-02-24
7
Medium Priority
?
182 Views
Last Modified: 2010-04-16
==================================
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
Comment
Question by:msssyau
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
7 Comments
 
LVL 1

Expert Comment

by:3ler
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

by:msssyau
ID: 8008311
i know...but it still can't work ~~
0
 
LVL 1

Expert Comment

by:3ler
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
On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

 
LVL 22

Expert Comment

by:grg99
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

by:3ler
ID: 8010423
o crap forgot that :$

sorry.

--3ler
0
 
LVL 101

Expert Comment

by:mlmcc
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

by:
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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

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

This article will show how Aten was able to supply easy management and control for Artear's video walls and wide range display configurations of their newsroom.
Learn how to use the free Acronis True Image app to easily transfer data between iPhones and Android phones.
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…
Suggested Courses

777 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question