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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Create a path if not exists 7 108
Adoquery sql  left join does not work 25 104
Dev express lookupcombo 3 44
Delphi Seattle StructureView color 1 21
A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…
In an interesting question ( here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…

735 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