RISCOS.com

www.riscos.com Technical Support:
DDE (Desktop Development Environment)

 


Find


Find searches both the names and the contents of one or more files for text patterns. It includes options allowing you:

  • to control whether the case of letters should be considered;
  • to use wildcard expressions to specify several filenames;
  • to insert wildcard expressions in the pattern string so that digits, control characters, alphanumerics and particular sets of characters can be searched for;
  • to start SrcEdit displaying found text using Throwback.

The SetUp dialogue box

Clicking Select on the application icon or dragging the name of a file from a directory display to the icon brings up the SetUp dialogue box:

FIND-2.PNG

The Patterns writable icon allows you to type in the patterns to be searched for.

If a single pattern includes spaces, the pattern must be enclosed in double quotes, for example:

"the text"

Double quote characters in a search pattern must be preceded by a backslash.

The Files writable icon allows you to specify the name of one or more files (typed in or dragged from a directory display) to do the searching in.

SetUp options

Line count only prints only a count of the number of lines matching the pattern from the specified files.

Filenames only lists only the names of files matching the pattern.

Case insensitive will ignore the case of letters; for example, normal and Normal would be considered as identical if this option was chosen.

Verbose lists the name of each file before searching it for pattern matches.

Throwback enables SrcEdit throwback when text selections are found.

Clicking on Wildcards displays a further set of options:

FIND-3.PNG

Pattern wildcards

The options listed under Pattern Wildcards allow you to specify wildcarded expressions in your search string. Clicking on one of these options will insert a special character into the Patterns writable icon immediately before the caret.

Wildcard Meaning
Any . Matches any single character. For example:

Fr.d will match Fred and Fr1d, but not Fried

Newline $ Matches the newline character (LineFeed).
Alphanum @ Matches any alphanumeric character a-z, A-z, 0-9 or _.
Digit # Matches any digit 0-9.
Ctrl | Matches Ctrl-c, where c is any character between @ and _.

For example:

|x matches Ctrl-x

Note: There are two special cases:

|? matches the Delete character

|!c matches Ctrl-c' where c' is the character c with its top bit set

Normal \ Matches the following character even if that character is a special character. For example:

\. matches the dot character (not any single character)

\c matches lowercase c

Set [ Inserts a left square bracket immediately before the caret.
] Set Inserts a right square bracket immediately before the caret.

The preceding two options insert opening and closing square brackets into the Patterns writable icon. You can then manually insert one or more characters between these brackets and Find will match any one of the characters you put inside the brackets. For example:

t[aei]n matches tan, ten and tin, but not ton

Note that a set is always case-sensitive.

Not ~ Matches any character other than the following character, where the following character is any of the simple character patterns listed above. For example:

la~ne matches late, lace and lake, but not lane

0 or more * Matches 0 or more occurrences of the following character, where the following character is any of the simple character patterns listed above. For example:

ca*n matches can, cannot and cat

1 or more ^ Matches 1 or more occurrences of the following character, where the following character is any of the simple character patterns listed above. For example:

ca^n matches can and cannot, but not cat

File wildcards

The options offered under File Wildcards insert special characters into the Files writable icon which allow you to specify files in a variety of ways. Several of these options require you to manually insert additional text next to or inside these special characters:

Filename ch. # inserts a hash character immediately before the caret. This character will match any single filename character except .

For example:

Find adfs::HDisc4.$.Fred#

will search files Fred1 and Freda, but not Fred13, Frederick etc.

Find adfs::HDisc4.$.Fr#d

will search files Fred and Fr2d, but not Fre1d, Freed etc.

0orMore filename chs. * inserts an asterisk immediately before the caret. This character will match any sequence of filename characters except ., {, and }.

For example:

Find adfs::HDisc4.$.Fred*

will search files Fred1 and Freda, and also Fred13, Frederick etc.

Find adfs::HDisc4.$.Fr*d

will search files Fred and Fr2d, and also Frd, Freed, Fr123d etc.

