Adobe 65009333 Scripting Guide - Page 20

Getting the current script

Page 20 highlights

Scripting Features Getting the current script 20 Property userInteractionLevel version Description This property controls the alerts and dialogs InCopy presents to the user. When you set this property to UserInteractionLevels.neverInteract, InCopy does not display any alerts or dialogs; set it to UserInteractionLevels.interactWithAlerts to enable alerts but disable dialogs; and set it to interactWithAll to restore the normal display of alerts and dialogs. The ability to turn off alert displays is very useful when you are opening documents via script; often, InCopy displays an alert for missing fonts or linked graphics files. To avoid this alert, set the user-interaction level to UserInteractionLevels.neverInteract before opening the document, then restore user interaction (set the property to interactWithAll) before completing script execution. The version of the scripting environment in use. For more information, see "Script versioning" on page 21. Note that this property is not the same as the version of the application. Getting the current script You can get a reference to the current script using the activeScript property of the application object. You can use this property to help you locate files and folders relative to the script, as shown in the following example (from the ActiveScript tutorial script): var myScript = app.activeScript; alert("The current script is: " + myScript); var myParentFolder = File(myScript).parent; alert("The folder containing the active script is: " + myParentFolder); When you debug scripts using a script editor, the activeScript property returns an error. Only scripts run from the Scripts palette appear in the activeScript property. When you debug scripts from the ExtendScript Toolkit, using the activeScript property returns an error. To avoid this error and create a way of debugging scripts that use the activeScript property, use the following error handler (from the GetScriptPath tutorial script): function myGetScriptPath() { try{ return app.activeScript; } catch(myError){ return File(myError.fileName); } }

  • 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
  • 59
  • 60
  • 61
  • 62
  • 63
  • 64
  • 65
  • 66
  • 67
  • 68
  • 69
  • 70
  • 71
  • 72
  • 73
  • 74
  • 75
  • 76
  • 77
  • 78
  • 79
  • 80
  • 81
  • 82
  • 83
  • 84
  • 85
  • 86
  • 87
  • 88

Scripting Features
Getting the current script
20
Getting the current script
You can get a reference to the current script using the
activeScript
property of the application object.
You can use this property to help you locate files and folders relative to the script, as shown in the
following example (from the ActiveScript tutorial script):
var myScript = app.activeScript;
alert("The current script is: " + myScript);
var myParentFolder = File(myScript).parent;
alert("The folder containing the active script is: " + myParentFolder);
When you debug scripts using a script editor, the
activeScript
property returns an error. Only scripts run
from the Scripts palette appear in the
activeScript
property.
When you debug scripts from the ExtendScript Toolkit, using the
activeScript
property returns an error.
To avoid this error and create a way of debugging scripts that use the
activeScript
property, use the
following error handler (from the GetScriptPath tutorial script):
function myGetScriptPath() {
try{
return app.activeScript;
}
catch(myError){
return File(myError.fileName);
}
}
userInteractionLevel
This property controls the alerts and dialogs InCopy presents to the user.
When you set this property to
UserInteractionLevels.neverInteract
,
InCopy does not display any alerts or dialogs; set it to
UserInteractionLevels.interactWithAlerts
to enable alerts but
disable dialogs; and set it to
interactWithAll
to restore the normal
display of alerts and dialogs. The ability to turn off alert displays is very
useful when you are opening documents via script; often, InCopy displays
an alert for missing fonts or linked graphics files. To avoid this alert, set the
user-interaction level to
UserInteractionLevels.neverInteract
before opening the document, then restore user interaction (set the
property to
interactWithAll
) before completing script execution.
version
The version of the scripting environment in use. For more information, see
Script versioning
” on page 21
. Note that this property is
not
the same as
the version of the application.
Property
Description