Navigation: ABC Library Reference > ASCIIPrintClass >====== ASCIIPrintClass Overview ====== | |
The ASCIIPrintClass provides the user interface–a simple Print Options dialog–to print one or more lines from a text file. The ASCIIPrintClass interface lets the end user specify a range of lines to print, then optionally previews the lines before printing them. The ASCIIPrintClass interface also provides access to the standard Windows Print Setup dialog.
ASCIIPrintClass Relationship to Other Application Builder Classes
The ASCIIPrintClass relies on the ASCIIFileClass to read and index the file that it prints. It also relies on the PrintPreviewClass to provide the on-line preview. It also uses the TranslatorClass to translate its Print Options dialog text if needed.
The ASCIIViewerClass uses the ASCIIPrintClass to provide the end user with a Print Options dialog to print one or more lines from the viewed file.
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:
ASCIIViewerClass | ASCIIFileClass plus user interface | |
ASCIIFileClass | Open, read, filter, and index the file | |
ASCIIPrintClass | Print one or more lines | |
ASCIISearchClass | Locate and scroll to text |
ASCIIPrintClass ABC Template Implementation
Both the Viewer procedure template and the ASCIIPrintButton control template generate code to instantiate an ASCIIPrintClass object. The Viewer template accomplishes this by adding a parameter to the ASCIIViewerClass.Init method. The ASCIIPrintButton template accomplishes this by declaring an ASCIIPrintClass object and calling the ASCIIViewerClass.AddItem method to register the ASCIIPrintClass object with the ASCIIViewerClass object.
ASCIIPrintClass Source Files
The ASCIIPrintClass source code is installed by default to the Clarion \LIBSRC folder. The specific ASCIIPrintClass source code and their respective components are contained in:
ABASCII.INC | ASCIIPrintClass declarations | |
ABASCII.CLW | ASCIIPrintClass method definitions |
ASCIIPrintClass Conceptual Example
The following example shows a typical sequence of statements to declare, instantiate, initialize, use, and terminate an ASCIIPrintClass object and related objects.
This example lets the end user select a file, then search and print from it.
MEMBER('viewer.clw')
INCLUDE('ABASCII.INC')
INCLUDE('ABWINDOW.INC')
MAP
MODULE('VIEWE002.CLW')
BrowseFiles PROCEDURE
END
END
BrowseFiles PROCEDURE
FilesOpened BYTE
ViewerActive BYTE(False)
Filename STRING(FILE:MaxFilePath),AUTO,STATIC,THREAD
AsciiFile FILE,DRIVER('ASCII'),NAME(Filename),PRE(A1),THREAD
RECORD RECORD,PRE()
Line STRING(255)
END
END
ViewWindow WINDOW('View an ASCII File'),AT(3,7,296,136),SYSTEM,GRAY
LIST,AT(5,5,285,110),USE(?AsciiBox),IMM,FROM('')
BUTTON('&Print…'),AT(7,119),USE(?Print)
BUTTON('&Search…'),AT(44,119),USE(?Search)
END
ThisWindow CLASS(WindowManager)
Init PROCEDURE(),BYTE,PROC,VIRTUAL
TakeAccepted PROCEDURE(),BYTE,PROC,VIRTUAL
END
Viewer AsciiViewerClass !declare Viewer object
Searcher AsciiSearchClass !declare Searcher object
Printer AsciiPrintClass !declare Printer object
CODE
GlobalResponse = ThisWindow.Run()
ThisWindow.Init PROCEDURE()
ReturnValue BYTE,AUTO
CODE
ReturnValue = PARENT.Init()
IF ReturnValue THEN RETURN ReturnValue.
SELF.FirstField = ?AsciiBox
SELF.VCRRequest &= VCRRequest
SELF.Errors &= GlobalErrors
OPEN(ViewWindow)
SELF.Opened=True
CLEAR(Filename)
ViewerActive=Viewer.Init(AsciiFile,A1:Line,Filename,?AsciiBox,GlobalErrors)
IF ~ViewerActive THEN RETURN Level:Fatal.
Viewer.AddItem(Searcher) !register Searcher with Viewer
Viewer.AddItem(Printer) !register Printer with Viewer
SELF.SetAlerts()
RETURN ReturnValue
ThisWindow.TakeAccepted PROCEDURE()
ReturnValue BYTE,AUTO
CODE
ReturnValue = PARENT.TakeAccepted()
CASE ACCEPTED()
OF ?Print
ThisWindow.Update
IF ViewerActive THEN Viewer.Printer.Ask. !display Print Options dialog
OF ?Search
ThisWindow.Update
IF ViewerActive
IF CHOICE(?AsciiBox)>0 !search from current line
Viewer.Searcher.Ask(Viewer.TopLine+CHOICE(?AsciiBox)-1)
ELSE
Viewer.Searcher.Ask(1) !search from line 1
END
END
END
RETURN ReturnValue