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

x
?
Solved

function to read an array of doubles into a string variable

Posted on 2006-06-28
3
Medium Priority
?
199 Views
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 array.it has just two elements.

e.g myarray(0)=2,34
myarry(1)=34,5

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;
begin
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
end;
end;

urgent help needed

thanks  a lot
0
Comment
Question by:nikolaosk
[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
  • 2
3 Comments
 
LVL 14

Accepted Solution

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

Expert Comment

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

Expert Comment

by:atul_parmar
ID: 17000290
I suggest

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

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

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone 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

In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
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…
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…
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

722 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