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

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