home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 5 / 05.iso / a / a067 / 1.img / GRUMP501.EXE / GFVALID.PRG < prev    next >
Encoding:
Text File  |  1991-08-26  |  2.3 KB  |  72 lines

  1. /*
  2.    Function: GFValid()
  3.    System:   GRUMPFISH LIBRARY
  4.    Author:   Greg Lief
  5.    Copyright (c) 1988-91, Greg Lief
  6.    Clipper 5.01 Version
  7.    Purpose:  Force total validation of all GETs when user attempts
  8.              to exit the READ
  9.    Syntax:   GFAllValid(<aGetlist>)
  10.    Returns:  Nada
  11.    Compile instructions: clipper gfvalid /n/w
  12. */
  13. function gfvalid(aGets)
  14. local nGets := len(aGets)
  15. local x
  16. local ok
  17. for x := 1 to nGets
  18.    /*
  19.        Loop through GETLIST array and check each one for a VALID clause.
  20.        Note the exitState test -- if this Get has an exitState already
  21.        defined, then it must have already been validated and we therefore
  22.        do not need to test it again here.
  23.    */
  24.    if aGets[x]:exitState == NIL .and. aGets[x]:postBlock != NIL
  25.  
  26.       //───── post this GET object as currently active... necessary because
  27.       //───── the VALID clause may depend upon GetActive()
  28.       getactive(aGets[x])
  29.  
  30.       //───── for the same reasons, post name of the GET object for READVAR()
  31.       //───── in case VALID function needs it (see GETREADVAR() below...)
  32.       readvar(getreadvar(aGets[x]))
  33.  
  34.       /*
  35.          Since it is possible to write a VALID clause that accepts
  36.          the currently active GET object as parameters, we must
  37.          activate each GET object (with the setfocus() method) prior
  38.          to testing the VALID clause. This is to simulate actual
  39.          conditions during the READ, because an active GET has
  40.          certain characteristics that an inactive GET does not (in
  41.          particular, the BUFFER and POS instance variables).
  42.       */
  43.       aGets[x]:setfocus()
  44.       ok := eval(aGets[x]:postBlock, aGets[x])
  45.       aGets[x]:killfocus()
  46.       if ! ok
  47.          readmodal( { aGets[x] } )
  48.       endif
  49.    endif
  50. next
  51. return nil
  52.  
  53.  
  54. /*
  55.   Function: GetReadVar()
  56.   Excerpted from GETSYS.PRG, which is
  57.   Copyright (c) 1990, 1991 Nantucket Corp.
  58.  
  59.   The reason I have duplicated it here is because, regrettably, it is a
  60.   static function in GETSYS.PRG, which means that "you can't get there
  61.   from here"
  62. */
  63. static function getreadvar(get)
  64. local name := Upper(get:name)
  65. local i
  66. if ( get:subscript <> NIL )
  67.    for i := 1 to len(get:subscript)
  68.       name += "[" + ltrim(str(get:subscript[i])) + "]"
  69.    next
  70. endif
  71. return name
  72.