Perché "se esiste" fallisce con un falso positivo?

2

Il file "Test.file" nel codice sottostante non esiste, eppure lo script restituisce true. Perché? Cosa sto sbagliando?

set thePath to (path to application support folder from user domain)

if exists thePath & "Test.file" then
display dialog "The file was found!" buttons {"OK"} default button 1
else
display dialog "The was file wasn't found." buttons {"OK"} default button 1
end if
    
posta rogerFernand 03.12.2013 - 04:46
fonte

1 risposta

2

È necessario fare riferimento a un file per il corretto funzionamento del test.

set thePath to path to application support folder from user domain
tell application "System Events" to exists file ((thePath as text) & "Test.file")

Con il condizionale:

set thePath to path to application support folder from user domain
tell application "System Events" to exists file ((thePath as text) & "Test.file")
if the result then
    display dialog "The file was found!" buttons {"OK"} default button 1
else
    display dialog "The was file wasn't found." buttons {"OK"} default button 1
end if
    
risposta data 03.12.2013 - 06:21
fonte

Leggi altre domande sui tag