Reference: Display Filters: Substitute
Move Up Move to Top
Contents: Filter Overview User Interface & Options
Example Variables
Filter Overview This filter allows certain strings in an article to be replaced with other strings or with graphics when the article is displayed. You might use this to, for example, fix a few particularly common and annoying spelling errors, or to replace an ASCII smiley :-) with an actual smiley, as shown in the example below

Like all other display filters, the Substitute filter only affects the presentation of the article. It does not change the original in any way.

Back to Top

User Interface The user interface for this filter looks like this:

The filter accepts a list of replacement rules, each of which has the following parameters:

  • Case - Can be set to make the comparison case sensitive, or unset to make it non case sensitive. Case sensitive comparisons are faster and generally recommended when possible.

  • Wild - If set, the pattern will be matched using AmigaOS wildcards. Otherwise, the pattern is searched for using a fixed string match, which is much faster than using wildcards.

  • Longest - When using a wildcard search, this option controls whether the longest or the shortest possible substring is matched. For example, given this text:

      aaaZ bbbZ

    if the longest option is used, 9 characters are matched (from the first a up until the Z in the second word). Otherwise, only 4 characters are matched (the first a through the Z at the end of that word).

  • Pattern - This string is searched for in the article body, and will be replaced with the replacement string or image defined below.

  • Replacement - When the pattern is found in an article body, it is replaced with this string, if non-empty. The string may contain the variable ${Img} in order to imbed a defined image in the replacement string. If the replacement string is empty and an image is defined, then the image is substituted for the original pattern.

  • Image - If non-empty, this is a filename of an image which is loaded using datatypes and used to replace the original pattern. This is intended to be used for small images such as smiley faces and the suchlike. If the replacement string above is empty, the image can be used directly. If the replacement string is non-empty, then it can use the variable ${Img} to control the location in the replacement where this image is displayed.

  • Mask - If non-empty, this is a filename of a mask which is used to control how the image is copied to the screen. The mask file must be a single plane IFF file with the same dimensions as the image file. Image bits are copied in any location where the mask has a 1, and the background shows through the image in any location where the mask has a zero.

Back to Top

Example Here is an example of some text with a Substitute filter set to convert ASCII smileys to a smiley graphic:

And here is the original text without using the substitute filter:

Back to Top

Variables There is one variable supported by this filter. The variable ${Img} may be used in the replacement text to specify the location in the replacement text where the defined image should be imbedded.