ENREGISTREMENT
- Introduction
- Définition d’Enregistrement & Exemple
- Déclaration du type et des variables Enregistrement
- Accès aux champs d’un enregistrement
- Instruction WITH
- List d’enregistrements
Réalisé par : OUZEGGANE Redouane
Département de Technologie
Faculté de Technologie – Université A.Mira, Bejaia
Année Universitaire 2015/2016
INTRODUCTION
Un étudiant peut être caractérisé par :
N° d’inscription (Matricule)
Nom
Prénom
Comment
CommentDate faire
regrouper pour représenter
plusieurs données une
de Naissance
classe dedans25 Lieu
étudiant
une seule? information
de Naissance
(Structure)
25unx étudiant ?
Pour représenter 5 Variables à déclarer
il faut déclarer !!!
5 variables
Tableau de Nom,
N_Inscription undeautre
: chaîne de prénom, …
Caractères
!!! nom Type Enregistrement
: chaîne
prenom : chaîne
Date_naiss : chaîne
Lieu_naiss : chaîne
1ère Année Technologie Année Universitaire
01/15 : 2015/2016
DÉFINITION D’UN ENREGISTREMENT
Enregistrement
Structure complexe de données
Englobe un ensemble de données
Ces données sont de type différents (Types Hétérogènes)
Chaque donnée d’un enregistrement est dite : champ
Similitude avec les tableaux à une dimension (Vecteur) :
Chaque case dans le tableau champ
Case : indice Champ : identificateur
Cases sont du même type Champs hétérogènes
1ère Année Technologie Année Universitaire
02/15 : 2015/2016
DÉFINITION D’UN ENREGISTREMENT
Enregistrement
Une structure complexe de données permettant de représenter un
ensemble données, dites champs, de différents types (de Types
Hétérogènes)
Un Enregistrement peut être vu comme un vecteur, où chaque case du vecteur est
considéré comme un champ dans un enregistrement :
• une case utilise un indice, un champs utilise un identificateur ;
• les cases sont du même type, et les champs sont de types hétérogène.
1ère Année Technologie Année Universitaire
03/15 : 2015/2016
DÉFINITION D’UN ENREGISTREMENT
Enregistrement
Champ 1 Champ 2 Champ 3 ....
Espace Mémoire
différent
1ère Année Technologie Année Universitaire
04/15 : 2015/2016
EXEMPLE
Produit
Champs Types
- Désignation - Chaîne de caractères
- Référence - Chaîne de caractères
- Quantité en Stock - Entier
- Prix Unitaire - Réel
Etudiant
Champs Types
- N_inscription - Chaîne de caractères
- Nom_Prenom - Chaîne de caractères
- Date_Naiss - Chaîne de caractères
- Moy_BAC - Réel
1ère Année Technologie Année Universitaire
05/15 : 2015/2016
DÉCLARATION
Déclaration d’un Type - Syntaxe
En Algorithme
Type
<id_Enreg> = Enregistrement
<id_champ1> : <type_1>
<id_champ2> : <type_2>
. . . .
<id_champN> : <type_N>
Fin
En Pascal
Type
<id_Enreg> = Record
<id_champ1> : <type_1>;
<id_champ2> : <type_2>;
…..
<id_champN> : <type_N>;
End;
1ère Année Technologie Année Universitaire
06/15 : 2015/2016
DÉCLARATION
Déclaration d’un Type - Exemple
En Algorithme
Type
Produit = Enregistrement
Designation : Chaîne
Reference : Chaîne
Quantite : Entier
Prix_Unitaire : Réel
Fin
En Pascal
Type
Produit = Record
Designation : String[50];
Reference : String[15];
Quantite : Integer;
Prix_Unitaire : Real;
End;
1ère Année Technologie Année Universitaire
07/15 : 2015/2016
DÉCLARATION
Déclaration d’une Variable
En Algorithme
Variables
<id_variable> : <id_enregistrement>
En Pascal
Var
<id_variable> : <id_enregistrement>;
Déclaration d’une Variable - Exemple
En Algorithme En Pascal
Variables Var
P : Produit P : Produit;
1ère Année Technologie Année Universitaire
08/15 : 2015/2016
ACCÈS AUX CHAMPS
Accès aux Champs - Exemple
En Algorithme
<id_var_Enreg>.<id_champs>
En Pascal
<id_var_Enreg>.<id_champ>
Accès aux Champs - Exemple
En Algorithme
P.Designation Imprimante
P.Prix_Unitaire 9500.00
En Pascal
p.Designation := Imprimante;
P.Prix_Unitaire := 9500.00;
1ère Année Technologie Année Universitaire
09/15 : 2015/2016
ACCÈS AUX CHAMPS AVEC WITH
Problème de répétition
En Algorithme
<instruction <id_var_enreg>.<id_champ1>>
<instruction <id_var_enreg>.<id_champ2>>
...
<instruction <id_var_enreg>.<id_champN>>
En Pascal
<instruction <id_var_enreg>.<id_champ1>>;
<instruction <id_var_enreg>.<id_champ2>>;
...
<instruction <id_var_enreg>.<id_champN>>;
Comment éviter de répéter l’identificateur de la
variable enregistrement ?
1ère Année Technologie Année Universitaire
10/15 : 2015/2016
ACCÈS AUX CHAMPS AVEC WITH
Instruction With- Syntaxe
En Algorithme
Avec <id_var_enreg> Faire
<instruction <id_champ1>>
<instruction <id_champ2>>
...
<instruction <id_champN>>
Fin-Avec
En Pascal
with <id_var_enreg> do
begin
<instruction <id_champ1>>;
<instruction <id_champ2>>;
...
<instruction <id_champN>>;
end;
1ère Année Technologie Année Universitaire
11/15 : 2015/2016
ACCÈS AUX CHAMPS AVEC WITH
Instruction With- Exemple
En Algorithme
P.Designation Imprimante
P.Reference IMP001_05
P.Quantite 7
P.Prix_Unitaire 9500.00
En Pascal
P.Designation := Imprimante;
P.Reference := IMP001_05;
P.Quantite := 7;
P.Prix_Unitaire := 9500.00;
1ère Année Technologie Année Universitaire
12/15 : 2015/2016
ACCÈS AUX CHAMPS AVEC WITH
Instruction With- Exemple
En Algorithme
Avec P Faire
Designation Imprimante
Reference IMP001_05
Quantite 7
Prix_Unitaire 9500.00
Fin-Avec
En Pascal
with P do
begin
Designation := Imprimante;
Reference := IMP001_05;
Quantite := 7;
Prix_Unitaire := 9500.00;
end;
1ère Année Technologie Année Universitaire
13/15 : 2015/2016
RÉSUMÉ
Un enregistrement est un type de données complexes qui
permet de regrouper un ensemble de données, dites champs,
dans une même entité ou structure.
Les champs d’un enregistrement peuvent être de type
différents. On dit que les champs sont de types hétérogènes.
Pour éviter de répéter le identificateur d’une variable
enregistrement, lors d’accès aux champs de cette variable, nous
utilisons l’instruction WITH.
1ère Année Technologie Année Universitaire
14/15 : 2015/2016
DÉMONSTRATION
Ecrire un programme PASCAL qui permet de
déclarer le type Produit vu dans ce cours?
Compléter le programme pour lire un seul
enregistrement ?
Comment faire pour lire N enregistrement ?
1ère Année Technologie Année Universitaire
15/15 : 2015/2016