Local and Global Properties for Files and File Systems
The local and global properties described here affect the way SenseTalk scripts access or interact with files and file system objects. For additional information about working with files and the file system in SenseTalk, see File and Folder References and File and Folder Interaction.
Setting or Changing Local and Global Property Values:
You can set a global property value with the SenseTalk commands Set
or Put
. Note that when you reference one of these properties, you must use the word the
before the property name to distinguish it from an ordinary variable.
Examples:
set the searchrectangle to [1,2,2,3]
put 2 into the remoteworkinterval
You can add or change specific named properties within a global property like this:
set the namedColors.pink to color("RGB,1.0,0.5,0.5") -- Adds pink to the namedColors global property and defines its RGB color value
set the listFormat's separator to " & " -- Sets the separator property of the listFormat global property
Properties can also be set or updated by using the setoption
or setoptions
commands. The setoption
command lets you update a single property, and setoptions
lets you update multiple properties.
Examples:
setoption searchrectangle, [1,2,2,3]
setoptions {searchrectangle: [1,2,2,3], scriptlogging: yes}
Because setoption
and setoptions
are specific for use with global and local properties, you omit the word the
from the property name in the command syntax for these commands.
For additional information about working with local and global properties, see Local and Global Properties in SenseTalk.
the folder
, the directory
Global Properties
Values: The path for the current working directory
Default: Typically, the path to the Documents folder; however, this value can be changed by updating the Default Suite Directory setting in the General section of Preferences.
Behavior: This property lets you access or change the current working folder. The value returned by the folder
ends with a slash unless the folderNamesEndWithSlash
global property is set to false. The slash at the end makes it easy to create a full path name by appending a file name, as shown in the example below.
The words folder
and directory
are used interchangeably within SenseTalk scripts. Wherever the word folder
is used in a script, you can use the word directory
instead.
Example:
set the directory to "C:\Users\Carrie\Desktop\"
Example:
set the folder to "C:\Users\Carrie\Desktop\"
Example:
set the directory to "C:\Users\Carrie\Desktop\data\"
put the files of the folder into fileObjects // Returns a list of the file objects for any files in the current working directory and stores them in a variable
Example:
set the folder to "/tmp/myWorkArea" -- Sets the working folder
put the folder & "newfile.txt" into filePath
put "xyz" into file filePath
Related:
the folderNamesEndWithSlash
folder
,directory
Functions
the folderNamesEndWithSlash
Global Property
Values: True
, False
Default: True
Behavior: This property determines whether folder or directory names are returned with a slash at the end. This property applies to the folder
and the directory
global properties as well as the various SenseTalk commands and functions that return directory paths.
Example:
set the folderNamesEndWithSlash to false
Example:
log the folder // Logs the current working directory with a slash at the end. For example: 'C:/Users/Carrie/Documents/'
set the folderNamesEndWithSlash to false
log the folder // Logs the current working directory without a slash at the end. For example: 'C:/Users/Carrie/Documents'
Example:
set the folderNamesEndWithSlash to false
put the folder & "\newfile.txt" into filepath // Concatenates the / to create a valid path, because the / is not returned by the folder function
put "xyz" into file filepath
Related:
the strictFiles
Global Property
Values: True
, False
Default: False
Behavior: This property can be used to provide stricter control over the use of files at runtime. When this property is set to True
, reading a nonexistent file as a container throws an exception rather than returning empty.
When set to False
, reading from a nonexistent file returns a value as though that file were empty. Sometimes this behavior can lead to unexpected results. For example, if a file name is entered incorrectly, a script treats it as empty rather than giving an error indicating that the file could not be found.
Example:
set the strictFiles to true
Example:
set the StrictFiles to true
put file "C/Desktopmyfile.txt" into myData // Throws exception: StrictFilesViolation Attempt to read nonexistent file: C:/Users/Carrie/Documents/C/Desktopmyfile.txt'
Related:
the strictProperties
the strictVariables
the defaultStringEncoding
Global Property
Values: The current string encoding method. To see the full list of available values, use the availableStringEncodings()
function:
put availableStringEncodings()