Index

Index:

Intro	Introduction to OttoSource

Display	The OttoSource display and buttonbar

Using	Using OttoSource

FileViewer	The File Viewer

Editing	Editing Text

Translate File	Character translation

History List	The History List

Printing	Printing

Configuring	Configuring

Multitasking	Multitasking Searches


Introduction

OttoSource lets you search for text in files and browse them on the screen. With text files you can also change the files using various stream editing features. It includes support for very large files and the ability to search and browse non-text ones.

Prerequisites

OttoSource requires Windows 3.1running in Enhanced mode.

Constraints

The following limits are imposed:

file size:	available memory

record number: 	max(LONG)

record size:        	4k

Copyright

OttoSource is a copyrighted work of Doug Overmyer, 1993/1994.

Distribution Terms

OttoSource may be freely used in any non-commercial setting . It may not be distributed in conjunction with any commercial or for-fee product unless prior approval is obtained from the author. Use in a commercial setting must also be arranged with the author.

Disclaimer

You use OttoSource entirely at your own risk. Only you can determine its suitability for your configuration and needs. No other warranties are offered or implied.

Notices:

Arts & Letters® is a registered trademark of Computer Support Corporation. CorelDRAW® is a registered trademark of Corel Systems Corporation. Micrografx is a registered trademark of Micrografx, Inc. GIF is a a registered trademark of CompuServe Inc.	=>Next


Display
The OttoSource Display

OttoSource presents a single window with several configurable panes. At the top are (optionally) a toolbar and options bar. Below are three splitter windows on the left and a file viewer window on the right. When you finally select a file, it will appear in the file view window.  Before you can get anything out of OttoSource, you have to establish a few parameters. The OttoSource screen looks like this:

Choose View/Toolbar to display the toolbar, and View/Options to show the option bar.

On the left are 3 splitter panes that display the current status:

Location	Name	Content

top 	Directory Status	lists current directory

middle	Selected Files 	files that match the file extention spec & path

bottom  	Search Files 	results of most recent file search

You can adjust the splitter panes by moving the mouse over one of the heavy bars and dragging it to

resize the pane.

Choose View/Ruler to display a floating character ruler with 80 positions.

Toolbar

OttoSource displays an optional toolbar that gives access to most of the menu options.

From left to right, the options are:

*Open file

*Change directory

*Print file

*Delete file

*Cut to clipboard

*Copy to clipboard

*Append to clipboard

*Paste from clipboard

*Find text

*Search files

*Reload from file history list

*Toggle selection bar on/off

*Toggle line numbers on/off

*Display a floating ruler

*Select font

*Help

Selection Bar

OttoSource displays an optional selction bar that lets you specify the file selection criteria.

From left to right, the options are:

* Search Text

* Paths:

* Ext(ensions)

Deep Search

Check Case

Whole Words

You can toggle the selection bar On/Off using the 'switch' icon on the toolbar.	=>Next


Using OttoSource
Putting OttoSource to Work

Briefly, to use OttoSource, you need to enter file selection criteria, optionally search the disk, and choose a file from one of the result windows. The file is then loaded into the file viewer on the right. Alternately you can choose File/Open to select a specific file to view. You can edit, copy text to the clipboard, and save the current file to a new name.

Selecting Files

To start  with, you must indicate the kind of files (extensions) that OttoSource should look at and what directories to look in (paths). We will call this selecting files - the results are displayed in the Selected Files window.

To make a selection, be sure the toolbar and option bar are visible. There are two fields to fill out:

Paths:	a comma separated list of paths to search [optional]

Ext(ensions): 	select files with these extensions (wild cards OK) e.g. .h,.cpp

To do anything useful with OttoSource, you must have at least one entry in the Ext(ensions) field.  The default is ".*".  The Paths field defaults to the current file directory. OttoSource uses these two criteria to build the list of files in the Selected Files window.

Each "field" is actually a combo box that remembers the entries you type (they are also saved from session to session). You can recall a prior entry by pulling down the combo list box and selecting an item. This way you will build up a list of your favorite search directories and file types which you can use to quickly set things up.

To change the default directory, click the Directory button on the toolbar, choose File/Change Directory from the menu, or right click on the directory display pane. Use the dialog box to navigate the disk, then click OK. The Selected Files window updates automatically.

Alternately choose File/Open and open a text file directly.

Searching  files

You can further refine your quest by specifying a text string in the "Search Text" field and clicking the File Search toolbar button/Menu item. OttoSource will open each file in the Selected File list and look for the Search Text that you have specified. When it finds a match, the file is added to the Search File window.

