list_replaceSyntaxeListReplace(Lst, Nro, Itm) Remplace un élément précis par un autre dans une liste. Trois paramètres : 1. La liste à modifier (Lst) au format liste. 2. Le numéro de l'élément à remplacer (Nro) au format nombre. 3. L' élément de remplacement (Itm) (tous formats) Le résultat est au format liste. Par Fredo d;o) ExempleListReplace({"Un", "Deux", "Cinq", "Quatre"}, 3, "Trois") ---> {"Un", "Deux", "Trois", "Quatre"} Scripton ListReplace(Lst, Nro, Itm) set NbrItms to (length of Lst) if (NbrItms is 0) or (Nro is 0) then return Lst if (Nro = NbrItms) then return ((items 1 thru -2 of Lst) & Itm) as list else if (Nro = -NbrItms) then return ({Itm} & (items 2 thru -1 of Lst)) as list else if (Nro < NbrItms) and (Nro > -NbrItms) then return (items 1 thru (Nro - 1) of Lst) & ¬ Itm & (items (Nro + 1) thru -1 of Lst) else return Lst end if end ListReplace
|