Pages

6 juil. 2008

DataBase (2/5)

on CardList()
if allCards = {} then
display dialog "DataBase empty." with icon 0
return {}
end if
set btn to button returned of (display dialog "DataBase" buttons {"Search...", "Show cards"} default button 2 with icon 1)
set SortBy to choose from list {"Auteur", "Titre", "Sujet", "Edition"} with prompt "Sort by :" cancel button name "Retour"
if SortBy is false then return
set SortBy to item 1 of SortBy
set listeInfos to {}
if btn is "Show cards" then
-- afficher les cartes
repeat with theCard in allCards
set (item5 of theCard) to SortBy
copy (getInfos() of theCard) to the end of listeInfos
end repeat
set cardToDelete to (choose from list listeInfos with prompt "DataBase" OK button name "Delete" cancel button name "Back")
-- effacer une carte
if cardToDelete is not false then
set cardToDelete to item 1 of cardToDelete
ASTID(" • ")
set newCardList to {}
repeat with theCard in allCards
if (text item 1 of cardToDelete item1 of theCard) ¬
or (text item 2 of cardToDelete item2 of theCard) ¬
or (text item 3 of cardToDelete item3 of theCard) ¬
or (text item 4 of cardToDelete item4 of theCard) ¬
then
copy theCard to the end of newCardList
end if
end repeat
ASTID("")
set allCards to newCardList
end if
else -- chercher une carte
set stringToSearch to checkEmptyDialog("Search " & SortBy & " :", "")
repeat with theCard in allCards
set (item5 of theCard) to SortBy
if stringToSearch is in (getInfos2() of theCard) then
copy (getInfos() of theCard) to the end of listeInfos
end if
end repeat
if listeInfos is {} then
display dialog myQuote & stringToSearch & myQuote & "is not found." buttons {"•"} default button 1 with icon 0
else
choose from list listeInfos with prompt "Result :"
end if
end if
end CardList


>>Ouvrir le script dans l'éditeur

Aucun commentaire: