Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Can a function return a Dynamin-Array in Delphi4 ?

Posted on 1999-07-19
5
Medium Priority
?
258 Views
Last Modified: 2010-04-06
Can a function return a Dynamin-Array in Delphi4 ?
If so how?
0
Comment
Question by:cAkk
[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
  • 3
  • 2
5 Comments
 
LVL 20

Accepted Solution

by:
Madshi earned 100 total points
ID: 1389497
No prob...

type TDAString = array of string;

function returnDynStrArr : TDAString;
var i1 : integer;
begin
  SetLength(result,10);
  for i1:=0 to 9 do
    result[i1]:=IntToStr(i1);
end;

The trick is to declare a type for the dynamic array.

Regards, Madshi.
0
 

Author Comment

by:cAkk
ID: 1389498
Why cannot i declear the function as follow:
function returnDynStrArr : Array of string;
                           ^^^^^^^^^^^^^^^
begin
 ....;
end;
0
 
LVL 20

Expert Comment

by:Madshi
ID: 1389499
Would be nice, but doesn't work. Ask Borland why doesn't work, not me...  :-)

Well, it's not too bad to declare a type, is it? It works exactly the same way, just one declaration more...
0
 

Author Comment

by:cAkk
ID: 1389500
ok.
0
 
LVL 20

Expert Comment

by:Madshi
ID: 1389501
Well, that was not so kind giving me only a C grade...  :-(

My answer could not be better - it's Delphi's fault, not mine.
0

Featured Post

Important Lessons on Recovering from Petya

In their most recent webinar, Skyport Systems explores ways to isolate and protect critical databases to keep the core of your company safe from harm.

Question has a verified solution.

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

This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…
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

688 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