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

  1. /*
  2.  * File......: DOSFILE.PRG
  3.  * Author....: Martin Colloby
  4.  * BBS.......: The Dark Knight Returns
  5.  * Net/Node..: 050/069
  6.  * User Name.: Martin Colloby
  7.  * Date......: 18/4/93
  8.  * Revision..: 1.0
  9.  *
  10.  * This is an original work by Martin Colloby and is placed in the public
  11.  * domain.
  12.  *
  13.  * Modification history:
  14.  * ---------------------
  15.  *
  16.  * $Log$
  17.  *
  18.  */
  19.  
  20.  
  21. /*  $DOC$
  22.  *  $FUNCNAME$
  23.  *      GT_ISFILENAME()
  24.  *  $CATEGORY$
  25.  *      General
  26.  *  $ONELINER$
  27.  *      Check to see if a filename is valid
  28.  *  $SYNTAX$
  29.  *      GT_IsFileName( cFile )
  30.  *  $ARGUMENTS$
  31.  *      cFile - File name
  32.  *  $RETURNS$
  33.  *      .T. if cFile is a valid DOS file name
  34.  *      .F. otherwise
  35.  *  $DESCRIPTION$
  36.  *      Checks to see that the given string passes the tests for validity
  37.  *      as a DOS file.  Does not allow drive path or extension to be passed.
  38.  *  $EXAMPLES$
  39.  *      Check that a file name is valid :
  40.  *
  41.  *          lCheck := GT_IsFileName( ".txt" )
  42.  *
  43.  *      returns .F.
  44.  *  $SEEALSO$
  45.  *
  46.  *  $INCLUDE$
  47.  *
  48.  *  $END$
  49.  */
  50.  
  51. *
  52. FUNCTION GT_IsFileName( cFile )
  53.  
  54. /*****************************************************************************
  55.  Purpose - Check that cFile is a valid DOS filename ( no extension ! )
  56.  Returns - .T. if cFile is valid
  57.  Author  - Log
  58.  Created - 06/11/92
  59. ******************************************************************************
  60.  Parameters - cFile - Filename to test
  61.  Privates   - None
  62.  Locals     - None
  63.  Externals  - None
  64. *****************************************************************************/
  65.  
  66. LOCAL lCount   := 0
  67. LOCAL lInValid := "/[]|<>+=;*.\? "  // :,
  68. LOCAL nCount   := 0
  69.  
  70. cFile := ALLTRIM( cFile )
  71.  
  72. IF LEN( cFile ) > 8 .OR. LEN( cFile ) = 0
  73.     RETURN( .F. )
  74. ENDIF
  75.  
  76. FOR nCount := 1 TO LEN( lInValid )
  77.     IF AT( SUBSTR( lInValid , nCount , 1 ) , cFile ) > 0
  78.         RETURN( .F. )
  79.     ENDIF
  80. NEXT nCount
  81.  
  82. RETURN( .T. )
  83. *
  84.