51 routines :

*AppleScriptsVanilla*
ascii_to_HTML
Average
Calculator
Calendar
Count_item
cut_text
days_week
EAN13
Encrypt-Decrypt
FactPremier
French_Vanilla_Dotted_Date
French_Vanilla_Dotted_Date2
Hexa_to_Bin
Last_month
list_erase
list_insert
list_replace
ListeDiviseurs
ListePremiers
Minuscule
NombreLong
NombreLong2
NomExtension
num_item
num_month
num_month2
num_week
number_format
number_format2
Paques
PGCD
PGCD2
reverse_string
Roman_to_Arab
round_decimal
search_email
search_replace
search_URL
SepNbre
SepNbre2
snip_text
stat
TauxPermut
TauxTransform
the_left
the_right
TriBulle
TriLineaire
week_and_year
XOR
ZeroDouble

list_replace

Syntaxe

ListReplace(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)

Exemple

ListReplace({"Un", "Deux", "Cinq", "Quatre"}, 3, "Trois")
---> {"Un", "Deux", "Trois", "Quatre"}

Script

on 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

Site scripté avec HyperCard ©1987-1998 Apple Computer, Inc.
Mise à jour le 19/01/10 à 08:45:57