home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 5 / 05.iso / a / a054 / 1.img / GETPRGS.EXE / GETS13.PRG < prev    next >
Encoding:
Text File  |  1992-03-08  |  3.8 KB  |  157 lines

  1. /***
  2. * Gets13.prg
  3. *
  4. * Reader for memo get
  5. */
  6.  
  7. #include "Getexit.ch"
  8. #include "InKey.ch"
  9.  
  10. // Note - cannot use _GET as it uses oGet:display() before
  11. // we can change var to "memo"
  12. #command @ <row>, <col> GET <var>                                      ;
  13.                         MEMO AT <t>, <l>, <b>, <r>                     ;
  14.                         [VALID <valid>]                                ;
  15.                         [WHEN  <when> ]                                ;
  16.                                                                        ;
  17.          =>                                                            ;
  18.          SetPos( <row>, <col> )                                        ;
  19.      ; Aadd(GetList,                                               ;
  20.               MemoGetNew( <var>,                                       ;
  21.                          {|x| iif( x == NIL, "Memo", <var> := x ) },   ;
  22.                          <(var)>, <{valid}>, <{when}>,                 ;
  23.                          {<t>, <l>, <b>, <r>} ))                       ;
  24.          ; Atail(GetList):reader := {|oGet| MemoReader(oGet) }         ;
  25.          ; Atail(GetList):display()
  26.  
  27. MEMVAR GetList
  28.  
  29. FUNCTION Gets13
  30.  
  31. LOCAL cVar1 := Space(10), ;
  32.       cVar2 := "This is the memo var", ;
  33.       cVar3 := Space(12)
  34.  
  35.   CLEAR SCREEN
  36.   @ 10, 10 SAY "Enter cVar" GET cVar1
  37.   @ 11, 10 SAY "Enter cVar" GET cVar2 MEMO AT 10, 10, 20, 20
  38.   @ 12, 10 SAY "Enter cVar" GET cVar3
  39.  
  40.   READ
  41.  
  42. RETURN NIL
  43.  
  44. #define VAR_ELEM     1
  45. #define COORDS_ELEM  2
  46.  
  47. proc MemoReader( oGet )
  48.  
  49.   // read the GET if the WHEN condition is satisfied
  50.   IF ( GetPreValidate(oGet) )
  51.     // activate the GET for reading
  52.     oGet:SetFocus()
  53.  
  54.     DO WHILE ( oGet:exitState == GE_NOEXIT )
  55.       // apply keystrokes until exit
  56.       DO WHILE ( oGet:exitState == GE_NOEXIT )
  57.         GetMemoApplyKey(oGet, InKey(0))
  58.       ENDDO
  59.  
  60.       // disallow exit if the VALID condition is not satisfied
  61.       IF ( !GetPostValidate(oGet) )
  62.         oGet:exitState := GE_NOEXIT
  63.       ENDIF
  64.     ENDDO
  65.  
  66.     // de-activate the GET
  67.     oGet:KillFocus()
  68.   ENDIF
  69.  
  70. RETURN
  71.  
  72.  
  73. FUNCTION EditMemo(oGet)
  74.  
  75. LOCAL t, l, b, r, aCoords, cSaveScreen, nRow, nCol
  76.  
  77.   aCoords := oGet:cargo[COORDS_ELEM]
  78.   t := aCoords[1]
  79.   l := aCoords[2]
  80.   b := aCoords[3]
  81.   r := aCoords[4]
  82.  
  83.   cSaveScreen := SaveScreen(t, l, b, r)
  84.   nRow := Row()
  85.   nCol := Col()
  86.  
  87.   @ t, l CLEAR TO b, r
  88.   @ t, l TO b, r
  89.   oGet:cargo[VAR_ELEM] := MemoEdit(oGet:cargo[VAR_ELEM], ;
  90.                                    t + 1, l + 1, b - 1, r - 1)
  91.   oGet:VarPut(oGet:cargo[VAR_ELEM])
  92.   oGet:updateBuffer()
  93.   DevPos(nRow, nCol)
  94.   RestScreen(t, l, b, r, cSaveScreen)
  95.  
  96. RETURN NIL
  97.  
  98.  
  99. FUNCTION MemoGetNew(cVar, bBlock, cName, bvalid, bWhen, aMemoCoords)
  100.  
  101. LOCAL oGet := GetNew(Row(), Col(), bBlock, cname)
  102.  
  103.   oGet:postBlock := bValid
  104.   oGet:preBlock  := bWhen
  105.   oGet:cargo     := {cVar, aMemoCoords}
  106.  
  107. RETURN oGet
  108.  
  109.  
  110. FUNCTION GetMemoApplyKey(oGet, nKey)
  111.  
  112. LOCAL bKeyBlock
  113.  
  114.   // check for SET KEY first
  115.   IF ( (bKeyBlock := SetKey(nKey)) <> NIL )
  116.     GetDoSetKey(bKeyBlock, oGet)
  117.     RETURN NIL                 // NOTE
  118.   ENDIF
  119.  
  120.   DO CASE
  121.     CASE nKey == K_UP
  122.       oGet:exitState := GE_UP
  123.  
  124.     CASE nKey == K_SH_TAB
  125.       oGet:exitState := GE_UP
  126.  
  127.     CASE nKey == K_DOWN
  128.       oGet:exitState := GE_DOWN
  129.  
  130.     CASE nKey == K_TAB
  131.       oGet:exitState := GE_DOWN
  132.  
  133.     CASE nKey == K_ENTER
  134.       oGet:exitState := GE_ENTER
  135.  
  136.     CASE nKey == K_ESC
  137.       IF Set(_SET_ESCAPE)
  138.         oGet:exitState := GE_ESCAPE
  139.       ENDIF
  140.  
  141.     CASE nKey == K_PGUP
  142.       oGet:exitState := GE_WRITE
  143.  
  144.     CASE nKey == K_PGDN
  145.       oGet:exitState := GE_WRITE
  146.  
  147.     CASE nKey == K_CTRL_HOME
  148.       oGet:exitState := GE_TOP
  149.  
  150.     CASE nKey == K_CTRL_PGDN
  151.       EditMemo(oGet)
  152.       oGet:exitState := GE_ENTER
  153.  
  154.   ENDCASE
  155.  
  156. RETURN NIL
  157.