If you check the Deep Search option, OttoSource checks files in each specified directory (in the Paths field) and all subdirectories, otherwise it sticks with the specified ones. If you choose Check Case then the case must match the target string exactly. If you choose Whole Word than only whole words that contain the search string will match.

Please note that the Search Files window does not just reflect files in the current directory - it lists everything found in the most recent search.

Printing

You can print the list of files in the Search File window by choosing File/Print SearchList. First, the list of files is formatted as text and copied to the clipboard. Second, the list of files appears in the File Viewer and a Print Preview is initiated. You can complete the print operation, abort, or make changes as you wish. Another option would be to save the contents of the document as a new text file.See File/Save As...

Pasting from Clipboard

When the file viewer window is empty, you can create a new document for viewing from text on the clipboard. Choose Edit/Paste... and a new document is opened with the text on the clipboard. You can then search and edit the text as any other file.

*Searching Non-Text Files

OttoSource will read and search both text and non-text files. When searching non-text files, all control characters (bytes with an ASCII value less then space), are converted to spaces.

*Proximity Searches

You can specify two search strings to match as follows. Enter both the strings in the 'SearchText' field separated by a '[nn]' entry which specifies how close together the strings must be found. This proximity field can specify from 1 to 80 characters. For example, to search for  the strings 'Elizabeth' and 'Overmyer' from 0 to 5 characters apart, enter:

Elizabeth[5]Overmyer

in the 'Search Text' box.  The number in the brackets is inclusive - it matches if the two strings are 5 characters apart or less.

You can include the search string '[n]' as a regular string by preceding it with a '\' escape character. For example,

Elizabeth\[5]Overmyer

searches for the simple string 'Elizabeth[5]Overmyer' in the source file.

hints -

Rremember that spaces are important in the search string - they count as just another character to match. Also, a proximity search proceeds by first locating the first string (to the left of the brackets). If you enter a string with very few characters, there will be a lot of matches, and the search will take a long time to complete.

Viewing files

Click in either the Selected or Search File windows, and view the file on the right. Alternatively, you can choose File/Open... and select a file to view directly.

=>Next


File Viewer

The file view window lets you browse the source file you've chosen. You can click the Find Text button on the toolbar or choose an Edit/Find option from the menus.to search for text. OttoSource will hunt up the next line that matches the "Text Search" field.  If found, the window scrolls to the matching line and highlights the text. The Check Case and Whole Word options apply here too.

Various keys are available for moving around in the file:

Home / End	move to top and bottom of the file

Pg Up / Pg Dn 	move up and down by a screen full of lines

Up / Down Arrows	move one line at a time.

The scroll bars also work.

Selecting Text

You can select text by clicking on a line, and dragging the cursor up or down - the lines are redrawn in reverse video. If you go above or below the fileview window, the text automatically scrolls into view and extends the selection. To end your selection with the mouse, move the cursor back into the file view window, and release the mouse button.  If you release outside of the window, the selection is cancelled.  Alternately, you can use the keyboard. Start a selection by pressing the Space bar - the top visible line is selected. To extend the selection, hold down the shift key, and use the Home/End or Up/Down arrow or Pg Up/Pg Dn keys to extend the selection. The Esc key cancels any existing selection.

Clipboard Support

Once you've selected some text, you can copy it to the clipboard by choosing Edit/Copy from the menu. If desired, you can append it to existing text on the clipboard by choosing Edit/Append. You can paste existing text on the clipboard by choosing Edit/Paste. The text is inserted below the currently selected line.

LineNumbers

You can display line numbers at the left of the file view window by choosing View/LineNumbers or clicking the Line Number icon. The current option also applies to any printed output you request. See Printing

If you double-click on a word, it is copied to the Text Search field.

Non-Text Files

OttoSource will display the text strings contained in any disk file. Text-only files are processed somewhat more quickly and display with a better format, but all are accepted. When processing files with non-text characters, OttoSource converts all control characters (ie less than a space) to spaces, and displays the file as a series of (arbitrary) 80 character records. The Find button works on these records just as with a regular text file.

This feature allows you to search formatted word processing documents, databases, spreadsheets, even .EXE files for  text strings. Once you load a file, use the Find option to locate the string and see if it looks promising. This can be a lot faster than opening 20 files in AmiPro or Word .

One peculiarity - if the find operation locates a match  that spans two display lines, OttoSource scrolls correctly to the top line but cannot highlight the string properly.

 	=>Next


Printing

You can print the current file by choosing File/Print from the menu or click the Printer icon. You may want to preview the output using File/Print Preview first. The output format is based on the following:

