home *** CD-ROM | disk | FTP | other *** search
/ DP Tool Club 16 / CD_ASCQ_16_0994.iso / news / 4611 / fw16d.ins / IDE / SOURCE / TEXT.PRG < prev    next >
Text File  |  1994-06-05  |  2KB  |  65 lines

  1. #include "FiveWin.ch"
  2.  
  3. //----------------------------------------------------------------------------//
  4.  
  5. function TxtOpen( cFileName )
  6.  
  7.    local oWndFile, oBrw, oIco, oBar
  8.    local cAlias  := "ARRAY"
  9.    local nField  := 1
  10.    local oFile
  11.  
  12.    DEFAULT cFileName := cGetFile( "Ascii Text (*.txt) | *.txt",;
  13.                                   "Select a TextFile" )
  14.  
  15.    if ! File( cFileName )
  16.       MsgStop( "I can't find that file!" )
  17.       return nil
  18.    endif
  19.  
  20.    oFile = TFile():New( cFileName )
  21.  
  22.     if oFile:Open( 0 ) > 0
  23.  
  24.        DEFINE ICON oIco RESOURCE "Notes"
  25.  
  26.        DEFINE WINDOW oWndFile FROM 1, 43 TO 23, 79 ;
  27.           TITLE "Text: " + cNoPath( cNoExt( cFileName ) ) MDICHILD ;
  28.           ICON oIco
  29.  
  30.        DEFINE BUTTONBAR oBar OF oWndFile
  31.  
  32.        DEFINE BUTTON RESOURCE "Font" GROUP OF oBar ;
  33.           ACTION oBrw:SelFont() ;
  34.           MESSAGE "Select a new font"
  35.  
  36.        DEFINE BUTTON RESOURCE "Clr" OF oBar ;
  37.           ACTION ( oBrw:SelColor(),;
  38.                    If( oWndFile != nil,;
  39.                    oWndFile:oControl:SetColor( oBrw:nClrText, oBrw:nClrPane ),) ) ;
  40.           MESSAGE "Select a new backcolor"
  41.  
  42.        @ 2, 0 LISTBOX oBrw FIELDS "" ;
  43.           HEADERS "" ;
  44.           SIZES   600 ;
  45.           SIZE 400, 400
  46.  
  47.        oBrw:bLine     = { || { oFile:ReadLn() } }
  48.        oBrw:bLogicLen = { || oFile:LastRec() }
  49.        oBrw:bGoTop    = { || oFile:GoTop() }
  50.        oBrw:bGoBottom = { || oFile:GoBottom() }
  51.        oBrw:bSkip     = { | nSkip, nOld | nOld := oFile:Recno(), oFile:Skip( nSkip ),;
  52.                                     oFile:Recno() - nOld }
  53.  
  54.        oWndFile:SetControl( oBrw )
  55.  
  56.        ACTIVATE WINDOW oWndFile ;
  57.           VALID ( oFile:Close(), oWndFile := nil, .t. )            // Destroy the Object
  58.     else
  59.        MsgInfo( "I can't open that file" )
  60.     endif
  61.  
  62. return nil
  63.  
  64. //---------------------------------------------------------------------------//
  65.