Task

Walk a given directory and print the names of files matching a given pattern.

(How is "pattern" defined? substring match? DOS pattern? BASH pattern? ZSH pattern? Perl regular expression?)


Note: This task is for non-recursive methods.   These tasks should read a single directory, not an entire directory tree.

Note: Please be careful when running any code presented here.



Related task

   Walk Directory Tree   (read entire directory tree). 


      directory$ = "C:\Windows\"
      pattern$ = "*.ini"
      PROClistdir(directory$ + pattern$)
      END
 
      DEF PROClistdir(afsp$)
      LOCAL dir%, sh%, res%
      DIM dir% LOCAL 317
      SYS "FindFirstFile", afsp$, dir% TO sh%
      IF sh% <> -1 THEN
        REPEAT
          PRINT $$(dir%+44)
          SYS "FindNextFile", sh%, dir% TO res%
        UNTIL res% = 0
        SYS "FindClose", sh%
      ENDIF
      ENDPROC