User Tools

Site Tools


asciiviewerclass_overview.htm
Navigation:  ABC Library Reference > ASCIIViewerClass >====== ASCIIViewerClass Overview C6H0009.jpg ====== Previous pageReturn to chapter overviewNext page

There are several related classes whose collective purpose is to provide reusable, read-only, viewing, scrolling, searching, and printing capability for files, including variable length files. Although these classes are primarily designed for ASCII text and they anticipate using the Clarion ASCII Driver to access the files, they also work with binary files and with other database drivers. These classes can be used to build other components and functionality as well.

The classes that provide this read-only functionality are the ASCII Viewer classes. The ASCII Viewer classes and their respective roles are:

ASCIIViewerClass Supervisor class
ASCIIFileClass Open, read, filter, and index the file
ASCIIPrintClass Print one or more lines
ASCIISearchClass Locate and scroll to text

These classes are fully documented in the remainder of this chapter.

ASCIIViewerClass

The ASCIIViewerClass uses the ASCIIFileClass, the ASCIIPrintClass, and the ASCIISearchClass to create a single full featured ASCII file viewer object. This object uses a LIST control to display, scroll, search, and print the contents of the file. Typically, you instantiate only the ASCIIViewerClass in your program which, in turn, instantiates the other classes as needed.

ASCIIFileClass

The ASCIIFileClass identifies, opens (read-only), indexes, and page-loads a file's contents into a QUEUE. The indexing function speeds any reaccess of records and supports page-loading, which in turn allows browsing of very large files.

ASCIIPrintClass

The ASCIIPrintClass lets the end user specify a range of lines to print, then prints them. It also provides access to the standard Windows Print Setup dialog.

ASCIISearchClass

The ASCIISearchClass lets the end user specify a search value, case sensitivity, and a search direction, then scrolls to the next instance of the search value within the file.

ASCIIViewerClass Relationship to Other Application Builder Classes

The ASCIIViewerClass is derived from the ASCIIFileClass, plus it relies on the ASCIIPrintClass, ASCIISearchClass, ErrorClass, and PopupClass to accomplish some user interface tasks. Therefore, if your program instantiates the ASCIIViewerClass, it must also instantiate these other classes. Much of this is automatic when you INCLUDE the ASCIIViewerClass header (ABASCII.INC) in your program's data section. See the Conceptual Example.

ASCIIViewerClass ABC Template Implementation

The ABC Templates declare a local ASCIIViewer class and object for each instance of the ASCIIViewControl template. The ABC Templates automatically include all the classes necessary to support the functionality specified in the ASCIIViewControl template.

The templates derive a class from the ASCIIViewerClass for each ASCIIViewerClass in the application. The derived class is called procedure:Viewer# where procedure is the procedure name and # is the instance number of the ASCIIViewControl template. The templates provide the derived class so you can use the ASCIIViewControl template Classes tab to easily modify the viewer's behavior on an instance-by-instance basis.

The object is named Viewer# where # is the instance number of the control template. The derived ASCIIViewerClass is local to the procedure, is specific to a single ASCIIViewerClass and relies on the global ErrorClass object.

ASCIIViewerClass Source Files

The ASCIIViewerClass source code is installed by default to the Clarion \LIBSRC folder. The specific ASCIIViewerClass source code and their respective components are contained in:

ABASCII.INC ASCIIViewerClass declarations
ABASCII.CLW ASCIIViewerClass method definitions

ASCIIViewerClass Conceptual Example

The following example shows a typical sequence of statements to declare, instantiate, initialize, use, and terminate an ASCIIViewerClass object and related objects.

This example lets the end user select a file, then browse, scroll, search, and print from it.

PROGRAM

MAP

END

INCLUDE('ABASCII.INC')                !declare ASCIIViewer Class

ViewWindow WINDOW('View a text file'),AT(3,7,296,136),SYSTEM,GRAY

      LIST,AT(5,5,285,110),USE(?AsciiBox),IMM

      BUTTON('&Print'),AT(5,120),USE(?Print)

      BUTTON('&Search'),AT(45,120),USE(?Search)

      BUTTON('&Close'),AT(255,120),USE(?Close)

     END

GlobalErrors ErrorClass                !declare GlobalErrors object

Viewer AsciiViewerClass,THREAD         !declare Viewer object

ViewerActive BYTE(False),THREAD        !Viewer initialized flag

Filename   STRING(255),THREAD          !FileName variable

StartSearch  LONG                      !hold selected line number

AsciiFile   FILE,DRIVER('ASCII'),NAME(Filename),PRE(A1),THREAD

RECORD     RECORD,PRE()

Line       STRING(255)

       END

      END

CODE

GlobalErrors.Init                   !initialize GlobalErrors object

OPEN(ViewWindow)                    !open the window

                                    !Initialize Viewer with:

ViewerActive=Viewer.Init( AsciiFile,| ! file label,

             A1:line,               | ! file field to display

             Filename,              | ! variable file NAME attribute

             ?AsciiBox,             | ! LIST control number

             GlobalErrors,          | ! ErrorClass object

             EnableSearch+EnablePrint)! features to implement flag

IF ~ViewerActive THEN RETURN.         ! if init unsuccessful, don't

                                      ! call other Viewer methods

asciiviewerclass_overview.htm.txt · Last modified: 2021/04/15 15:56 by 127.0.0.1