home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 5 / 05.iso / a / a054 / 1.img / GETLIB.EXE / GETSENSE.PRG < prev    next >
Encoding:
Text File  |  1992-03-09  |  2.0 KB  |  66 lines

  1. // GetSense.prg
  2. //
  3. // Get reader to perform edit sensing on a net
  4.  
  5. #include "Getexit.ch"
  6.  
  7. // Offsets into GET object's cargo
  8. #define FLD_ORIGINAL 1   // Field's original value
  9. #define FLD_GSB      2   // Its get / set block
  10. #define SENSE_NOTIFY 3   // Code block to notify when ANY field
  11.                          // has changed
  12.  
  13. proc GetSenseReader( oGetCur, aGets, nTimeout )
  14.  
  15. LOCAL nKey, i, nField, oGet
  16.  
  17.   // read the GET if the WHEN condition is satisfied
  18.   IF ( GetPreValidate(oGetCur) )
  19.     // activate the GET for reading
  20.     oGetCur:SetFocus()
  21.  
  22.     DO WHILE ( oGetCur:exitState == GE_NOEXIT )
  23.       // check for initial typeout (no editable positions)
  24.       IF ( oGetCur:typeOut )
  25.         oGetCur:exitState := GE_ENTER
  26.       ENDIF
  27.  
  28.       // apply keystrokes until exit
  29.       DO WHILE ( oGetCur:exitState == GE_NOEXIT )
  30.         nKey := InKey(nTimeout)
  31.         IF nKey == 0
  32.           // No key within wait time, compare all fields against
  33.           // their original values. For each one changed, evaluate
  34.           // its notify function
  35.           SKIP 0   // Refresh
  36.           FOR i := 1 TO Len(aGets)
  37.             oGet := aGets[i]
  38.             // IF "sense" get, compare original with new version
  39.             IF ValType(oGet:cargo) == "A" .AND. ;
  40.                     !(Eval(oGet:cargo[FLD_GSB]) == ;
  41.                       oGet:cargo[FLD_ORIGINAL])
  42.               // Evaluate this GET's "notify" code block
  43.               Eval(oGetCur:cargo[SENSE_NOTIFY], oGet, aGets)
  44.  
  45.               // After notifying user, reset orignal
  46.               // value to current
  47.               oGet:cargo[FLD_ORIGINAL] := Eval(oGet:cargo[FLD_GSB])
  48.             ENDIF
  49.           NEXT
  50.         ELSE
  51.           GetApplyKey(oGetCur, nKey)
  52.         ENDIF
  53.       ENDDO
  54.  
  55.       // disallow exit if the VALID condition is not satisfied
  56.       IF ( !GetPostValidate(oGetCur) )
  57.         oGetCur:exitState := GE_NOEXIT
  58.       ENDIF
  59.     ENDDO
  60.  
  61.     // de-activate the GET
  62.     oGetCur:KillFocus()
  63.   ENDIF
  64.  
  65. RETURN
  66.