home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 5 / 05.iso / a / a013 / 1.ddi / SOURCE.EXE / F_MMOVEW.PRG < prev    next >
Encoding:
Text File  |  1991-01-25  |  3.1 KB  |  108 lines

  1. *****************************************************************
  2. FUNCTION MEMOVIEW
  3. *****************************************************************
  4.  
  5. * Display or edit a memo in a predefined window
  6.  
  7. * Copyright(c) 1991 - James Occhiogrosso
  8.  
  9. #include "setcurs.ch"
  10.  
  11. LOCAL infoline, old_screen, old_color, spacing
  12.  
  13. PARAMETERS format, memo_name, top, left, bottom, right, update, ;
  14.            userfunc, line_len, tab_size, start_line, start_col, ;
  15.            init_row, init_col
  16.  
  17. * If you wish to use your own control function, instead of
  18. * MEMOCTRL remove the EXTERNAL declaration line below.
  19.  
  20. EXTERNAL MEMOCTRL
  21.  
  22. IF PCOUNT() < 2
  23.     * Not enough parameters. Give it back
  24.     RETURN(memo_name)
  25.  
  26. ELSEIF PCOUNT() >= 2 .AND. PCOUNT() < 6
  27.     * Set up full screen MEMOEDIT with default control function
  28.     top = 0
  29.     left = 0
  30.     bottom = 24
  31.     right = 79
  32.     update = .T.
  33.     userfunc = "MEMOCTRL"
  34.  
  35. ELSEIF PCOUNT() = 6
  36.     * Use passed coordinates with default control function.
  37.     update = .T.
  38.     userfunc = "MEMOCTRL"
  39.  
  40. ELSEIF PCOUNT() = 7
  41.     * Use passed coordinates with default control function.
  42.     userfunc = "MEMOCTRL"
  43. ENDIF
  44.  
  45. * Define defaults for other parameters not passed
  46.  
  47. line_len   = IF(line_len   == NIL, (right-left)-1, line_len)
  48. tab_size   = IF(tab_size   == NIL, 4, tab_size)
  49. start_line = IF(start_line == NIL, 1, start_line)
  50. start_col  = IF(start_col  == NIL, 0, start_col)
  51. init_row   = IF(init_row   == NIL, 0, init_row)
  52. init_col   = IF(init_col   == NIL, 0, init_col)
  53.  
  54.  
  55. * Save old color setting
  56. old_color = SETCOLOR()
  57.  
  58. * Save current insert key setting as a block
  59. bInsert_key := SETKEY(22)
  60.  
  61. * Clear insert key and display cursor in appropriate size
  62. SET KEY 22 TO
  63. CSRINSERT(,,, .F.)
  64.  
  65. * Set up message variable
  66. message = ' Press F2 for edit keys '
  67.  
  68. * Save the screen area to be used
  69. old_screen = SCRNSAVE(top,left,bottom,right)
  70.  
  71. IF format
  72.  
  73.     * Clear memo area, draw a box, and display initial message.
  74.     SETCOLOR(colhelp2)
  75.     @ top, left, bottom, right BOX '┌─┐│┘─└│ '
  76.     spacing = (((right - left)-2) - LEN(message)) / 2
  77.     @ bottom, left + 1 SAY REPLICATE('─',spacing) + message + ;
  78.                            REPLICATE('─',spacing)
  79.  
  80.     * Display insert status
  81.     IF update
  82.         @ top, right-12 SAY " Insert " + IF(READINSERT(), ;
  83.                             "on ", "off ")
  84.     ENDIF
  85.  
  86.     * Edit the memo inside boxed area
  87.      memo_name = MEMOEDIT(memo_name, top+1, left+2, bottom-1,  ;
  88.                           right-1, update, userfunc, line_len, ;
  89.                           tab_size, start_line, start_col,     ;
  90.                           init_row, init_col)
  91.  
  92. ELSE
  93.     * Edit the memo without special formatting
  94.     SETCOLOR(colmemoget)
  95.     memo_name = MEMOEDIT(memo_name, top, left, bottom, right,  ;
  96.                          update, userfunc, line_len, tab_size, ;
  97.                          start_line, start_col, init_row,      ;
  98.                          init_col)
  99. ENDIF
  100.  
  101. * Restore starting conditions
  102.  
  103. SETCOLOR(old_color)
  104. SCRNREST(old_screen)
  105. SETKEY(22, bInsert_key)
  106. RETURN (memo_name)
  107.  
  108.