current line number setting

margin

header

font.

line wrap column

The margin, header and line-wrap options are set in the configuration dialog - see Configuring. The current viewing font is also used for printed output.

If you select the header option, OttoSource will print a header at the top of each page of output. The header contains the file name, DOS file date and time stamp, and the current page number.

Please note that OttoSource wraps lines based on column positions. This is a bit simplistic with proportional fonts. If you choose a large font, it is possible that some text may be truncated on the right if the print line extends beyond the edge of the page.  Basically Ive included this option to support printing long data records in a mono-spaced font so you can check record layout. However, the records can vary in length and any selectible Windows font should work.

Printing operations will proceed much more quickly if you choose a printer device font. Also, OttoSource repaginates the entire printed output at the start of every print job - if the file is large, this can take several seconds. One benefit of this delay is that you can print one or a series of pages at a time rather than having to print the entire file every time. This option is available from the Print dialog box.

You can print the list of files in the Search File window by choosing File/Print SearchList. First, the list of files is formatted as text and copied to the clipboard. Second, the list of files appears in the File Viewer and a Print Preview is initiated. You can complete the print operation, abort, or make changes as you wish. Another option would be to save the contents of the document as a new text file.See File/Save As...

=>Next


OttoSource Configuration
Configuring OttoSource

Choose File/Configure to start the configuration dialog:

The File/Configure dialog lets you set various options for your viewing and printing pleasure:

* Tab size

* Line numbers

* Print margin (left, in inches)

* Header (pathname, date/time stamp, page number)

* Multitask searches

* Wrap line column

Tabs are expanded when the file is first read - if you need to change the setting for the current file, you

will need to change the configuration, and force a reload.

If you specify a Wrap line column > 0. long lines will be wrapped at that length when printed. This is a rather mechanical line wrap - it does not check to see if the resulting line segments can actually fit on the printed page without truncation. You will need to choose your font  with this in mind.

You can also choose File/Reset Criteria to clear all the selection criteria stored in the combo boxes.

=>Next


Multitasking Searches

Choose File/Configure to start the configuration dialog. You can set an option to have OttoSource multitask (yield control to other applications) during file operations. This is most useful if you have very extensive searches in mind, or the files are large. Of course turning on multitasking slows down the searches somewhat, so you have to experiment some. While OttoSource is busy searching or loading a file, it will not let you change critical state information, such as the current file, directory, search string and so forth. In any case, if you succeed in fooling it, the program is bound to crash, so use the opportunity to work with some other application, not OttoSource.

=>Next


History List

OttoSource maintains a list of the last 25 files you have looked at during each session. To quickly return to one, choose Search/Previous File to return to the prior file, or Search/History to select a file name from a listbox. There is also a toolbar button to activate the History window.


Editing Text
 Editing

The Edit  menu offers several options for altering records.  There is a basic search and replace option, as well as several ways to change and delete whole records. However, OttoSource is stream-oriented. What you do not have is an interactive editing environment that lets you edit/change/and insert text directly on a line. There are many other editors that offer those options. Please note that all changes are made to the in-memory image of the file - NOTHING is written to disk until you choose File/Save As.... This applies to all the OttoSource editing options.

Find/Replace

Choose Edit/Find Replace... to bring up the standard Windows Search and Replace dialog. This dialog lets you enter a search string and a change-to string,  find the next occurence, change it, or globally find and change all such strings.

One peculiarity of OttoSource - it makes only one change per line for each pass of the file. When it has read the last line, it sees if there are any more strings to change, and asks you if you wish to make another pass.

When OttoSource finds a hit, it scrolls the window to the matching string and highlights it (unless you have chosen Change All which supresses the display until all changes have been made).

Stream Editing Features

The stream editing features of OttoSource are useful for globally manipulating the contents of a file. Your commands select a subset of records from the file and change them in some predictable fashion. There are several stream editing functions:

*Edit/Delete

Deletes the currently selected (highlighted) records.

*Edit/Paste

Pastes the contents of the clipboard (text only) below the currently selected line.

*Edit/Set Record Length...

Pads or truncates the length of each record (as needed) to the number of characters you specify. Records are padded with spaces. When you specify the record length, you do not count the terminating CR/LF characters - OttoSource adds them automatically. This feature is especially useful in shaping up text files for import to database programs which expect fixed length records, or creating files to upload to mainframes.

*Edit/Find Delete...

Finds and deletes records that match certain criteria which you specify.

Your options are presented in a dialog box as follows:

