Recent

Author Topic: How to add record to Tlist and read record from Tlist  (Read 11247 times)

admfotad

  • Newbie
  • Posts: 2
How to add record to Tlist and read record from Tlist
« on: August 18, 2015, 01:49:42 pm »
Hi

Long time ago i used to code using Delphi. Now i'm trying with Lazarus. How can I add record to a Tlist and read from Tlist record - i can not find out how to do it in Lazarus.
Example in Delphi:

Code: [Select]
type
pls=^tls ;
tls=record
something:string[30];
another:string[30];
password :integer;
end;

Code: [Select]
var
  Form1: TForm1;
  list :Tlist;
  rec: Pls;

Code: [Select]
procedure no_idea_how_to;
var
nw:pls;
begin
//reading from Tlist
new(nw);
nw:=list.Items[z];
nw.something:='it's a hard life';
// and so on

//adding record  to list
new(nw);
(..)
list.add(nw);
end;


but this code is not working in Lazarus. Any ideas ?
Thank you in advance.
« Last Edit: August 18, 2015, 01:51:35 pm by admfotad »

eny

  • Hero Member
  • *****
  • Posts: 1634
Re: How to add record to Tlist and read record from Tlist
« Reply #1 on: August 18, 2015, 02:13:57 pm »
Sure it works.
But you have to show the actual code you are using so we can help you out; not snippets that do not compile.

One hint to start with:
Code: [Select]
nw^.something := 'it''s a hard life';
Or you coulde try the Delphi mode flag:
Code: [Select]
{$MODE DELPHI}
« Last Edit: August 18, 2015, 02:17:37 pm by eny »
All posts based on: Win10 (Win64); Lazarus 2.0.10 'stable' (x64) unless specified otherwise...

Thaddy

  • Hero Member
  • *****
  • Posts: 14373
  • Sensorship about opinions does not belong here.
Re: How to add record to Tlist and read record from Tlist
« Reply #2 on: August 18, 2015, 02:22:20 pm »
In Delphi mode that simply works. Free Pascal is not Delphi. If you want it to behave like Delphi you have to tell it so.
Object Pascal programmers should get rid of their "component fetish" especially with the non-visuals.

admfotad

  • Newbie
  • Posts: 2
Re: How to add record to Tlist and read record from Tlist
« Reply #3 on: August 18, 2015, 02:31:26 pm »
Sure it works.
But you have to show the actual code you are using so we can help you out; not snippets that do not compile.

One hint to start with:
Code: [Select]
nw^.something := 'it''s a hard life';
Or you coulde try the Delphi mode flag:
Code: [Select]
{$MODE DELPHI}


Thanks for quick answer, it's allready working well with eny's hint

Regards

 

TinyPortal © 2005-2018