Pages

6 juil. 2008

DataBase (5/5)

on read_file(thePath)
try
set thePath to thePath as string
set idFile to open for access file thePath
set fileData to read idFile as list
close access idFile
on error errMsg number errNum
close access file thePath
return false
end try
return fileData
end read_file

on write_file(theText, thePath)
try
set thePath to thePath as string
set idFile to open for access file thePath with write permission
write theText to idFile starting at 0 as list
close access id_file
return true
on error
close access file thePath
return false
end try
end write_file

-- Check the entry in a dialog box who must not be empty
on checkEmptyDialog(theText, defaultAnswer)
repeat
set theAnswer to text returned of (display dialog theText default answer defaultAnswer with icon 1)
if (count theAnswer) > 0 then exit repeat
end repeat
return theAnswer
end checkEmptyDialog

-- Return the number of one item in a list
on ItemNumber(theItem, theList)
repeat with NumItem from 1 to count theList
if theItem = item NumItem of theList then return NumItem
end repeat
return 0
end ItemNumber

on ASTID(x) -- set  item delimiter to x
set AppleScript's text item delimiters to x
end ASTID

>>Ouvrir le script dans l'éditeur

Aucun commentaire: