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
  • 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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Magic Software info 18 138
how can i search if string exist in array ? 3 63
How to make Sign in, using Clientdataset? 1 28
DBCtrlGrid, Delphi, Scroll 7 24
Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
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…
This video shows how to use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.
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…

766 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