Creating, Saving, and Running Scripts
To create a new script that shows a message:
- Go to the File menu and select New->Script, which will open a new text editor without any script.
- In the script editor, enter the the following command
To save this script to the project and run it:
- Go to the File menu and select "Save As".
- In the project "Save As" dialog, enter the name "Test_script", then press "Save".
- Then, while the script is open, run it by either selecting Run/Script Query from the Tools menu, or pressing Alt-Enter hotkey to issue a keyboard command to run the script.
While we saved this script in the project, we could also have saved it to the file system. To save this script to the filesystem:
- Go to the File menu, and select "Save As External"
- Then, save the script as you would any other file on your system.
Actually, both scripts are stored on the filesystem. However, when scripts are created inside a project, the script file is managed directly by the project and is not readily accessible to other applications on the filesystem. In contrast, when scripts are created outside the project, they are managed by the filesystem and can be readily accessed and manipulated by tools outside of Strata.
Because you can create and save scripts inside or outside your project, you are free to manage your scripts as you see fit. You can open and save scripts to both locations, and move them back and forth between the project and the file system by simply using "Save As" or "Save As External."
Creating scripts inside a project is useful if you want to create a script that's tightly related to a specific set of tables and queries in a system that you run on a regular basis, and that you don't want to accidentally be moved by other tools in the filesystem. However, creating scripts outside a project is useful if you want to edit scripts with other text editors, manage scripts with source control, or develop scripts collaboratively with other developers.