Code: Select all
$x = Document.active
if $x = "document <untitled>"
Select All
Delete
Close
else
exit
endIt seems that the condition is not understood. What went wrong?
Code: Select all
$x = Document.active
if $x = "document <untitled>"
Select All
Delete
Close
else
exit
endI don't know but the following seems to work.js wrote:What went wrong?
Code: Select all
$docs = Document.openDocuments
foreach $doc in $docs
$path = $doc.filePath
if $path == undefined # i.e. if it is an unsaved document not having a path
Document.setActive $doc
Menu ':File:Close'
if $doc.hasChanges
Press Button "Don't Save"
end
end
endFirst "=" is an assignment, not a comparison. So really that "if" statement will always be true. Also, the capitalization and spacing of the string is not correct. What you meant was:js wrote:Code: Select all
$x = Document.active if $x = "document <untitled>"
Code: Select all
$x = Document.active
if $x == "Document<Untitled>"Code: Select all
$doc = Document.active
$doc = Cast to String $doc
If $doc == "Document<Untitled>"Code: Select all
$doc = Document.active
If $doc.filePath == undefinedCode: Select all
$doc = Document.active
If $doc.filePath == undefined
Select All
Delete
Close
EndCode: Select all
$doc = Document.active
If $doc.filePath == undefined
$doc.clearUndoHistory
Close
EndCode: Select all
$doc = Document.active
if $doc != undefined # i.e. unless there is no open document...
$doc.close true
endCode: Select all
$doc = Document.active
if $doc != undefined # i.e. unless there is no open document...
if $doc.filePath == undefined
$doc.close true
end
endCode: Select all
$docs = Document.openDocuments
foreach $doc in $docs
if $doc.filePath == undefined
$doc.close true
end
end