|
|
Subject:
Programming in Delphi 3: passing the whole array
Category: Computers > Programming Asked by: cyntlhiadiane-ga List Price: $5.00 |
Posted:
07 Oct 2003 12:26 PDT
Expires: 06 Nov 2003 11:26 PST Question ID: 263545 |
I want to pass an array to another procedure in Delphi 3. How do I type the parameter list? var AccountNumber : array [1..100] of variant; AccountType : array[1..100] of variant; // Loop through the array and fill with values // Now call the procedure and pass the array Create_the_Record(AccountNumber,AccountType); It's the parameter list for this last part that I am not typing correctly. |
|
Subject:
Re: Programming in Delphi 3: passing the whole array
Answered By: joseleon-ga on 07 Oct 2003 13:02 PDT Rated: |
Hello, cyntlhiadiane: To pass an array to a procedure it's better to use open array parameters, take a look at this code: procedure MyProcedure(items: array of integer); var i:integer; begin for i:=low(items) to high(items) do begin showmessage(inttostr(items[i])); end; end; procedure TForm1.Button1Click(Sender: TObject); var values: array [1..10] of integer; begin myprocedure([1,2,3]); myprocedure(values); end; In the line: myprocedure([1,2,3]); You are constructing an array of integers to be passed to the function, but in the line: myprocedure(values); you are passing a fixed size array, the key is in the declaration of the parameters here: procedure MyProcedure(items: array of integer); and the way you use them to know the lowest element and the highest element: for i:=low(items) to high(items) do begin Feel free to request any clarification until you understand how they behave. Regards. |
cyntlhiadiane-ga
rated this answer:
and gave an additional tip of:
$1.00
Simple enough for me to follow and comprehend. Exact information that I needed. |
|
There are no comments at this time. |
If you feel that you have found inappropriate content, please let us know by emailing us at answers-support@google.com with the question ID listed above. Thank you. |
Search Google Answers for |
Google Home - Answers FAQ - Terms of Service - Privacy Policy |