?
Solved

Array and dynamic Array , does Aarry name represent first address?

Posted on 2003-03-21
6
Medium Priority
?
272 Views
Last Modified: 2010-04-04
 declare---function test(Avalue:pchar);  

use:
var
  lack: array[0..19] of char;
  lace: array of char ;
 begin
   test(lack);//sucess;
   setlength(lace,20);
   for Index:=0 to SizeOf(lace) do
     lace[Index]:=#255;
   test(lace);//cannot compile ,,why?
 end;

which one can tell me why?

if i use dynamic array ,how can i realize it ?

thank you in advance !




0
Comment
Question by:bloodbird
[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
6 Comments
 

Author Comment

by:bloodbird
ID: 8180674
up
0
 
LVL 2

Accepted Solution

by:
Kalroth earned 100 total points
ID: 8180707
Hi bloodbird,

I hope this is good enough for you.

(*** CODE ***)

procedure AProc( Value: PChar );
begin
  ShowMessage(Value);
end;

procedure TForm1.Button1Click(Sender: TObject);
var
  lack : array[0..19] of Char;
  lace : array of Char;
  idx : Integer;
begin
  lack := '--------------------';
  AProc(lack);

  SetLength(lace,20);
  for idx := Low(lace) to High(lace) do
    lace[idx] := #$2D;

  AProc(@lace[Low(lace)]); // Pass pointer to first character in array.
end;

(*** /CODE ***)
0
 
LVL 4

Assisted Solution

by:nestorua
nestorua earned 100 total points
ID: 8189687
HI,
You need only do the following: "test(PChar(lace));" instead of "test(lace);", that's all.
Sincerely,
Nestorua.
0
 

Expert Comment

by:CleanupPing
ID: 9316643
bloodbird:
This old question needs to be finalized -- accept an answer, split points, or get a refund.  For information on your options, please click here-> http:/help/closing.jsp#1 
EXPERTS:
Post your closing recommendations!  No comment means you don't care.
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
Michael from AdRem Software outlines event notifications and Automatic Corrective Actions in network monitoring. Automatic Corrective Actions are scripts, which can automatically run upon discovery of a certain undesirable condition in your network.…
In this brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…
Suggested Courses

765 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