 |
|
|
|
| |
Overview - Introduction |
|
| |
|
|
Purpose |
|
| |
The main scope of daVinci Script is to automate manual computer activities, so they can be carried out in a
single operation with just a mouse click, no matter of how many or how complex they are.
This kind of automation is not only extremely time-saving, it eliminates also the risk for human errors during the entire process.
daVinci Script can work in a wide range of modes and, thanks to all the different executables operating on different platforms, offers an almost unlimited power to
the handy user, willing to write his own script code.
Even with simple script files, consisting of just a few lines, you will able to carry out heavy tasks. Then, by adding the power of the built-in
programming capabilities, with variables, conditional statements and loops, you will be able to move your code to an even higher dimension.
While a wide range of program-flow statements are available, the emphasis of the functionality has been put on a set of powerful instructions rather than on the
possibility to create complex program flows.
As an example, suppose you need to upload to an FTP server all the recently changed files from a local folder in your computer; this particular task would
not require more than two simple statements:
FtpSetup( "www.domain.com" "account" "password")
FtpUploadFiles( "C:\Temp\my files" "\data\my folder" Changed ) |
|
|
|
|
How it works |
|
| |
Command interpretation
The basic mechanism in daVinci Script relies in the interpretation of instructions gathered from text files.
These instructions, also called script code, consist of a series of commands with or without arguments.
The task defined by each single command is carried out directly, before the next command is read and interpreted. When no more commands are found in
the script, the application terminates.
Commands are typically composed by a command name and a variable number of arguments, which can be text strings (mostly enclosed in-between parenthesis), variable names
(system or user variables)
and keywords (predefined names).
Example (where @Source and @Destination are variable names and Subfolders
is a keyword):
Set( @Source "C:\Temp\source-folder" )
Set( @Destination "C:\Project\destination-folder" )
CopyFiles( @Source @Destination "*.txt" Subfolders ) |
Complexity and extent
When things are getting more complex, when more work needs to be recorded in your scripts, the daVinci's programming
capabilities will provide for you all the power you may need.
By means of
predefined system constants,
user defined variables
and
functions,
conditional statements
and loops, daVinci Script will always be able to carry out the tasks you ask it to do.
Inclusion of external scripts
As your code grows in proportions and complexity, the introduction of modularity will become a necessity.
For this reason daVinci Script offers the possibility to include script code defined in other files. When the application detects the command
Include(<filename>), it reads and interprets at once the contents of the named file.
One major benefit of script inclusion is the possibility to define in separate files functions to be used by many different scripts. When some of the functions
are corrected or improved, the changes will affect all the other scripts using them.
Embedding of remote scripts
In order to allow your code to work in a distributed environment, daVinci Script supports
Remote Control through the inclusion of
embedded scripts.
The idea is very simple: if you want some lines of code to be executed on another unit (a machine located anywhere in the world), just embed those lines in your code in-between the
two commands
BeginRemote(...) and EndRemote(...).
The arguments in the first command identifies the machine where the embedded code is to be executed, while the
arguments in the second command will tell to the application whenever it shall wait for remote execution completion or not before proceeding
(synchronous v. asynchronous execution).
Since all the variables created by the code are automatically transferred to and from remote units, the remote machine feels and actually acts as an extension of the hosting one.
It is also possible to have nested embedded scripts, which makes it possible to reach an inaccessible unit through a locally connected and reachable machine
(like for instance a PC connected to a web server through a local network).
Read more»
By offering the possibility to use a variety of channels for
Remote Control, like CGI,
FTP, ActiveSync and Local Network, daVinci Script allows you to extend your power to any
kind of distributed computer environments.
|
|
| |
 |
|
|
|
Preparation and Execution |
|
| |
Setting up a PC shortcut
The easiest way to launch daVinci and let it execute a certain script is to do it through a shortcut, as described below:
1. In Windows Explorer, right-click on the name of the executable (daVinci.exe) and select "Create Shortcut" from the popup
menu.
2. Right-click on the newly created shortcut (Shortcut to daVinci.exe) and select "Properties" from the popup menu.
3. Type after the executable name (in the field labeled Target) the name of your script, including the complete path if the
file is located in a folder
different than the current one.
| |
| |
1. Create a daVinci shortcut
 |
