home *** CD-ROM | disk | FTP | other *** search
- // GetSense.prg
- //
- // Get reader to perform edit sensing on a net
-
- #include "Getexit.ch"
-
- // Offsets into GET object's cargo
- #define FLD_ORIGINAL 1 // Field's original value
- #define FLD_GSB 2 // Its get / set block
- #define SENSE_NOTIFY 3 // Code block to notify when ANY field
- // has changed
-
- proc GetSenseReader( oGetCur, aGets, nTimeout )
-
- LOCAL nKey, i, nField, oGet
-
- // read the GET if the WHEN condition is satisfied
- IF ( GetPreValidate(oGetCur) )
- // activate the GET for reading
- oGetCur:SetFocus()
-
- DO WHILE ( oGetCur:exitState == GE_NOEXIT )
- // check for initial typeout (no editable positions)
- IF ( oGetCur:typeOut )
- oGetCur:exitState := GE_ENTER
- ENDIF
-
- // apply keystrokes until exit
- DO WHILE ( oGetCur:exitState == GE_NOEXIT )
- nKey := InKey(nTimeout)
- IF nKey == 0
- // No key within wait time, compare all fields against
- // their original values. For each one changed, evaluate
- // its notify function
- SKIP 0 // Refresh
- FOR i := 1 TO Len(aGets)
- oGet := aGets[i]
- // IF "sense" get, compare original with new version
- IF ValType(oGet:cargo) == "A" .AND. ;
- !(Eval(oGet:cargo[FLD_GSB]) == ;
- oGet:cargo[FLD_ORIGINAL])
- // Evaluate this GET's "notify" code block
- Eval(oGetCur:cargo[SENSE_NOTIFY], oGet, aGets)
-
- // After notifying user, reset orignal
- // value to current
- oGet:cargo[FLD_ORIGINAL] := Eval(oGet:cargo[FLD_GSB])
- ENDIF
- NEXT
- ELSE
- GetApplyKey(oGetCur, nKey)
- ENDIF
- ENDDO
-
- // disallow exit if the VALID condition is not satisfied
- IF ( !GetPostValidate(oGetCur) )
- oGetCur:exitState := GE_NOEXIT
- ENDIF
- ENDDO
-
- // de-activate the GET
- oGetCur:KillFocus()
- ENDIF
-
- RETURN