home *** CD-ROM | disk | FTP | other *** search
- /***
- * Gets22.prg
- *
- * GETs in SECTIONs. TAB key moves to start of next section,
- * SH-TAB to previous section.
- */
-
- #command @ <row>, <col> GET <var> ;
- [<clauses,...>] ;
- SECTION <nSection> ;
- [<moreClauses,...>] ;
- => ;
- @ <row>, <col> GET <var> ;
- [<clauses>] ;
- [<moreClauses>] ; ;
- Atail(getList):cargo := DictNew() ;
- ; DictPutPair(Atail(getList):cargo, {"SEC #", <nSection>}) ;
- ; Atail(getList):reader := {|oGet| SectReader(oGet)}
-
- #command READ SECTION ;
- => ;
- SectionStarts(GetSecStarts(GetList)) ;
- ; ReadModal(GetList); GetList := {} ;
- ; SectionStarts(NIL)
-
- #include "Inkey.ch"
- #include "Getexit.ch"
-
- MEMVAR GetList
-
- FUNCTION Gets22
-
- LOCAL cLname, cFname, cAddr1, cAddr2, cAddr3, cTel
- LOCAL cCard, cCardNum
- LOCAL nDbls, nSgls, nSglSuites, nDblSuites, nReservation
- LOCAL aSecStarts
-
- SET SCOREBOARD OFF
- cLname := Space(15)
- cFname := Space(15)
- cAddr1 := Space(20)
- cAddr2 := Space(20)
- cAddr3 := Space(20)
- cTel := Space(20)
-
- CLEAR SCREEN
- @ 0, 0 TO 24, 79
- @ 1, 2 SAY "Name" COLOR "W+/N"
- @ 2, 2 SAY " Last Name [" + Space(Len(cLname)) + "]"
- @ 2, 14 GET cLname SECTION 1
- @ 3, 2 SAY "First Name [" + Space(Len(cFname)) + "]"
- @ 3, 14 GET cFname SECTION 1
- @ 4, 2 SAY " Address [" + Space(Len(cAddr1)) + "]"
- @ 4, 14 GET cAddr1 SECTION 1
- @ 5, 2 SAY " [" + Space(Len(cAddr2)) + "]"
- @ 5, 14 GET cAddr2 SECTION 1
- @ 6, 2 SAY " [" + Space(Len(cAddr3)) + "]"
- @ 6, 14 GET cAddr3 SECTION 1
- @ 7, 2 SAY " Tel [" + Space(Len(cTel)) + "]"
- @ 7, 14 GET cTel SECTION 1
-
- cCard := Space(10)
- cCardNum := Space(16)
- @ 9, 2 SAY "Confirmation" COLOR "W+/N"
- @ 10, 2 SAY " Card [" + Space(Len(cCard)) + "]"
- @ 10, 13 GET cCard SECTION 2
- @ 11, 2 SAY " Card # ["
- @ 11, 13 GET cCardNum PICTURE "@R 9999-9999-9999-9999" SECTION 2
- @ 11, Col() SAY "]"
-
- nDbls := 0
- nSgls := 0
- nSglSuites := 0
- nDblSuites := 0
- @ 13, 2 SAY "Rooms" COLOR "W/N+"
- @ 14, 2 SAY " Dbl. [ ]"
- @ 14, 14 GET nDbls PICTURE "9999" SECTION 3
- @ 15, 2 SAY " Sgl. [ ]"
- @ 15, 14 GET nSgls PICTURE "9999" SECTION 3
- @ 16, 2 SAY "Sgl. Suite [ ]"
- @ 16, 14 GET nSglSuites PICTURE "9999" SECTION 3
- @ 17, 2 SAY "Dbl. Suite [ ]"
- @ 17, 14 GET nDblSuites PICTURE "9999" SECTION 3
-
- nReservation := 0
- @ 19, 2 SAY "Reservation # [ ]"
- @ 19, 17 GET nReservation PICTURE "99999999" SECTION 4
-
- READ SECTION
-
- RETURN NIL
-
-
- 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 GoToGet(n)
-
- LOCAL oGetCurrent := GetActive()
- LOCAL nGetCurrent := Ascan(GetList, {|o| o == oGetCurrent})
-
- IF nGetCurrent > n
- oGetCurrent:exitState := GE_UP
- ELSE
- oGetCurrent:exitState := GE_DOWN
- ENDIF
- GetMovingTo(n)
-
- RETURN NIL
-
-
- FUNCTION GetMovingTo(n)
-
- STATIC nWhereToGo
- LOCAL nOldWhereGo := nWhereToGo
-
- IF PCount() > 0
- nWhereToGo := n
- ENDIF
-
- RETURN nOldWhereGo
-
-
- 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