Biomodèles/Biomodels
SCILAB 3.0 PAS A PAS
SCILAB 3.0 STEP-TO-STEP

Jacques-Deric Rouault

Laboratoire de Neurobiologie de l'Apprentissage, de la Mémoire et de la Communication. CNRS UMR 8620, Bat. 446, Université Paris-Sud, F91400 Orsay

Orscilab
ORSCILAB

14 LES LISTES TYPEES TLIST
14 THE TYPED LISTS TLIST
14.2 Champs d'une liste / Fields of a list
Version 2.1.2 du 27 janvier 2005 / Version 2.1.2, January 27th 2005
Biomodèles/Biomodels N°1 pp 0x-0y Décembre 2004 December 2004

Retour à la Table générale / Return to the General table
Index général / General index
Passage à la section suivante 14.3 / Next section 14.3

a

b
definefields (tlist)
c
null (tlist)
d
setfield (tlist)
e
getfield (tlist)

Les opérations générales sur les champs des listes de type list s'appliquent également aux champs des listes de type tlist.
The general operations on fields of lists if type list also apply to fields of lists of type tlist.

Cependant, il est fortement recommandé de ne pas utiliser la notation indice de list, en particulier sur le premier champ de la liste, mais les noms définis dans la déclaration de la liste tlist.
However, it is strongly recomended to do not use the index notation of list, in particlar on the first field of the list, but the names defined in the declaration of the list tlist.

// PROGRAMME SPAS140201 : tlist
t=tlist(["nom";"ch1";"ch2";"ch3"],1.1, 1.2, 1.3);
t("ch2"),
t.ch2,
t(3),


Ch14Sc02-Fig01

La fonction definedfields retourne dans un vecteur les rangs des champs définis de la liste.
The function definedfields returns in a vector the ranks of the fields defined.

// PROGRAMME SPAS140202 - tlist  definefields
tt=tlist(["nom";"ch1";"ch2";"ch3"]);
tt.ch2="bibi";
v = definedfields (tt),


Ch14Sc02-Fig02

La fonction null rend un champ indéfini, en fait lui affecte la variable vide []. Ne pas l'appliquer au premier champ !
The function null suppresses the value of a field, in fact affects the null variable [] to the field. Do not apply it to the first field !

// PROGRAMME SPAS140203 - tlist  null
tt=tlist(["nom";"ch1";"ch2";"ch3"], 10, 20, 30);
tt("ch1"),
tt("ch1") = null;
tt("ch1"),
tt(1) = null;
tt("ch1"),


Ch143Sc02-Fig03

La procédure setfield affecte une valeur à un champ d'une liste.
The procedure setfield affects a value to one field of a list.

// PROGRAMME SPAS130204 - tlist  affectation setfield
tt=tlist(["nom";"ch1";"ch2";"ch3"],10, 25, 30);
v = int32(257);
setfield ("ch3",v,tt)
tt.ch3,

Ch14Sc02-Fig04

La procédure getfield extrait  plusieurs champs d'une liste.
The procedure getfield  extracts several fields from a list.

// PROGRAMME SPAS140205 - tlist  extraction multiple getfield
tt=tlist(["nom";"ch1";"ch2";"ch3"],45, 55, 75);
[a, b] = getfield (["ch3", "ch2"],tt),

Ch14Sc02-Fig05

NB : les insertions récursives directes ne sont pas traitées ici. Voir l'article insertion-affectation dans l'Help de Scilab.
Note: the direct recursive insertions are not treated here. Refer to the item insertion-affectation of the Help of Scilab.


Retour à la Table générale / Return to the General table
Index général / General index
Passage à la section suivante 14.3 / Next section 14.3