This version is out of date, covering development from v9.5.0 to v9.7.3. It is maintained here only for inbound reference links from elsewhere. It is no longer actively updated.

Jump to the current version of aTbRef

Tinderbox v9 Icon

AutoFetch commands

To assist in manipulation of AutoFetched data is is possible to set an action to run on the raw output of the data before it is set as the note's $Text. It can be thought of as if it were an 'OnAutoFetch' action. Such actions are set in an Action-type attribute $AutoFetchCommand, and thus use the same syntax as agent actions and rules.

If $AutoFetchCommand is empty (the default), $AutoFetch behaves as normal; the contents of the specified URL are stored in the note's text.

$AutoFetchCommand has code set, that code is run on this note (i.e. the same note holding this code) immediately after a network AutoFetch event has been performed (event triggers are described under AutoFetch).

Historically, these actions have been command line calls but as Tinderbox's range of text-manipulation operators in action code has expanded, pure action code may suffice. For instance, if pulling stock ticker information, it is possible to look for a line like "AAPL: 145.64 USD" and set the price to a Number-type attribute $StockPrice. This could be done like so:

$StockPrice = $Text.following("AAPL: ").replace(" USD",""); 

An AutoFetch command might invoke an outside program, perhaps fetching some information from the user's hard disk or network, using the runCommand() operator. For example:

$Text = runCommand("echo | ls ~"/Documents); 

will replace the $Text of the note with a list of all the files currently in the user's Documents folder (the latter syntax is the recommended choice).

$Delivered = runCommand("myDatabaseQuery $TrackingID"); 

which will run the shell script 'myDatabaseQuery' in the user's OS home folder, passing it the value of the note's $TrackingID attribute as an argument.

When accessing the command line this way the current working directory is '/', i.e. the root of the current volume (more on the assumed working directory). Thus if calling scripts elsewhere (e.g. in a user account's 'Documents") remember to prefix an appropriate path to the script.