?
Solved

Procedure~~~~

Posted on 2003-02-24
7
Medium Priority
?
186 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
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
Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
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

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

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…
Article by: Tammy
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

609 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