Sub-directories ... inserts three dots immediately before the caret. It must be positioned immediately after a directory name. Find will then search all nominated files in that directory and in any subdirectories in that structure.

For example:

Find adfs::Amy.$.Receipts...monthly

will search all files called monthly in the directory Receipts and also in any subdirectories of Receipts.

Or { inserts a left brace immediately before the caret.

Or } inserts a right brace immediately before the caret.

The preceding two options insert opening and closing braces into the Files writable icon. You can then manually insert one or more filename characters between these braces, separating each filename with a comma. Find will then search all filenames inside the braces.

For example:

Find adfs::HDisc4.$.W.rel.{atype,btype,ctype}

would search all three files inside the braces, i.e. atype, btype and ctype.

0 or More ( inserts a left bracket immediately before the caret.

) 0 or More inserts a right bracket immediately before the caret.

The preceding two options insert opening and closing brackets into the Files writable icon. You can then manually insert one or more filename characters between these brackets and Find will search any files with none, one or more occurrences of the characters you put inside the brackets.

For example:

Find adfs::HDisc4.$.Fr(e)d

will search files Frd, Fred and Freed, but not Frid.

Find adfs::HDisc4.$.Fr(ie)d

will search files Frd, Fried and Frieied, but not Frid, Frieed or Fred.

The SetUp menu

Clicking Menu on the SetUp dialogue box displays the menu shown on the left.

FIND-4.PNG

Command line option - see Command line interface.

The Allow '-' option enables you to specify another pattern which will be matched even if it begins with a -. This pattern will be searched for in conjunction with the patterns you have inserted into the Patterns writable icon.

If you need to match two or more patterns beginning with a -, then you must precede each additional pattern with -e

For example:

-pattern -e -pattern -e -pattern

Grep style enables you to specify patterns using the syntax of the UNIX grep tool. This option is provided for users familiar with UNIX.

The Application menu

Clicking Menu on the Find application icon gives the following options:

FIND-5.PNG

For a description of each option in the application menu see the chapter entitled General features.

Note that Auto Run and Auto Save are not available for this application.

Example output

The output of Find appears in one of the standard non-interactive tool output windows. For more details of these see the chapter entitled Output.

The following window shows an example of the output from Find:

FIND-6.PNG

In the above example the pattern MOV[CV] was specified in the Patterns writable icon in order to list only those instructions beginning with MOVV or MOVC in an assembler source file. Instructions where the fourth letter was not a C or V, such as MOVS, MOVNE and MOVEQS, were, therefore, not listed. The Throwback option was not enabled in the above example. With Throwback enabled, a SrcEdit Throwback browser would also have appeared allowing the file Util to be edited, starting at the found lines.

Command line interface

For normal use you do not need to understand the syntax of the Find command line, as it is automatically generated for you from the SetUp dialogue box settings. The Command Line syntax for Find is:

Find [options] [pattern{ pattern}] -f filepattern{ filepattern}

Options
-c list only a count of the number of lines matching from each file.
-n ignore the case of letters when making comparisons.
-l list only the names of files matching patterns.
-v list the name of each file before searching it for matches.
-u accept UNIX grep/egrep-style patterns.
-e allow the following pattern arguments to begin with a -.
Pattern
. matches any single character.
$ matches the newline character (LineFeed).
@ matches any alphanumeric character.
# matches any digit.
| |c matches Ctrl-c, where c is any character between @ and _.
\ matches the following character even if that character is a special character.
[ ] matches any character inside the square brackets.
~ matches any character other than the following character.
* matches 0 or more occurrences of the following character.
^ matches 1 or more occurrences of the following character.
-f marks the end of multiple patterns and the start of filepatterns.
Filepattern
# matches any filename character except .
* matches 0 or more filename characters other than .
... searches files in that directory and any subdirectories in that directory.
{,} searches files contained within braces (filenames separated by commas).
( ) search any file with none, one or more occurrences of the characters inside the brackets.

This edition Copyright © 3QD Developments Ltd 2015
Last Edit: Tue,03 Nov 2015