Author Topic: Dir Walk Challenge  (Read 1817 times)

B+

  • Hero Member
  • *****
  • Posts: 846
    • View Profile
Re: Dir Walk Challenge
« Reply #15 on: 29. September 2018, 05:15:38 »
Well I finally got a useful directory walk working from SmallBASIC.
Chris has a Keyword DIRWALK but it isn't easy for me to use but I bet Chris could extract 100 x's faster than I.

When you launch SmallBASIC you are actually looking at the output from the DIRWALK command.

(SmallBASIC runs main.bas which provides the user interface)



Ah! I knew that all that extraction wasn't needed!

Code: [Select]
'Dir Walk 2.bas for SmallBASIC 0.12.13 B+ 2018-09-28

FUNC sto(x)
  if right(lcase(x.name), 4) = ".bas"
    pathname = iff( x.depth > 0, (x.path + chr(92) + x.name), (x.path + x.name))
    container << pathname
  fi
  sto = TRUE
END

DIRWALK "." USE sto(x)
SORT container
'check and file results
FOR i IN container DO ? i
tsave "BAS files.txt", container

Same output results.
« Last Edit: 29. September 2018, 05:35:10 by B+ »

jj2007

  • Full Member
  • ***
  • Posts: 168
  • MasmBasic rocks
    • View Profile
    • MasmBasic - faster than C
Re: Dir Walk Challenge
« Reply #16 on: 21. June 2019, 13:41:17 »
Nice to see MasmBasic in action again. Are the files coming out sorted automatically?

Hi B+,

No, GetFiles doesn't sort automatically, but SortFiles will do that, and it has quite a number of useful options.

B+

  • Hero Member
  • *****
  • Posts: 846
    • View Profile
Re: Dir Walk Challenge
« Reply #17 on: 23. June 2019, 01:20:32 »
Wow! took awhile to give birth to an answer. ;-))

My files list is coming in handy finding a SmallBASIC file that I know I have somewhere among the 1000's.

jj2007

  • Full Member
  • ***
  • Posts: 168
  • MasmBasic rocks
    • View Profile
    • MasmBasic - faster than C
Re: Dir Walk Challenge
« Reply #18 on: 12. July 2019, 00:38:52 »
Wow! took awhile to give birth to an answer. ;-))

Apologies - I found your post by accident. I confess that I visit this forum only occasionally...