[DEV][AppleScript] problème de récupération de variable
Bonjour,
Je viens de commencer l'utilisation d'apple script, j'ai utilisé le super tuto à la découverte d'apple script qui est très bien fait par contre j'ai un petit souci dans mon script, à la fin je ne n'arrive pas a récupérer le nom d'un artiste pour le modifier.
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58
| tell application "iTunes"
set morceaux to selection
if morceaux is {} then
display dialog "vous devez sélectionner des morceaux!" with icon caution buttons ("ok")
return
end if
set champs to {"Nom", "Artiste", "Album"}
set champ to (choose from list champs with prompt "quel champ editer ?" default items "Nom") as string
if champ is "false" then
display dialog "Abandon du script!" buttons {"ok"} with icon note giving up after 15
return
end if
set choix to display dialog "Combien de caractères supprimer dans \"" & champ & "\"? " default answer "2" buttons {"Au début", "A la fin", "Annuler"}
--nb de caractère a couper
set longueur to text returned of choix
-- début ou en fin
set ou to button returned of choix
repeat
try
set longueur to (longueur as integer) + 1
exit repeat
on error
display dialog "Vous devez entrer une valeur numérique !" with icon caution buttons {"ok"}
set choix to display dialog "Combien de caractères supprimer ?" default answer "2" buttons {"ok"}
set longueur to text returned of choix
end try
end repeat
if ou is "Au début" then
set idx1 to longueur
set idx2 to -1
else
set idx1 to 1
set idx2 to -longueur
end if
if champ is item 1 of champs then
try
set name to text idx1 thru idx2 of (get name)
end try
else if champ is item 2 of champs then
try
set artist to text idx1 thru idx2 of (get artist)
end try
else
try
set album to text idx1 thru idx2 of (get album)
end try
end if
end tell |
si quelqu'un pourrai m'éclairer je vous en remercie