| **Navigation:**  [[abc library reference.htm|ABC Library Reference]] > ASCIIViewerClass > AsciiViewerClass Methods >====== Init (initialize the ASCIIViewerClass object) {{c6h0009.jpg|C6H0009.jpg}} ====== | [[displaypage display new page .htm|{{btn_prev_n.gif|Previous page}}]][[abc library reference.htm|{{btn_home_n.gif|Return to chapter overview}}]][[kill shut down the asciiviewerclass object .htm|{{btn_next_n.gif|Next page}}]] | | || **Init( **//file, field, //[//filename//]//, list control, error handler //[//, features//]// //**)** {{blk2blue.jpg|blk2blue.jpg}} | **Init** | Initializes the ASCIIViewerClass object. | | //file// | The label of the file to display. | | //field// | The fully qualified label of the //file //field to display. | | //filename// | The label of the //file//'s NAME attribute variable. If omitted, the file has a constant NAME attribute. If null (''), the Init method prompts the end user to select a file. | | //list control// | An integer constant, variable, EQUATE, or expression containing the control number of the LIST that displays the //file //contents. | | //error handler// | The label of the ErrorClass object to handle errors encountered by this ASCIIViewerClass object. | | //features// | An integer constant, variable, EQUATE, or expression that tells the ASCIIViewerClass object which features to implement; for example, printing (//EnablePrint//), searching (//EnableSearch//), or both. If omitted, no additional features are implemented. | The **Init **method initializes the ASCIIViewerClass object and returns a value indicating whether it successfully accessed the //file// and is ready to proceed. **Implementation:** The Init method returns one (1) if it accessed the //file// and is ready to proceed; it returns zero (0) and calls the Kill method if unable to access the //file //and cannot proceed. If the Init method returns zero (0), the ASCIIViewerClass object is not initialized and you should not call its methods. You can set the //features //value with the following EQUATEs declared in ASCII.INC. Pass either EQUATE to implement its feature (search or print), or add the EQUATEs together to implement both features. **EnableSearch        BYTE(001b)** **EnablePrint         BYTE(010b)** **Return Data Type:     **BYTE **Example:** ** PROGRAM** ** MAP** ** END** ** INCLUDE('ABASCII.INC')                !declare ASCIIViewer Class** **ViewWindow WINDOW('View an ASCII 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** **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** ** ACCEPT                               !If init succeeded, proceed** **  IF EVENT() = EVENT:CloseWindow** **   IF ViewerActive THEN Viewer.Kill.  !If init succeeded, shut down** **  END** **  !program code** ** END** **See Also:     **[[kill shut down the asciiviewerclass object .htm|Kill]]