April 23, 2024, 10:03:22 PM

News:

Own IWBasic 2.x ? -----> Get your free upgrade to 3.x now.........


A little more folder help

Started by TexasPete, January 28, 2009, 10:36:44 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

TexasPete

Below I am trying to read only the folders into the html file. I am just getting off of a lot of demeral from surgery. I am try to read and check for all sub folders only and put them in my array. I am usining instr to determine if there is a file extension or not. It still continues to read all the files . No matter is there is a period in the file name or not . What am I doing wrong?

filename = FINDNEXT(dir)
      '---This limits the type of File returned
                     PRINT filename," ", attrib
                     IF (filename <> ".")and (filename <> "..")
              if attrib =16  and instr(filename,".") < 1 then
                HtmlFiles[NoHtmlFiles]=filename   :NoHtmlFiles=NoHtmlFiles+1
                   PRINT "Sub FOLDERS ",filename," ", attrib
                            end if
                   ENDIF

Thanks a lot Texas Pete


billhsln

This should work.

dir = FINDOPEN(path + "*.*")
IF(dir)
DO
filename = FINDNEXT(dir,attrib)
IF len(filename)
IF attrib & @FILE_DIRECTORY
IF(filename <> ".") & (filename <> "..")
HtmlFiles[NoHtmlFiles]=filename
                                        NoHtmlFiles++
ENDIF
ENDIF
ENDIF
UNTIL filename = ""
FINDCLOSE dir


Bill
When all else fails, get a bigger hammer.

TexasPete

bILL,

  I did as you suggested and the following code resulted. Unfortunately, It is still reading all the files into the array instead of only the folders.

   DO
   
'--------------------------get html file names--------------
'-----------------------------------------------------------
'--------------------------------------------------------------
     filename = FINDNEXT(dir,attrib)
      '---This limits the type of File returned
        PRINT filename," ", attrib
      if len(filename)
         if attrib & @FILE_DIRECTORY
              IF (filename <> ".") &(filename <>"..")
               HtmlFiles[NoHtmlFiles]=filename   :NoHtmlFiles++
                PRINT "Sub FOLDERS ",filename," ", attrib
              end if
         ENDIF
      endif
  UNTIL filename = ""


If i missed something please let me know what I missed.

Thanks Texas Pete

billhsln

January 28, 2009, 01:07:13 PM #3 Last Edit: January 28, 2009, 01:21:27 PM by billhsln
Other values for Attrib:

@FILE_ARCHIVE
@FILE_COMPRESSED
@FILE_DEVICE
@FILE_DIRECTORY
@FILE_ENCRYPTED
@FILE_HIDDEN
@FILE_NORMAL
@FILE_READONLY
@FILE_SYSTEM

Could you send me more of the code you are using, so I could test it on my machine.  The code I sent before works on my PC.

Bill
When all else fails, get a bigger hammer.