home *** CD-ROM | disk | FTP | other *** search
/ Power CD-ROM!! 7 / POWERCD7.ISO / prgmming / clipper / gt_lower.ch < prev    next >
Text File  |  1993-07-01  |  3KB  |  99 lines

  1. /*
  2.  * File......: GT_Lower.ch
  3.  * Author....: Niall Scott
  4.  * BBS.......: The Dark Knight Returns
  5.  * Net/Node..: 050/069
  6.  * User Name.: Niall Scott
  7.  * Date......: 29/06/93
  8.  * Revision..: 1.0
  9.  * Log file..: $Logfile$
  10.  *
  11.  * This is an original work by Niall R Scott and is placed in the
  12.  * public domain.
  13.  *
  14.  * Modification history:
  15.  * ---------------------
  16.  *
  17.  * Rev 1.0  29/06/93
  18.  * Initial Revision
  19.  */
  20.  
  21.  
  22. /*  $DOC$
  23.  *  $FUNCNAME$
  24.  *      GT_LOWERR()
  25.  *  $CATEGORY$
  26.  *      Wrappers/Errors
  27.  *  $ONELINER$
  28.  *      Handle low level file access errors
  29.  *  $SYNTAX$
  30.  *      GT_LOWERR()
  31.  *  $ARGUMENTS$
  32.  *
  33.  *  $RETURNS$
  34.  *
  35.  *  $DESCRIPTION$
  36.  *    Wrapper to connect low level file functions e.g. Fopen()
  37.  *    to standard Clipper error system.
  38.  *  $EXAMPLES$
  39.  *        FUNCTION DiscErr()
  40.  *            Local oOldHandler
  41.  *            Local nTries := 0
  42.  *            Local nAns
  43.  *            local aArrErr
  44.  *    
  45.  *           // Set up the New handler and pass old handler as a parameter
  46.  *           bNewHandler := {|e| ErrDisc(e, bOldHandler)}
  47.  *           bOldHandler := ErrorBlock(bNewHandler)
  48.  *    
  49.  *            WHILE (.t.)
  50.  *                BEGIN SEQUENCE
  51.  *    
  52.  *                    // Floppy disc access here
  53.  *                    fopen('a:\missing.zxy')
  54.  *    
  55.  *                    //For low Level functions that don't normally use the
  56.  *                    // error system
  57.  *                     GT_LOWERR()
  58.  *    
  59.  *                    // This is the recovery section of the Begin/End Sequence
  60.  *                    // construct.  A BREAK statement got us to this point.
  61.  *                RECOVER USING aErrArr
  62.  *    
  63.  *                    // Allow the user three attempts
  64.  *                    if nTries++ < 3
  65.  *                        ...
  66.  *                        ...
  67.  *                        ...
  68.  *                        // Your recovery code
  69.  *                        ...
  70.  *                        ...
  71.  *                        ...
  72.  *                        Do Case
  73.  *                        Case nAns == 2
  74.  *                            EXIT
  75.  *                        Case nAns == 3
  76.  *                            QUIT
  77.  *                        EndCase
  78.  *                    ENDIF
  79.  *                END SEQUENCE
  80.  *            ENDDO
  81.  *        RETURN NIL
  82.  *  $SEEALSO$
  83.  *
  84.  *  $INCLUDE$
  85.  *
  86.  *  $END$
  87.  */
  88.  
  89. // Wrapper to enable use of error system with low level
  90. // file functions
  91. #xtranslate GT_LOWERR() =>  IF Ferror() > 0                 ;;
  92.                    kError := ErrorBlock()        ;;
  93.                    oError := errornew()          ;;
  94.                                    oError:genCode       := 21           ;;
  95.                                    oError:osCode        := Ferror()     ;;
  96.                                    Eval(kError, oError)         ;;
  97.                    Endif
  98.  
  99.