Announcement

Collapse
No announcement yet.

DIR$ - Folder name with period

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • DIR$ - Folder name with period

    As part of a backup programme I extract a list of all folders on a hard drive and have always suspected that the list was not complete.

    With some spare time at the moment I have revisited this and have found that the DIR$ function with the attribute set to 16, 17, 19 or 23 will not return a folder name that contains a period.

    Microsoft KB article KB905231 states that a period in a folder name is legal and accessing the folder in DOS works.

    If anyone can help with this one I would be obliged.

    TIA
    Roy

  • #2
    Kind of an odd problem you got there. Wrote the following CC5 test code. Made sure my root directory contained a folder with a period in it and it works perfectly.
    Code:
    FUNCTION PBMAIN () AS LONG
        mask$ = "c:\*.*"
        te$ = DIR$(mask$,16)
        DO UNTIL te$ = ""
        PRINT;te$
        te$ = DIR$
        LOOP
        WAITKEY$
        END FUNCTION
    How about a snippit of what you are using?
    There are no atheists in a fox hole or the morning of a math test.
    If my flag offends you, I'll help you pack.

    Comment


    • #3
      Mel, thanks for reply.

      I was using PBCC4 but upgraded to PBCC5 in case that was the issue and hence the delay.

      I had been using a mask of "c:\*." but when I use your mask of "C:\*.*" I agree I now see the folder with the period but I am also seeing the one file in my route directory.

      It seems to me that the DIR$ function is ignoring the attribute 16 and searching for folders when the mask is set to "*." and files when it is set to "*.*".

      Am I missing something here?

      TIA Roy

      Comment


      • #4
        If you want ONLY folders in response to DIR$, you ONLY have to read the 5x doc...
        Michael Mattias
        Tal Systems (retired)
        Port Washington WI USA
        [email protected]
        http://www.talsystems.com

        Comment


        • #5
          Personally, I think if you leave the closing quote off your mask string, you are creating a syntax error so your results should be undefined. After all, without the closing quote, there could be anything appended to the end of your mask string.
          Jeff Blakeney

          Comment


          • #6
            In a simple assignment of a literal to a string variable, if no closing quote is found the compiler will infer that closing double-quote following the last non-space (non whitespace?) character of the line of source code.

            I agree it should be a syntax error to leave it off; but it's not, and it's documented that it's not required.
            Michael Mattias
            Tal Systems (retired)
            Port Washington WI USA
            [email protected]
            http://www.talsystems.com

            Comment


            • #7
              Originally posted by Roy Petrie View Post
              ...Am I missing something here?
              Well, maybe a little.

              DIR$ searches everything in the folder.

              A mask of "*." will return only file names/folders, ignoring any extensions.

              A mask of "*.*" will search filenames AND extensions and return anything matching mask$,attribute.

              Remember, windows "see's" folders as just another file name. It's all in the attribute associated with that name that makes the difference.
              There are no atheists in a fox hole or the morning of a math test.
              If my flag offends you, I'll help you pack.

              Comment


              • #8
                Whoops. My eyes are going. I could have sworn I saw a "*.* where there is a "*.".
                Jeff Blakeney

                Comment

                Working...
                X