home *** CD-ROM | disk | FTP | other *** search
- // GetSect.prg
- //
- // Get reader implementing GET ... SECTION
-
- #include "Getexit.ch"
- #include "Inkey.ch"
-
- MEMVAR GetList
-
- PROCEDURE SectReader( oGet )
-
- LOCAL nKey
- LOCAL nSect := DictAt(oGet:cargo, "SEC #")
- 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 )
- nKey := InKey(0)
- DO CASE
- CASE nKey == K_TAB
- oGet:exitState := GE_DOWN
- GoToGet(NextSection(oGet, GetList))
-
- CASE nKey == K_SH_TAB
- oGet:exitState := GE_UP
- GoToGet(PrevSection(oGet, GetList))
-
- OTHERWISE
- GetApplyKey( oGet, nKey )
- ENDCASE
- 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 NextSection(oGet)
-
- LOCAL oCurrentSection := DictAt(oGet:cargo, "SEC #")
- LOCAL aSections := SectionStarts()
-
- RETURN aSections[oCurrentSection % Len(aSections) + 1, 2]
-
-
- FUNCTION PrevSection(oGet)
-
- LOCAL oCurrentSection := DictAt(oGet:cargo, "SEC #")
- LOCAL aSections := SectionStarts()
-
- RETURN iif(oCurrentSection == 1, ;
- aSections[Len(aSections), 2], ;
- aSections[(oCurrentSection - 1) % Len(aSections), 2])
-
-
- FUNCTION GetSecStarts(GetList)
-
- LOCAL aSectionStarts := {}
- LOCAL nGets := Len(GetList)
- LOCAL i
- LOCAL aCargo
-
- FOR i := 1 TO nGets
- aCargo := GetList[i]:cargo
- IF Ascan(aSectionStarts, ;
- {|e| e[1] == DictAt(aCargo, "SEC #") } ) == 0
- Aadd(aSectionStarts, ;
- { DictAt(aCargo, "SEC #"), i })
- ENDIF
- NEXT
-
- RETURN aSectionStarts
-
-
- // Get / Set array containing section start / get # pairs
-
- FUNCTION SectionStarts(aSecs)
-
- STATIC aSectionStarts := {}
- LOCAL aOldStarts := aSectionStarts
-
- IF Pcount() > 0
- aSectionStarts := aSecs
- ENDIF
-
- RETURN aOldStarts