home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 5 / 05.iso / a / a054 / 1.img / GETLIB.EXE / MEMOREAD.PRG < prev    next >
Encoding:
Text File  |  1992-03-09  |  2.4 KB  |  121 lines

  1. // MemoRead.prg
  2. //
  3. // Get reader for memo fields
  4.  
  5. #define VAR_ELEM     1
  6. #define COORDS_ELEM  2
  7.  
  8. #include "Getexit.ch"
  9. #include "Inkey.ch"
  10.  
  11. proc MemoReader( oGet )
  12.  
  13.   // read the GET if the WHEN condition is satisfied
  14.   IF ( GetPreValidate(oGet) )
  15.     // activate the GET for reading
  16.     oGet:SetFocus()
  17.  
  18.     DO WHILE ( oGet:exitState == GE_NOEXIT )
  19.       // apply keystrokes until exit
  20.       DO WHILE ( oGet:exitState == GE_NOEXIT )
  21.         GetMemoApplyKey(oGet, InKey(0))
  22.       ENDDO
  23.  
  24.       // disallow exit if the VALID condition is not satisfied
  25.       IF ( !GetPostValidate(oGet) )
  26.         oGet:exitState := GE_NOEXIT
  27.       ENDIF
  28.     ENDDO
  29.  
  30.     // de-activate the GET
  31.     oGet:KillFocus()
  32.   ENDIF
  33.  
  34. RETURN
  35.  
  36.  
  37. FUNCTION EditMemo(oGet)
  38.  
  39. LOCAL t, l, b, r, aCoords, cSaveScreen, nRow, nCol
  40.  
  41.   aCoords := oGet:cargo[COORDS_ELEM]
  42.   t := aCoords[1]
  43.   l := aCoords[2]
  44.   b := aCoords[3]
  45.   r := aCoords[4]
  46.  
  47.   cSaveScreen := SaveScreen(t, l, b, r)
  48.   nRow := Row()
  49.   nCol := Col()
  50.  
  51.   @ t, l CLEAR TO b, r
  52.   @ t, l TO b, r
  53.   oGet:cargo[VAR_ELEM] := MemoEdit(oGet:cargo[VAR_ELEM], ;
  54.                                    t + 1, l + 1, b - 1, r - 1)
  55.   oGet:VarPut(oGet:cargo[VAR_ELEM])
  56.   oGet:updateBuffer()
  57.   DevPos(nRow, nCol)
  58.   RestScreen(t, l, b, r, cSaveScreen)
  59.  
  60. RETURN NIL
  61.  
  62.  
  63. FUNCTION MemoGetNew(cVar, bBlock, cName, bvalid, bWhen, aMemoCoords)
  64.  
  65. LOCAL oGet := GetNew(Row(), Col(), bBlock, cname)
  66.  
  67.   oGet:postBlock := bValid
  68.   oGet:preBlock  := bWhen
  69.   oGet:cargo     := {cVar, aMemoCoords}
  70.  
  71. RETURN oGet
  72.  
  73.  
  74. FUNCTION GetMemoApplyKey(oGet, nKey)
  75.  
  76. LOCAL bKeyBlock
  77.  
  78.   // check for SET KEY first
  79.   IF ( (bKeyBlock := SetKey(nKey)) <> NIL )
  80.     GetDoSetKey(bKeyBlock, oGet)
  81.     RETURN NIL                 // NOTE
  82.   ENDIF
  83.  
  84.   DO CASE
  85.     CASE nKey == K_UP
  86.       oGet:exitState := GE_UP
  87.  
  88.     CASE nKey == K_SH_TAB
  89.       oGet:exitState := GE_UP
  90.  
  91.     CASE nKey == K_DOWN
  92.       oGet:exitState := GE_DOWN
  93.  
  94.     CASE nKey == K_TAB
  95.       oGet:exitState := GE_DOWN
  96.  
  97.     CASE nKey == K_ENTER
  98.       oGet:exitState := GE_ENTER
  99.  
  100.     CASE nKey == K_ESC
  101.       IF Set(_SET_ESCAPE)
  102.         oGet:exitState := GE_ESCAPE
  103.       ENDIF
  104.  
  105.     CASE nKey == K_PGUP
  106.       oGet:exitState := GE_WRITE
  107.  
  108.     CASE nKey == K_PGDN
  109.       oGet:exitState := GE_WRITE
  110.  
  111.     CASE nKey == K_CTRL_HOME
  112.       oGet:exitState := GE_TOP
  113.  
  114.     CASE nKey == K_CTRL_PGDN
  115.       EditMemo(oGet)
  116.       oGet:exitState := GE_ENTER
  117.  
  118.   ENDCASE
  119.  
  120. RETURN NIL
  121.