home *** CD-ROM | disk | FTP | other *** search
/ Power CD-ROM!! 7 / POWERCD7.ISO / prgmming / clipper / gt_gotop.prg < prev    next >
Text File  |  1993-10-14  |  2KB  |  84 lines

  1. /*
  2.     File......: GT_GoTop.prg
  3.     Author....: Martin Bryant
  4.     BBS.......: The Dark Knight Returns
  5.     Net/Node..: 050/069
  6.     User Name.: Martin Bryant
  7.     Date......: 11/02/93
  8.     Revision..: 1.0
  9.  
  10.     This is an original work by Martin Bryant and is placed
  11.     in the public domain.
  12.  
  13.     Modification history:
  14.     ---------------------
  15.  
  16.     Rev 1.0 11/02/93
  17.     PD Revision.
  18. */
  19.  
  20. /*  $DOC$
  21.  *  $FUNCNAME$
  22.  *      GT_GOTOP()
  23.  *  $CATEGORY$
  24.  *      General
  25.  *  $ONELINER$
  26.  *      Move the filepointer to the first record
  27.  *  $SYNTAX$
  28.  *      GT_GoTop([<bWhile>],[<bFor>],[<bFind>]) -> NIL
  29.  *  $ARGUMENTS$
  30.  *      <bWhile> Code block giving a while clause.
  31.  *
  32.  *      <bFor> Code block giving a for clause.
  33.  *
  34.  *      <bFind> Code block giving a value to compare against
  35.  *      the index. Acts as a form of while clause.
  36.  *  $RETURNS$
  37.  *      NIL
  38.  *  $DESCRIPTION$
  39.  *      Reposition the filepointer to the first record given
  40.  *      a for/while clause.
  41.  *  $EXAMPLES$
  42.  *  $SEEALSO$
  43.  *
  44.  *  $INCLUDE$
  45.  *
  46.  *  $END$
  47.  */
  48.  
  49. #include "GT_LIB.ch"
  50.  
  51. FUNCTION GT_GoTop(bWhile,bFor,bFind)
  52.  
  53. LOCAL lFault := .F.
  54.  
  55. Default bWhile to { | | .T. }
  56. Default bFor to { | | .T. }
  57. Default bFind to NIL
  58.  
  59. //  Find first item not legal
  60. IF bFind = NIL
  61.     DBGOTOP()
  62. ELSE
  63.     DBSEEK(EVAL(bFind))
  64. ENDIF
  65.  
  66. BEGIN SEQUENCE
  67.     DbEVAL({ || BREAK(NIL) } ;
  68.         ,bFor ;
  69.         ,bWhile)
  70.     lFault := .T.
  71.  
  72. END SEQUENCE
  73.  
  74. //  OK ?
  75. IF lFault
  76.     DBGOTO(LASTREC()+1)
  77. ENDIF
  78.  
  79. /*
  80.     End of GT_GoTop()
  81. */
  82. RETURN(NIL)
  83.  
  84.