This shows you the differences between two versions of the page.
Both sides previous revision Previous revision | Next revision Both sides next revision | ||
howtos:toolcoding:tool_shell_scripts [2010/03/16 12:40] shona.weldon |
howtos:toolcoding:tool_shell_scripts [2010/03/16 12:54] shona.weldon |
||
---|---|---|---|
Line 69: | Line 69: | ||
One of the challenges of running shell scripts in standard mode is the need to create and shape objects. To mitigate this, TOOL scripts can be run in //local// mode in which TOOL objects - as files - can be accessed from and output to the the local working directory. This is especially useful if certain TOOL objects (with instance data) exist in a modelbase. These variables can be exported directly from SAMM (right click on variable | Export Variables...) to the working directory. The TOOL file format preserves shape and instance data. | One of the challenges of running shell scripts in standard mode is the need to create and shape objects. To mitigate this, TOOL scripts can be run in //local// mode in which TOOL objects - as files - can be accessed from and output to the the local working directory. This is especially useful if certain TOOL objects (with instance data) exist in a modelbase. These variables can be exported directly from SAMM (right click on variable | Export Variables...) to the working directory. The TOOL file format preserves shape and instance data. | ||
+ | |||
+ | ===== Example session ===== | ||
+ | Suppose you wanted to test some code in a script which required building a shaped object (with an informant from your model called canReg) running a couple of tools and then showing the result with table. Here's one example of how to use interactive TOOL and a tool script to do that. | ||
+ | |||
+ | - Make a sub directory in your model account (can also be done in a user account depending on what you want to do) to hold your test script and any data it may create | ||
+ | - In that directory write your script text file (myScript.t) just as you would any other piece of tool code (most similar to view writing): | ||
+ | <file> | ||
+ | informant canReg[] | ||
+ | |||
+ | local myStock[cr,ts] = create(; dim=canReg, dim=SEQ;time:1992:1994:1;year) | ||
+ | myStock[cr,ts] = import(; rowTitles=on, dataFile=$home/primaryData/inputStock.txt ) | ||
+ | |||
+ | local myStockTot[ts] = sum (myStock[cr,ts]; dim=canReg) | ||
+ | |||
+ | table (myStockTot[ts]) | ||
+ | </file> | ||
+ | - Launch interactive TOOL - find it under Start/All Programs/whatIf/TOOL | ||
+ | - Login as your model account | ||
+ | - Check where you are and move to the directory you created above: | ||
+ | <code> | ||
+ | TOOL> where() | ||
+ | TOOL> look() | ||
+ | TOOL> moveto("the appropriate path to your testing directory") | ||
+ | </code> | ||
+ | |||
+ | |||
+ | |||
+ | |||
+ | |||
+ | |||
===== Other Useful Information ===== | ===== Other Useful Information ===== |