The Record Selection criteria determine which records from the file are considered a 'match', while the OnMatch Option  specifies what happens to the records. The MatchWhat string  is matched against each record in the file- if a Starting-at is given, then match begins only with the column specified. Match Case and Whole Word are applied if checked. If  Starting-at =  0, then the match is applied to the whole record. Once a record is identified as either a Match or NoMatch, the OnMatch Option is applied and the next record is read. This continues until the end of the file.

This option is useful for quickly subsetting a file if the offending records are uniformly identifiable.

Note that the records are deleted only from the memory image of the file - there is no change to the disk until you use File/Save As... to actually write the file to disk.

*Find/Replace Column...

Lets you edit the file stream based on matching strings in certain column positions. You fill in the following dialog box to specify the action:

The underlying logic is to select a group of records based on the Record Selection criteria, delete the characters from Replace Column Start through

End, and insert the With string. The whole action is completed before updating the screen. Here are the details.

* Records are selected based on the MatchWhat string (and MatchCase/WholeWord options) at the Starting-at column. If MatchWhat is empty, all records are selected. All the characters in the MatchWhat string are compared to the record.

* You must always supply Start and End values for Replace Columns. Start must be >  0, End can be  >= 0.

* If  Replace Columns With  is empty, columns from Start through End are simply deleted in all selected records.

* If Replace Columns End is  less than Start, the With string is inserted at the  Start position  and the source string is appended to itself beginning at End+1. This lets you simply insert strings, or even duplicate column positions.

Examples:

A record with 9 characters looks as follows:

123456789	<column position>

AdougBCDE	<record>

Here are 5 sample criteria and the resulting changes:

|--Match--|	|-------Replace------|	|--Result--------|

What	Start	Start	End	With	Record

oug	3	2	4	aaabc	AaaabcgBCDE

< >	2	1	XXX	AXXXdougBCDE

< >	1	5	FOO	FOOBCDE

< >	7	8	< >	AdougBE

< >	1	0	YYY	YYYAdougBCDE


 Character Translation

As a stand-alone feature, OttoSource supports character substitution for file streams. The idea is that you specify strings of characters that you wish to translate in one file when it is rewritten to a second file. This feature is similar to search and replace except that it operates on all kinds of files, not just text, and supports all valid  character codes (0 - 255) including control codes.  The file translation option does not load the target file into the file window, since that operation supresses control characters which are the raison d'etre for this option.

Beware that you can easily destroy the logical consistency of your target file if you exercise this feature carelessly.  To help reduce the risk, you are prevented from overwriting the input file.

To begin a file translation, choose File/Translate...and fill in the dialog box. There are several things you need to specify:

Files

Specify the In file and Out file. You can either type in a complete path name or use the Browse buttons to locate an existing file. The In and Out names must be different.

Strings

The Old and New edit boxes let you specify a pair of translation strings. The strings consist of characters that you type or specify. You can enter any keyboard character by just typing the character(s) in the edit box.. To specify a control character, make a special entry in this form:

[nnn]

where nnn = ASCII or ANSI decimal  code of the character you wish to specify. Be sure to include the brackets and 3 numeric characters. You can intermix regular characters and control characters to form your string. Each string can be up to 999 bytes long, and you can have a large number of translation pairs - more than you could stand to type. Here are some sample strings:

String	Meaning

abc[097][098][099]	'abcabc' - two ways to say the same thing

country[013][010]	'country' followed by CR/LF characters

[009]Now	'Tab' followed by string 'Now'

Translation Table

Once you have specified a translation pair, click More  to move the strings to the Translation Table. The table is just for reference but you will find it handy if you are specifying several translations. The Old and New strings are separated by an '=' sign which is inserted for legibility.

When you have added all the strings you wish to translate (and specified the In and Out files), choose DoIt or Cancel. If all goes according to plan, your In file is opened and copied to a block of global memory, matched byte by byte against the translation strings, blocked and rewritten with changes to the Out file. This process requires that you have enough free memory to hold the entire byte stream.

In general, the order of the translation strings is immaterial, with this exception. The comparisons are made in the order you entered the strings, and stop with the first hit. If a match is found at a given offset, the bytes are translated and moved to the output file. No further attempt is made to match  at this point in the file - instead the file pointer is bumped up to the next unmatched byte. This features lets you 'hide' unwanted translations.

For most of us, translating control characters requires an ASCII or ANSI character chart to look up the decimal values. These are available in many DOS and Windows manuals. If you need to translate a string of the form '[abc]', (which looks just like a control character to the OttoSource parser), you will need to specify one of the brackets using control character notation, e.g. '[091]abc]'.