Recent

Author Topic: Type records  (Read 785 times)

asiocapensis

  • Newbie
  • Posts: 2
Type records
« on: November 20, 2019, 01:15:10 pm »
In my project i want to use a general variable that is like

planp : record
  nr : array [0 .. 20] of real;
  ihus : array [0 .. 20] of real;
end; 

The idea is to use it as
planp.nr[1]:=7.1;
planp.ihus[1]=10.3;

this done in an event in a form

I also want to use this kind of structure withing a stucture like

george : record
    apple : planp;
    banana : real;
end

In what part of a project shall i put the record structure to make it all over visible?

What else am I doing wrong in this?

Fungus

  • Sr. Member
  • ****
  • Posts: 353
Re: Type records
« Reply #1 on: November 20, 2019, 01:26:29 pm »
Put it in a unit and use that unit in all the files where the records are to be used.

Code: Pascal  [Select][+][-]
  1. unit SomeUnit;
  2.  
  3. interface
  4.  
  5. uses units_to_use;
  6.  
  7. type
  8.  
  9.   record1 = record
  10.     field1: datatype;
  11.     field2: datatype;
  12.   end;
  13.  
  14.   record2 = record
  15.     field1: record1;
  16.     field2: real;
  17.   end;
  18.  
  19. //Function and procedure prototypes
  20.  
  21. implementation
  22.  
  23. //Function and procedure implementations
  24.  
  25. end.

EDIT: Replaced ":" with "=", brainfart..
« Last Edit: November 20, 2019, 01:52:22 pm by Fungus »

asiocapensis

  • Newbie
  • Posts: 2
Re: Type records
« Reply #2 on: November 20, 2019, 01:41:40 pm »
When i do like that i get a compiler error at line 15

Fungus

  • Sr. Member
  • ****
  • Posts: 353
Re: Type records
« Reply #3 on: November 20, 2019, 01:52:47 pm »
When i do like that i get a compiler error at line 15

I have edited my previous post.

mangakissa

  • Hero Member
  • *****
  • Posts: 1131
Re: Type records
« Reply #4 on: November 21, 2019, 09:01:00 pm »
I shall not creating 'uses units_to_use'but calling unit 'SomeUnit' to each unit that uses the records.

The reference is 'SomeUnit'.
Lazarus 2.06 (64b) / FPC 3.0.4 / Windows 10
stucked on Delphi 10.3.1

 

TinyPortal © 2005-2018