StrongED:Applying scripts

[[Image:stronged36x38.png]] Applying scripts to StrongED windows
The apply icon for the StrongED toolbar.

In the toolbar of versions of StrongED from 4.67 onwards you will see this icon. Its purpose is to let you apply a script to the text in the window. This facility is very powerful; it lets you extend the capabilities of StrongED without limit, and it turns StrongED into a handy development environment for any scripting language.
 * If you shift-drag the icon of the script file onto the apply icon the action of the script will be applied to the contents of the window.
 * If you ctrl-drag the icon of the script file onto the apply icon then the result will be displayed in a new StrongED window; the original window will be unchanged.
 * If you shift-ctrl-drag the icon of the script file onto the apply icon the action of the script will be applied to all the open StrongED windows; this can be useful for mailshots.

Adding new scripting languages
The mechanism for achieving this has evolved with the different versions of StrongED, but for version 4.68a4 it is achieved by the application !ScriptSED in the !StrongED.Defaults.Tools directory. The application !ScriptSED will try to recognize the scripting language from the filetype of the file whose icon is dragged, but if that fails because its filetype is text then it will examine its first line. For a generic (and imaginary) scripting language foo, foo-scripts should begin with the line


 * 1) ! foo

the foo binary should be on your system's Run$Path and an Obey file called foo should be put in the !ScriptSED.Languages directory telling StrongED how to apply the script. Its syntax will depend on foo's requirements for a correct commandline. The languages are already provided with appropriate Obey files. Their contents should be sufficient to enable a foo-enthusiast to get foo working with StrongED.
 * awk
 * basic
 * lua
 * perl
 * python

Script input/output conventions
Your script can read the contents of the StrongED window as from a file named either by It should output to stdout or equivalently to the file named by StrongED$Script_Outfile. For example, to list the URLs in a webpage, view the source of it in StrongED and apply the awk script
 * the first command line argument
 * or equivalently by the system variable StrongED$Script_Infile

BEGIN { RS = "\"" } /^http:\/\//
 * 1) ! awk

This says: treat the double-quote sign as record separator and print out all records starting with http://.