2. Edit the shortcut properties
 |
|
3. Append the script filename
 |
|
|
|
| |
At this point a good thing to do would be to rename the shortcut using the name of the related script file (which will make it easier for you to identify it
among others). For instance, if the script name is "My script.txt", you could call the shortcut "My script".
Then you can move the shortcut to the destination of your preference, like the desktop, or a dedicated folder, or even leave it in the daVinci folder.
Setting up a mobile shortcut
On mobile units it is not so simple to create shortcuts containing a command line.
We suggest that you use the daVinci's built-in function PdaCreateShortcut()
for that purpose.
For instance, you could execute the following script on your PC, with your mobile unit directly connected to it (through ActiveSync):
PdaCreateShortcut( "TestScript" "/Program Files/daVinciMob/daVinciMob.exe"
"/My Documents/daVinci Scripts/Test.txt" "/Windows/Start Menu/Programs"
)
|
The code above will create in the Programs folder
(/Windows/Start Menu/Programs) on your mobile a shortcut named
TestScript. When you tap with the pen on the shortcut icon, the script
Test.txt, found in
/My Documents/daVinci Scripts, will be executed.
Alternative way of preparation
Step 1:
Change the extension of your script filename from
txt to something else, for instance dav or dvs.
Step 2:
Double-click on the script file. When Windows asks you for the name of the executable to run, browse your File System and select daVinci.exe. Check also the
box labeled: Always use the selected program to open this kind of file.
Now your system is ready to launch daVinci every time you double-click on a file with the chosen
extension.
Execution
In order to execute your script file, just double-click on the target icon (shortcut or script file). daVinci will open the script file and execute all the commands found in
it. When the last command is carried out, daVinci terminates.
If the execution of a script takes time, it is fully possible to start another script before the first one is terminated. There is no limit (except the
amount of RAM in your computer) for how many instances of daVinci that can run contemporaneously. |
|
|
|
Feedback during debugging |
|
| |
Once your script is well tested and free of bugs you will probably want to keep it silent, except for error message when things go
wrong.
But the way to a perfectly working script may sometimes be not so short and problem-free as you would like to have it, especially when the script complexity is considerable.
In such cases it is very important to be able to follow script execution in detail and to control it as needed.
In order to make the developing phase easier, daVinci Script supplies the following debugging features:
1. Debugger window and debugger commands
Trough the OpenWindow() command you can from your script open a window
on screen containing:
1. A field where all the commands are printed as they are executed.
This way, if the execution is stopped for some reason, you will always have the possibility to see the last executed statement before
the stop.
2. A field in which you will be able to see all the diagnostic printouts generated by the script code (Print commands) and
all the error
messages generated by the application.
This will give you the possibility focus the feedback to certain parts of the script, without the need to browse through a large quantity
of lines to find the part you want to examine.
In addition, special commands like Wait, Pause and
Exit, combined with the Pause, Resume and
Exit buttons at the bottom of the window
will give you the possibility to accurately control the execution of the script code during debugging.
Example:
PositionWindow( -1, -1, 750, 450 )
SetWindowFont( WindowText Name( "Lucida Console" ) Size( 9 ) )
OpenWindow( Commands Printouts RelSize( 60 ) )
Set( @MyVariable "temporary text" )
Print( "All printouts will be displayed here:" )
Print( "MyVariable is: %MyVariable%" )
Pause # Leave the control to the operator
CloseWindow( Commands ) # Close the command field after resume
#...........
#...........
If( @Error )
OpenWindow( Printouts )
Print( "Error while attempting to..." )
Pause # Let the operator see the error message
Exit # Terminate on resume (debugger window closed automatically)
Endif |
2. Log files
Log files, where both printouts and error messages are written, can be used to examine the execution process afterwards.
The log
files are very versatile, allowing you to use them for a number of different purposes. You can for instance:
- Open a log file and erase its current contents before anything new is written in it, or keep the old contents intact and append all new
outputs to it.
- Open a different log file for each one of your scripts or share the same log file between different scripts.
- Open, close and open again the log file, how many times you want, during the execution of your script.
- Switch between different log files during the execution of your script.
|
|
|
|
|
|
|
|
|
Produced by Carso | Last update: 2010-04-11
|
|