StrongED:Applying scripts: Difference between revisions

From RISC OS
Jump to navigationJump to search
Line 3: Line 3:
[[Image:apply26x26.gif]]
[[Image:apply26x26.gif]]
The ''apply'' icon for the StrongED toolbar.
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.
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.
Line 10: Line 9:
* 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.
* 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
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


Line 21: Line 21:
* '''python'''
* '''python'''
are already provided with appropriate Obey files. Their contents should be sufficient to enable a foo-enthusiast to get foo working with StrongED.
are already provided with appropriate Obey files. Their contents should be sufficient to enable a foo-enthusiast to get foo working with StrongED.

=== script i/o ===
Your script can read the contents of the StrongED window as if from a file named either by
* the first command line argument
* or equivalently by the system variable '''StrongED$Script_Infile'''
It should output to '''stdout''' or equivalently to the file named by '''StrongED$Script_Outfile'''.

Revision as of 11:35, 11 May 2008

Applying scripts to StrongED windows

Apply26x26.gif 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

#! 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

  • awk
  • basic
  • lua
  • perl
  • python

are already provided with appropriate Obey files. Their contents should be sufficient to enable a foo-enthusiast to get foo working with StrongED.

script i/o

Your script can read the contents of the StrongED window as if from a file named either by

  • the first command line argument
  • or equivalently by the system variable StrongED$Script_Infile

It should output to stdout or equivalently to the file named by StrongED$Script_Outfile.