Comparaison des versions

Légende

  • Ces lignes ont été ajoutées. Ce mot a été ajouté.
  • Ces lignes ont été supprimées. Ce mot a été supprimé.
  • La mise en forme a été modifiée.

...

Une liste peut être declarée avec des variables , ou en référence à une entité logique , ou en reference to à une autre liste , ou encore une combination de ces éléments .

Bloc de code
/* ___ Déclarations de lilistes _______________________________________________________________ 
LISTE LST_EXAMPLE    ELT_ONE ELT_TWO ELT_2205											/* définir une liste avec des éléments simples définis auparavant, ici les variables ELT_ONE, ELT_TWO et ELT_2205
LISTE LST_ART_ALC_2  *REF_MLD(HL_ART_ALCOOL)											/* définir une liste avec toutes les propriétés de l'entité HL_ART_ALCOOL
LISTE LST_ART_ALC_3  *REF_MLD(HL_ART_ALCOOL) *REF_MLD(HL_ART_LANGUE) 					/* définir une liste avec toutes les propriétés des entités HL_ART_ALCOOL et HL_ART_LANGUE
LISTE LST_ART_ALC_4  *REF_MLD(HL_ART_ALCOOL) *REF_MLD(HL_ART_LANGUE) w_COD_ARTICLE_1	/* définir une liste avec toutes les propriétés des entités HL_ART_ALCOOL et the HL_ART_LANGUE, plus la variable w_COD_ARTICLE_1
LISTE LST_ART_ALC_5  *REF_L(LST_ART_ALC_4) ELT_2205		                           		/* définir une liste avec toutes les propiétés de la liste LST_ART_ALC_4, plus la variable ELT_2205

...

On peut également utililser LIRE_D_ELT (lire le denier élément) and LIRE_AR_ELT (lire l'élément précédent).

Bloc de code
/* ___ Liste Lists- usageutilisations _______________________________________________________________
READ_F 
LIRE_P_ELT LST_EXAMPLE 							/* welecture trydu topremier readélément thede firstla element of the list (if it exists)
DO_WHILEliste (s'il existe)
TANT_QUE &CODE_LST(LST_EXAMPLE) = *NORMAL		/* didest-ce theque lastl'opération operationa on the list end successfully réussi ?
  ...
  READLIRE_NXAV_ELT LST_EXAMPLE						/* trylecture tode readl'élément the next element of the list
REDO

READ_Lsuivant (s'il existe)
REFAIRE

LIRE_D_ELT LST_EXAMPLE 							/* welecture trydu todernier readélément thede lastla element of the list (if it exists)
DO_WHILEliste (s'il existe) 
TANT_QUE &CODE_LST(LST_EXAMPLE) = *NORMAL		/* did the last operation on the list end successfully ?
  ...
  READLIRE_PRAR_ELT LST_EXAMPLE						/* trylecture tode readl'élément the next element of the listprécédent (s'il existe)
REDO

3 -

...

Parcourir une liste en utilisant des indexs

Afin de parcourir une liste pour chercher un élément (or à parti d'un élément), on peut crééer et ustiliser des listes indexées (avec l'instruction INDEX_LIST).

On pourra alors utiliser les instructions LIRE_ELT (pour lire un élément) ou LIRE_P_ELT (pour accéder au premier élément supérieur ou égal à la valeur de l'

...

To parse a list to find an element (or from an element), we can create and use list indexes (with the LIST_INDEX instruction).Then we will be allowed to use READ_ELT (to read an element) or READ_F_ELEMENT (to go to the first element greater or equal to the value of the index).

Bloc de code
/* ___ Déclarations Listsde declarationslistes _______________________________________________________________
LIST
LISTE       LST_EXAMPLE    ELT_ONE ELT_TWO ELT_2205		/* definingdéfinit aune listliste withavec single3 elements"colonnes" definedprécédemment previouslydéclarés, ici les herevariables ELT_ONE, ELT_TWO andet ELT_2205 variables
LISTINDEX_INDEXLISTE MY_INDEX       LST_EXAMPLE ELT_2205			    /* we define thedéfinit l'index MY_INDEX indexqui thatva willindexer indexla theliste LST_EXAMPLE listsur onla thecolonne ELT_2205 column

/* ___ ListsListe - usageutilisations _______________________________________________________________ 
ELT_2205 = 67											/* wevaleur setqu'on theveut valueatteindre wedans want to reach in the list
READla liste
LIRE_ELT MY_INDEX 										/* weon tryessaie tode readlire thele firstpremier elementélément ofde thela list withqui contiendrait thela valuevaleur 67 indans thela columncolonne ELT_2205
IFSI &CODE_LST(MY_INDEX) = *NORMAL						/* did the find the element with the searched value a-t-on trouvé ?
  ...													/* ifsi yesoui, thenalors weon areest onpositionné thesur elementl'élément, weon can use itpeut l'utiliser, modifyle itmodifier orou deletele itsupprimer.
ENDFIN

ELT_2205 = 67
READLIRE_FP_ELT MY_INDEX 									/* readslire thele firstpremier elementélément thatdont isla greatervaleur orde equal to the column value of the index
DO_WHILEcolonne LT_2205 est supérieure ou égale à la valeur positionnée pour l'index (67)
TANT_QUE &CODE_LST(MY_INDEX) = *NORMAL
  ...
  READLIRE_NXAV_ELT MY_INDEX
REDOREFAIRE

DELETEDETRUIRE_INDEX MY_INDEX									/* deletesupprimer the l'index ifsi it'son notne neededl'utilise anymoreplus, topour freelibérer thela memorymémoire used by the index

An index is first created when the first read is done on on it (with READ_ELT or READ_F_ELT).

qu'il utilise

Un index est créé au moment où on l'utilise pour la première fois en lecture.

Quand un index n'a plus d'utiliité dans le programme, on peut le détruire it (pour libérer de la mémoire) avec l'instruction DELETE_INDEX.When an index is not needed more, we can destroy it (to release memory) with the  DELETE_INDEX instruction

4 - Operations on lists

To delete a list , we can use the CLEAR_LST instruction,

...