home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 5 / 05.iso / a / a054 / 1.img / GETEXS.EXE / GETEX05.PRG < prev    next >
Encoding:
Text File  |  1992-03-16  |  2.6 KB  |  114 lines

  1. // Getex05.prg
  2. //
  3. // GoToGet - pass name for get var rather than number
  4. //
  5. // Reworked version of gets20.prg
  6.  
  7. #include "Getexit.ch"
  8. #include "Inkey.ch"
  9.  
  10. #command READ ALLOWING MOVE                                    ;
  11.          =>                                                    ;
  12.          Aeval(GetList,                                        ;
  13.                {|o| o:Reader := {|o1| GetMoveReader(o1)} })    ;
  14.          ; ReadModal(GetList); GetList := {}
  15.  
  16. MEMVAR GetList
  17.  
  18. FUNCTION Getex05
  19.  
  20. LOCAL cVar1 := "cVar1", ;
  21.       cVar2 := "cVar2", ;
  22.       cVar3 := "cVar3", ;
  23.       cVar4 := "cVar4"
  24.  
  25.   CLEAR SCREEN
  26.   @ 10, 10 GET cVar1 ;
  27.     VALID iif(LastKey() == K_DOWN,  (GoToGet("cVar3"), .T.), .T.)
  28.  
  29.   @ 10, 40 GET cVar2 ;
  30.     VALID iif(LastKey() == K_DOWN,  (GoToGet("cVar4"), .T.), .T.)
  31.  
  32.   @ 11, 10 GET cVar3 ;
  33.     VALID iif(LastKey() == K_UP,    (GoToGet("cVar1"), .T.), .T.)
  34.  
  35.   @ 11, 40 GET cVar4 ;
  36.     VALID iif(LastKey() == K_UP,    (GoToGet("cVar2"), .T.), .T.)
  37.  
  38.   READ ALLOWING MOVE
  39.  
  40. RETURN NIL
  41.  
  42.  
  43. proc GetMoveReader( oGet )
  44.  
  45. LOCAL nCurrentGet
  46.  
  47.   nCurrentGet := Ascan(GetList, {|o| o == oGet })
  48.   IF !(GetMovingTo() == NIL) .AND. nCurrentGet != GetMovingTo()
  49.     IF nCurrentGet > GetMovingTo()
  50.       oGet:exitState := GE_UP
  51.     ELSE
  52.       oGet:exitState := GE_DOWN
  53.     ENDIF
  54.   ELSE
  55.     GetMovingTo(NIL) 
  56.     // read the GET if the WHEN condition is satisfied
  57.     IF ( GetPreValidate(oGet) )
  58.       // activate the GET for reading
  59.       oGet:SetFocus()
  60.  
  61.       DO WHILE ( oGet:exitState == GE_NOEXIT )
  62.         // check for initial typeout (no editable positions)
  63.         IF ( oGet:typeOut )
  64.           oGet:exitState := GE_ENTER
  65.         ENDIF
  66.  
  67.         // apply keystrokes until exit
  68.         DO WHILE ( oGet:exitState == GE_NOEXIT )
  69.           GetApplyKey(oGet, InKey(0))
  70.         ENDDO
  71.  
  72.         // disallow exit if the VALID condition is not satisfied
  73.         IF ( !GetPostValidate(oGet) )
  74.           oGet:exitState := GE_NOEXIT
  75.         ENDIF
  76.       ENDDO
  77.  
  78.       // de-activate the GET
  79.       oGet:KillFocus()
  80.     ENDIF
  81.   ENDIF
  82.  
  83. RETURN
  84.  
  85.  
  86. FUNCTION GoToGet(cVarName)
  87.  
  88. LOCAL oGetCurrent := GetActive()
  89. LOCAL nGetCurrent := Ascan(GetList, {|o| o == oGetCurrent})
  90. LOCAL nNewGet := Ascan(GetList, ;
  91.                        {|o| Trim(Upper(o:name)) == Upper(cVarName) })
  92.  
  93.   IF nGetCurrent > nNewGet
  94.     oGetCurrent:exitState := GE_UP
  95.   ELSE
  96.     oGetCurrent:exitState := GE_DOWN
  97.   ENDIF
  98.   GetMovingTo(nNewGet)
  99.  
  100. RETURN NIL
  101.  
  102.  
  103. FUNCTION GetMovingTo(n)
  104.  
  105. STATIC nWhereToGo
  106. LOCAL  nOldWhereGo := nWhereToGo
  107.  
  108.   IF Pcount() > 0
  109.     nWhereToGo := n
  110.   ENDIF
  111.  
  112. RETURN nOldWhereGo
  113.  
  114.