A Script is used to tie a number of Jobs together and to provide a way to extend the built-in functionality of Toucan. Behind the scenes Toucan has an interpreter for the Lua programming language. It is a standard interpreter with a number of extra Toucan functions added and as such should accept and existing Lua scripts.
The Script interface is very similar to the Variables interface. Scripts can be saved, added and removed using the standard controls in the top left of the window. To run a script simply press the Run button. The rest of the window is taken up by a large syntax highlighted text editor from creating scripts.
In Lua strings can be written in quotes, such as "this is a string" or in double brackets, such as [[this is also a string]]. In Toucan it is preferable to use the form surrounded by square brackets. This is because when in quotes a \ is treated as an escape character and thus does not work as expected when writing Windows file paths. One solution is to just use a / instead, which is fully supported by Toucan or to use the square bracket form.
When Toucan needs a list of strings it uses a table, for example when passing a list of paths to be encrypted. The same conditions about strings apply when they are in tables, an example of the preferred format is {[[C:\\path\\one]], [[@drive@\\path\\two]], [[D:\\path\\@date@]]} unlike some Lua tables we do not specify an index for each value, they have no use to Toucan and as such just clutter the function calls.
Toucan also uses tables when specifying options for Sync and Backup. An example Sync map would be {size = false, short = true}. This is technically an associative map. You do not need to set all of the attributes when specifying these options and any that you do not will take the default values shown on the functions documentation.
As well as all of the built in Lua commands Toucan supports the following extra commands:
Run a previously saved job
Parameters: |
|
---|---|
Return type: | none |
Run a sync with the given options
Parameters: |
|
---|---|
Return type: | none |
Run a previously saved job
Parameters: |
|
---|---|
Return type: | none |
Run a backup with the given options
Parameters: |
|
---|---|
Return type: | none |
Run a previously saved job
Parameters: |
|
---|---|
Return type: | none |
Run a secure with the given options
Parameters: |
|
---|---|
Return type: | none |
Output a message, either to the progress window or the command line
Parameters: |
|
---|---|
Return type: | none |
Perform Variable expansion on the string.
Parameters: |
|
---|---|
Returns: | The expansion, or if none was found the original string |
Return type: | string |
Deletes the given file, this does not work on folders
Parameters: |
|
---|
Copies the source file to the destination, this only applies to files and any existing file will be overwritten
Parameters: |
|
---|---|
Returns: | Whether the file was successfully copied |
Return type: | bool |
Moves the source file to the destination, this only applies to files and any existing file will be overwritten
Parameters: |
|
---|---|
Returns: | Whether the file was successfully moved |
Return type: | bool |
Renames the source file to the destination, this only applies to files and any existing file will be overwritten. This is the same as a copy
Parameters: |
|
---|---|
Returns: | Whether the file was successfully renamed |
Return type: | bool |
Exectues the file at the given path, this can be a file to open or a program to run
Parameters: |
|
---|---|
Returns: | The return value of the program is not async, otherwise nothing |
Return type: | int |
Used to get the full path to a saved Toucan script. This can then be used to run a script with the following code:: dofile(getscript([[myscriptname]]))
Parameters: |
|
---|---|
Returns: | The full path to the script |
Return type: | string |
When run this command will prompt for a password, either on the command line or using the Password Dialog and this password will be used for all subsequent Secure and Backup with password jobs.
Return type: | none |
---|
Shuts the computer down
Returns: | Success or failure |
---|---|
Return type: | bool |