Difference between revisions of "Record/es"

From Lazarus wiki
Jump to navigationJump to search
Line 1: Line 1:
 
{{Record}}[[category:Español]][[category:Castellano]]
 
{{Record}}[[category:Español]][[category:Castellano]]
A highly structured data type in [[Pascal]] .  
+
   Un tipo de datos altamente estructurado en [[Pascal]] .  
  
While simple data structures such as arrays or sets consist of elements all of the same type, a record can consist of a number of elements of different types, and can take on a huge complexity. Each separate part of a record is referred to as a Field.
+
   Mientras las estructuras simples cómo matrices y conjuntos consisten en agrupaciones de elementos del mismo tipo, un registro consiste en una agrupación de elementos de tipos diversos y puede ser muy complejo. Cada una de las distintas partes de un registro se denomina Campo.
  
Some examples of records:
+
   Algunos ejemplos de registros:
  
Type
+
<delphi> Type
   ExampleRecord = Record
+
   RegistroEjemplo = Record
                     Values: array [1..200] of real;
+
                     Valores: array [1..200] of real;
                     NumValues: Integer; { holds the actual number of points in the array }
+
                     CuantosValores: Integer; { el número real de puntos en la matriz }
                     Average: Real { holds the average or mean of the values in the array }
+
                     Media: Real { el promedio o media de los valores en la matriz }
 
                   End;
 
                   End;
  
   Member = Record
+
   Socio = Record
               Firstname, Surname : string;
+
               Nombre, Apellidos : string;
               Address: array [1..3] of string;
+
               Direccion: array [1..3] of string;
               Phone : Integer;
+
               Telefono : Integer;
               Birthdate: TDateTime;
+
               FechaNacimiento: TDateTime;
               PaidCurrentSubscription: Boolean
+
               CuotasAlDia: Boolean
             End;
+
             End;</delphi>
  
A record is treated by the program as a single entity, and for example a whole record can be copied (provided the copy is of the same type) thus:
+
&nbsp;&nbsp;&nbsp;A record is treated by the program as a single entity, and for example a whole record can be copied (provided the copy is of the same type) thus:
  
Var a, b : Member;
+
<delphi> Var a, b : Member;
 
  Begin
 
  Begin
 
   { assign values to the fields in Record a }
 
   { assign values to the fields in Record a }
Line 29: Line 29:
 
   ...
 
   ...
 
   b := a
 
   b := a
  End;
+
  End;</delphi>
  
Individual fields are accessed by placing a dot between the record name and the field name thus:
+
&nbsp;&nbsp;&nbsp;Individual fields are accessed by placing a dot between the record name and the field name thus:
  a.firstname := 'George';
+
<delphi>  a.firstname := 'George';
 
   a.surname := 'Petersen';
 
   a.surname := 'Petersen';
 
   a.phone := 789534;
 
   a.phone := 789534;
   a.PaidCurrentSubscription := TRUE;
+
   a.PaidCurrentSubscription := TRUE;</delphi>
  
Alternatively, the whole series of fields can be made available together using the WITH construct:
+
&nbsp;&nbsp;&nbsp;Alternatively, the whole series of fields can be made available together using the WITH construct:
with a  
+
<delphi> with a  
 
   do
 
   do
 
   begin
 
   begin
Line 45: Line 45:
 
     phone := 789534;
 
     phone := 789534;
 
     PaidCurrentSubscription := TRUE
 
     PaidCurrentSubscription := TRUE
   end;
+
   end;</delphi>
  
  
Records are widely used in Pascal, to group data items together logically.
+
&nbsp;&nbsp;&nbsp;Records are widely used in Pascal, to group data items together logically.

Revision as of 01:44, 22 July 2008

Deutsch (de) English (en) español (es) suomi (fi) français (fr) magyar (hu) polski (pl) português (pt) русский (ru)
   Un tipo de datos altamente estructurado en Pascal .

   Mientras las estructuras simples cómo matrices y conjuntos consisten en agrupaciones de elementos del mismo tipo, un registro consiste en una agrupación de elementos de tipos diversos y puede ser muy complejo. Cada una de las distintas partes de un registro se denomina Campo.

   Algunos ejemplos de registros:

<delphi> Type

  RegistroEjemplo = Record
                    Valores: array [1..200] of real;
                    CuantosValores: Integer; { el número real de puntos en la matriz }
                    Media: Real { el promedio o media de los valores en la matriz }
                  End;
  Socio = Record
             Nombre, Apellidos : string;
             Direccion: array [1..3] of string;
             Telefono : Integer;
             FechaNacimiento: TDateTime;
             CuotasAlDia: Boolean
           End;</delphi>

   A record is treated by the program as a single entity, and for example a whole record can be copied (provided the copy is of the same type) thus:

<delphi> Var a, b : Member;

Begin
  { assign values to the fields in Record a }
  ...
  ...
  b := a
End;</delphi>

   Individual fields are accessed by placing a dot between the record name and the field name thus: <delphi> a.firstname := 'George';

 a.surname := 'Petersen';
 a.phone := 789534;
 a.PaidCurrentSubscription := TRUE;</delphi>

   Alternatively, the whole series of fields can be made available together using the WITH construct: <delphi> with a

  do
  begin
    firstname := 'George';
    surname := 'Petersen';
    phone := 789534;
    PaidCurrentSubscription := TRUE
  end;</delphi>


   Records are widely used in Pascal, to group data items together logically.