home *** CD-ROM | disk | FTP | other *** search
/ Programmer 7500 / MAX_PROGRAMMERS.iso / CLIPPER / MISC / CLIPDEMO.ZIP / EDIT.TXT < prev    next >
Encoding:
Text File  |  1988-01-25  |  4.0 KB  |  78 lines

  1. ***************************************************************************
  2. * This PROCEDURE takes advantage of CLIPPER's memofield functions         *
  3. * and uses them as a text editor.  These functions can be used on         *
  4. * any character variable as well as memofields.                           *
  5. * The functions and their syntax are listed below.                        *
  6. *                                                                         *
  7. *  1) MEMOEDIT(memo, t, l, b, r, update,ufunc,line_length,tabsize,;       *
  8. *              initial_line,initial_col,relative_row,relative_col)        *
  9. *                                                                         *
  10. *        where:                                                           *
  11. *              memo  =  memo to edit                                      *
  12. *              t, l, b, r = window definition                             *
  13. *              update  =  update allowed (default TRUE)                   *
  14. *              ufunc   = <expC> name of user function to handle exceptions*
  15. *              line_length = virtual width and allows horizontal scrolling*
  16. *              tabsize  =  spaces between regular tab stops (default = 4) *
  17. *              initial_line = initial line where the cursor is placed     *
  18. *              initial_col = initial column where the cursor is placed    *
  19. *              relative_row = initial row of the cursor relative to window*
  20. *              relative_col = initial col of the cursor relative to window*
  21. *                                                                         *
  22. *  2) MEMOREAD(file)                                                      *
  23. *                                                                         *
  24. *        where:                                                           *
  25. *             file  = the name of the file to read from disk              *
  26. *                                                                         *
  27. *  3) MEMOWRIT(file, variable)                                            *
  28. *                                                                         *
  29. *        where:                                                           *
  30. *             file  =  the name of the file to write to disk              *
  31. *             variable  =  a character variable to store the file contents*
  32. ***************************************************************************
  33.  
  34.  
  35. PROCEDURE EDITOR
  36.  
  37.   file_pattern = "*.txt"             && The files to edit.
  38.   @ 0, 0 CLEAR
  39.   aray_siz = ADIR(file_pattern)       && The amount of files.
  40.   DECLARE aray_dir[aray_siz]          && Create array.
  41.   ADIR(file_pattern,aray_dir)         && Fill array.
  42.   DO WHILE .T.
  43.     BOXIT(0,0,24,79,2)
  44.     @ 2, 2 TO  4 + aray_siz,17 DOUBLE && Draw box.
  45.     @ 3, 3 CLEAR TO 3 + aray_siz,16   && Clear box.
  46.     mess = "Select a file to EDIT, or <Esc> to exit"
  47.     mess2 = "(hint -> choose <EDIT.TXT> to VIEW the source code)"
  48.     @ 1, 4 get mess
  49.     @ 5,20 get mess2
  50.     clear gets
  51.     FOR file_name = 1 to aray_siz
  52.       @ 3 + file_name,4 PROMPT aray_dir[file_name]
  53.     NEXT                              && Place file names
  54.     MENU TO which_one                 && on screen in menu.
  55.     IF which_one = 0                  && If escape key was entered
  56.       RETURN                          && leave the progam.
  57.     ENDIF
  58.     @ 0,0 CLEAR
  59.     SET FUNCTION 3 to chr(23)     
  60.     mess = "<F3> to save and exit, <Esc> to exit"
  61.     @ 1,10 get mess
  62.     CLEAR GETS
  63.     @ 2,0 to 24,79 double
  64.     IF aray_dir[which_one] = "EDIT.TXT"                   && if EDIT.TXT
  65.          MEMOWRIT(aray_dir[which_one],MEMOEDIT(MEMOREAD ; &&    browes it
  66.              (aray_dir[which_one]),3,1,23,78,.F.))    && othewise
  67.     ELSE                                                  &&    edit it.  
  68.          MEMOWRIT(aray_dir[which_one],MEMOEDIT(MEMOREAD ; 
  69.                  (aray_dir[which_one]),3,1,23,78)) 
  70.     ENDIF
  71.     SET FUNCTION 3 TO
  72.      @ 0, 0 CLEAR
  73.   ENDDO
  74.  
  75. *END PROCEDURE  
  76.  
  77.  
  78.