home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 5 / 05.iso / a / a067 / 1.img / GRUMP501.EXE / MEMEDIT.PRG < prev    next >
Encoding:
Text File  |  1991-06-09  |  2.9 KB  |  105 lines

  1. /*
  2.     Program: MEMEDIT()
  3.     System: GRUMPFISH LIBRARY
  4.     Author: Greg Lief
  5.     Copyright (c) 1988-90, Greg Lief
  6.     Special thanks to Matt Amis for his suggestions!!
  7.     Clipper 5.01 Version
  8.     Compile instructions: clipper memedit /n/w/a
  9.  
  10.     Procs & Fncts: MEMEDIT()
  11.                    ESCFUNC()
  12.  
  13.     Calls: SHADOWBOX()   (function in SHADOWBO.PRG)
  14.  
  15.     Generic memo editing function
  16. */
  17.  
  18. //───── begin preprocessor directives
  19.  
  20. #include "grump.ch"
  21. #include "inkey.ch"
  22. #include "memoedit.ch"
  23.  
  24. //───── end preprocessor directives
  25.  
  26. function memedit(cfield, ntop, nleft, nbottom, nright, msg, leditit)
  27. local ret_val := .t., memo, oldexact := set(_SET_EXACT, .T.)
  28. default ntop to 5
  29. default nleft to 10
  30. default nbottom to 19
  31. default nright to 69
  32. default msg to []
  33. default leditit to .t.
  34. gfsaveenv( .t., 3 )               // make cursor large
  35. ColorSet(C_MEMEDIT_BOX)
  36. Shadowbox(ntop, nleft, nbottom, nright, 1, msg)
  37. @ nbottom, nleft + INT(nright - nleft) / 2 - 12 SAY ;
  38.    if(leditit, 'Ctrl-W to save,', ' to move, or') + ' Esc to exit'
  39. ColorSet(C_MEMEDIT_WINDOW)
  40. scroll(ntop + 1, nleft + 1, nbottom - 1, nright - 1, 0)
  41. /*
  42.    if we are editing a field, FIELDBLOCK() will not return NIL.
  43.    if we are editing a PUBLIC or PRIVATE, MEMVARBLOCK() will not return NIL.
  44. */
  45. if (memo := fieldblock(cfield)) = NIL .and. (memo := memvarblock(cfield)) = NIL
  46.    memo := cfield
  47. else
  48.    memo := eval(memo)
  49. endif
  50. memo := memoedit(memo, ntop + 1, nleft + 1, nbottom - 1, nright - 1, ;
  51.                  leditit, 'escfunc', , 3)
  52. //───── the following block is relevant only when we are editing
  53. if leditit
  54.    if lastkey() != K_ESC
  55.       do case
  56.  
  57.          //───── we edited a field */
  58.          case fieldpos(cfield) != 0
  59.             if rlock()
  60.                fieldput(fieldpos(cfield) , memo)
  61.                unlock
  62.             else
  63.                err_msg(NETERR_MSG)     /* see GRUMP.CH */
  64.                ret_val := .f.
  65.             endif
  66.  
  67.          //───── we edited a private or public variable
  68.          case memvarblock(cfield) != NIL
  69.             eval( memvarblock(cfield) , memo)
  70.  
  71.          //───── we edited a local or static variable
  72.          otherwise
  73.             cfield := memo
  74.       endcase
  75.    else
  76.       ret_val := .f.
  77.    endif
  78. endif
  79. gfrestenv()
  80. set(_SET_EXACT, oldexact)
  81. return ret_val
  82.  
  83. * end function MemEdit()
  84. *--------------------------------------------------------------------*
  85.  
  86.  
  87. function EscFunc(stat, line, col)
  88. //───── Alters "ABORT Y/N" msg if Esc is hit during Memoedit
  89. //───── only if changes have been made, otherwise skip this routine
  90. local buffer
  91. if lastkey() = K_ESC .and. stat = 2
  92.    buffer := savescreen(0, 60, 0, 75)
  93.    @ 0,60 ssay 'MEMO NOT UPDATED'
  94.    tone(MUSIC_ALERT, 1)
  95.    tone(MUSIC_ALERT, 1)
  96.    inkey(1)
  97.    restscreen(0, 60, 0, 75, buffer)
  98. endif
  99. return ME_DEFAULT
  100.  
  101. * end function EscFunc()
  102. *--------------------------------------------------------------------*
  103.  
  104. * eof memedit.prg
  105.