function to read an array of doubles into a string variable

Posted on 2006-06-28
Last Modified: 2010-04-05
hi there experts!!!!!

i have an array. i call it myarray(). this is an array of doubles.this is a static has just two elements.

e.g myarray(0)=2,34

the values of the array are x,y coordinates that represent a point which happens to be the center of a circle.

i need a function in delphi that will loop through the items of this array and will store its values in a string variable

something like this

function readarrayofdoublesinasting (const arr : array of doubles) :String;
var n : integer;
for n := low(arr) to high(arr) do
//here loop through the items of the array
result := (str1,str2)
//where str1 and str2 are the x,y coordinates converted into a comma delimited string

urgent help needed

thanks  a lot
Question by:nikolaosk
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
  • 2
LVL 14

Accepted Solution

Pierre Cornelius earned 250 total points
ID: 17000250
function readarrayofdoublesinasting (const arr : array of doubles) :String;
var n : integer;
  result:= '';
  for n := low(arr) to high(arr)
    do result:= result + FloatToStr(arr[n])+',';
  SetLength(result, length(result)-1); //get rid of last comma
LVL 14

Expert Comment

by:Pierre Cornelius
ID: 17000257
type: "array of doubles"
should be "array of double"
LVL 10

Expert Comment

ID: 17000290
I suggest

  MyPoint = record
    X : Double;
    Y : Double;
  MyResult = record
    Str1, Str2 : String;

function myfunc(myarray : array of MyPoint) : MyResult;
  i : integer;
  For i := low(myarray) to high(myarray) do
    Result.Str1 := Result.Str1 + ',' + FloatToStr(myarray[i].X);
    Result.Str2 := Result.Str2 + ',' + FloatToStr(myarray[i].Y);
  SetLength(Result.Str1, length(Result.Str1)-1);
  SetLength(Result.Str2, length(Result.Str2)-1);

Featured Post

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.

Question has a verified solution.

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

The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
There's a multitude of different network monitoring solutions out there, and you're probably wondering what makes NetCrunch so special. It's completely agentless, but does let you create an agent, if you desire. It offers powerful scalability …
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…
Suggested Courses
Course of the Month10 days, 23 hours left to enroll

631 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