home *** CD-ROM | disk | FTP | other *** search
- /*
- Program: MEMEDIT()
- System: GRUMPFISH LIBRARY
- Author: Greg Lief
- Copyright (c) 1988-90, Greg Lief
- Special thanks to Matt Amis for his suggestions!!
- Clipper 5.01 Version
- Compile instructions: clipper memedit /n/w/a
-
- Procs & Fncts: MEMEDIT()
- ESCFUNC()
-
- Calls: SHADOWBOX() (function in SHADOWBO.PRG)
-
- Generic memo editing function
- */
-
- //───── begin preprocessor directives
-
- #include "grump.ch"
- #include "inkey.ch"
- #include "memoedit.ch"
-
- //───── end preprocessor directives
-
- function memedit(cfield, ntop, nleft, nbottom, nright, msg, leditit)
- local ret_val := .t., memo, oldexact := set(_SET_EXACT, .T.)
- default ntop to 5
- default nleft to 10
- default nbottom to 19
- default nright to 69
- default msg to []
- default leditit to .t.
- gfsaveenv( .t., 3 ) // make cursor large
- ColorSet(C_MEMEDIT_BOX)
- Shadowbox(ntop, nleft, nbottom, nright, 1, msg)
- @ nbottom, nleft + INT(nright - nleft) / 2 - 12 SAY ;
- if(leditit, 'Ctrl-W to save,', ' to move, or') + ' Esc to exit'
- ColorSet(C_MEMEDIT_WINDOW)
- scroll(ntop + 1, nleft + 1, nbottom - 1, nright - 1, 0)
- /*
- if we are editing a field, FIELDBLOCK() will not return NIL.
- if we are editing a PUBLIC or PRIVATE, MEMVARBLOCK() will not return NIL.
- */
- if (memo := fieldblock(cfield)) = NIL .and. (memo := memvarblock(cfield)) = NIL
- memo := cfield
- else
- memo := eval(memo)
- endif
- memo := memoedit(memo, ntop + 1, nleft + 1, nbottom - 1, nright - 1, ;
- leditit, 'escfunc', , 3)
- //───── the following block is relevant only when we are editing
- if leditit
- if lastkey() != K_ESC
- do case
-
- //───── we edited a field */
- case fieldpos(cfield) != 0
- if rlock()
- fieldput(fieldpos(cfield) , memo)
- unlock
- else
- err_msg(NETERR_MSG) /* see GRUMP.CH */
- ret_val := .f.
- endif
-
- //───── we edited a private or public variable
- case memvarblock(cfield) != NIL
- eval( memvarblock(cfield) , memo)
-
- //───── we edited a local or static variable
- otherwise
- cfield := memo
- endcase
- else
- ret_val := .f.
- endif
- endif
- gfrestenv()
- set(_SET_EXACT, oldexact)
- return ret_val
-
- * end function MemEdit()
- *--------------------------------------------------------------------*
-
-
- function EscFunc(stat, line, col)
- //───── Alters "ABORT Y/N" msg if Esc is hit during Memoedit
- //───── only if changes have been made, otherwise skip this routine
- local buffer
- if lastkey() = K_ESC .and. stat = 2
- buffer := savescreen(0, 60, 0, 75)
- @ 0,60 ssay 'MEMO NOT UPDATED'
- tone(MUSIC_ALERT, 1)
- tone(MUSIC_ALERT, 1)
- inkey(1)
- restscreen(0, 60, 0, 75, buffer)
- endif
- return ME_DEFAULT
-
- * end function EscFunc()
- *--------------------------------------------------------------------*
-
- * eof memedit.prg
-