Solved

Tlist and numbers (double)

Posted on 1998-11-08
7
243 Views
Last Modified: 2010-04-04
hi
i know that there ispostibility to assigned numbers to Tlist pointer for example if
Value : integer
put(index, TObject(Value))
but if i want to assigned number from type Double , how can i do it ? simple proccess like put(index(Tobject(value( .... give an Error Msg

10x in advance
Asi
0
Comment
Question by:asi
[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
  • 2
7 Comments
 
LVL 10

Expert Comment

by:viktornet
ID: 1346098
ListName.Add(@DoubleVariable);

Is this what you want???
0
 
LVL 20

Expert Comment

by:Madshi
ID: 1346099
Yes, with Viktor's solution you can add a reference/pointer to your double values. But the original double variable has to remain valid. That means you can't give in local function variables...
If you don't like that you could use something like this (it's an extract from my delphi help file):

procedure TForm1.FormButton1Click(Sender: TObject);
type
  PMyList = ^AList;
  AList = record
    I: Integer;
    C: Char;
  end;
var
  MyList: TList;
  ARecord: PMyList;
  B: Byte;
  Y: Word;
begin
  MyList := TList.Create;
  New(ARecord);
  ARecord^.I := 100;
  ARecord^.C := 'Z';
  MyList.Add(ARecord); {Integer 100 und das Zeichen Z in die Liste einfügen }
  New(ARecord);
  ARecord^.I := 200;
  ARecord^.C := 'X';
  MyList.Add(ARecord); {Integer 200 und Zeichen X in die Liste einfügen }

  { Einträge in Paintbox ausgeben )
  Y := 10;             {Variable für Funktion TextOut }

  for B := 0 to (MyList.Count - 1) do
  begin
    ARecord := MyList.Items[B];
    Canvas.TextOut(10, Y, IntToStr(ARecord^.I)); {Display I}
    Y := Y + 30;  { Y noch einmal inkrementieren }
    Canvas.TextOut(10, Y, ARecord^.C);  { C ausgeben }
    Y := Y + 30;  {Y inkrementieren}
  end;

  { Aufräumen: Listeneinträge und Liste freigeben }
 for B := 0 to (MyList.Count - 1) do
 begin
    ARecord := MyList.Items[B];

    Dispose(ARecord);
 end;
 MyList.Free;
end;

Regards, Madshi.
0
 
LVL 10

Expert Comment

by:viktornet
ID: 1346100
Just remember that TList is for saving pointers...

Cheers,
Viktor
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:asi
ID: 1346101
i know .... the Tlist is for saving pointers but since pointers are 3 bytes they can alos save numbers
integer number is just fine ... and about double .... ?
0
 
LVL 20

Expert Comment

by:Madshi
ID: 1346102
Pointers and integers are 4 byte long, not 3 byte...
Have you looked at my comment???
0
 

Author Comment

by:asi
ID: 1346103
Madshi

ya , convert your comment -> answer
and i'll give u the points
Asi
0
 
LVL 20

Accepted Solution

by:
Madshi earned 10 total points
ID: 1346104
Thanx, asi...   :-)
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

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

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…
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…
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…
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

730 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