home *** CD-ROM | disk | FTP | other *** search
- // Getex05.prg
- //
- // GoToGet - pass name for get var rather than number
- //
- // Reworked version of gets20.prg
-
- #include "Getexit.ch"
- #include "Inkey.ch"
-
- #command READ ALLOWING MOVE ;
- => ;
- Aeval(GetList, ;
- {|o| o:Reader := {|o1| GetMoveReader(o1)} }) ;
- ; ReadModal(GetList); GetList := {}
-
- MEMVAR GetList
-
- FUNCTION Getex05
-
- LOCAL cVar1 := "cVar1", ;
- cVar2 := "cVar2", ;
- cVar3 := "cVar3", ;
- cVar4 := "cVar4"
-
- CLEAR SCREEN
- @ 10, 10 GET cVar1 ;
- VALID iif(LastKey() == K_DOWN, (GoToGet("cVar3"), .T.), .T.)
-
- @ 10, 40 GET cVar2 ;
- VALID iif(LastKey() == K_DOWN, (GoToGet("cVar4"), .T.), .T.)
-
- @ 11, 10 GET cVar3 ;
- VALID iif(LastKey() == K_UP, (GoToGet("cVar1"), .T.), .T.)
-
- @ 11, 40 GET cVar4 ;
- VALID iif(LastKey() == K_UP, (GoToGet("cVar2"), .T.), .T.)
-
- READ ALLOWING MOVE
-
- RETURN NIL
-
-
- proc GetMoveReader( oGet )
-
- LOCAL nCurrentGet
-
- nCurrentGet := Ascan(GetList, {|o| o == oGet })
- IF !(GetMovingTo() == NIL) .AND. nCurrentGet != GetMovingTo()
- IF nCurrentGet > GetMovingTo()
- oGet:exitState := GE_UP
- ELSE
- oGet:exitState := GE_DOWN
- ENDIF
- ELSE
- GetMovingTo(NIL)
- // read the GET if the WHEN condition is satisfied
- IF ( GetPreValidate(oGet) )
- // activate the GET for reading
- oGet:SetFocus()
-
- DO WHILE ( oGet:exitState == GE_NOEXIT )
- // check for initial typeout (no editable positions)
- IF ( oGet:typeOut )
- oGet:exitState := GE_ENTER
- ENDIF
-
- // apply keystrokes until exit
- DO WHILE ( oGet:exitState == GE_NOEXIT )
- GetApplyKey(oGet, InKey(0))
- ENDDO
-
- // disallow exit if the VALID condition is not satisfied
- IF ( !GetPostValidate(oGet) )
- oGet:exitState := GE_NOEXIT
- ENDIF
- ENDDO
-
- // de-activate the GET
- oGet:KillFocus()
- ENDIF
- ENDIF
-
- RETURN
-
-
- FUNCTION GoToGet(cVarName)
-
- LOCAL oGetCurrent := GetActive()
- LOCAL nGetCurrent := Ascan(GetList, {|o| o == oGetCurrent})
- LOCAL nNewGet := Ascan(GetList, ;
- {|o| Trim(Upper(o:name)) == Upper(cVarName) })
-
- IF nGetCurrent > nNewGet
- oGetCurrent:exitState := GE_UP
- ELSE
- oGetCurrent:exitState := GE_DOWN
- ENDIF
- GetMovingTo(nNewGet)
-
- RETURN NIL
-
-
- FUNCTION GetMovingTo(n)
-
- STATIC nWhereToGo
- LOCAL nOldWhereGo := nWhereToGo
-
- IF Pcount() > 0
- nWhereToGo := n
- ENDIF
-
- RETURN nOldWhereGo
-