Basicprogramming(.org) > General questions and discussions

Dir Walk Challenge

<< < (2/4) > >>

ZXDunny:
Oh, I'm not trolling. Even you will be able to tell when I am.

You viciously and without provocation attacked me personally, and I'm not allowed to even defend myself? I'll add that the list of things I'm not allowed to do according to some guy on the internet who goes by the name of Mike, yeah?

Tomaaz:
Mike, I don't remember ZXDunny trolling anyone. He's never had problems with people using other BASICs, unlike some other members. He's never had problems with me posting code in Python, Ruby or Perl, unlike some other members. You want to see some good trolling? Sorry, you just missed one. It was here. Aurel was having laugh at OOP. It involved words like "pussy", "suck" etc., but Aurel must have gotten sober in the meantime and edited it.

B+:

--- Quote from: Tomaaz on September 24, 2018, 06:07:36 PM ---Mike, I don't remember ZXDunny trolling anyone. He's never had problems with people using other BASICs, unlike some other members. He's never had problems with me posting code in Python, Ruby or Perl, unlike some other members. You want to see some good trolling? Sorry, you just missed one. It was here. Aurel was having laugh at OOP. It involved words like "pussy", "suck" etc., but Aurel must have gotten sober in the meantime and edited it.

--- End quote ---

Either that or the Moderator button works, Aurel apologized before the last edit to "0".

B+:
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.

Here is code I came up with (not nearly so elegant as Ruby one liner) to extract and sort only .bas files:

--- Code: ---'Dir Walk.bas for SmallBASIC 0.12.13 B+ 2018-09-24

CONST DEBUG = TRUE

FUNC sto(x)
  IF DEBUG THEN ? x   'debug: line record returned by DIRWALK, you should see how this monster is formatted!!!!
 
  'the extraction begins, remove brackets and split to fields
  SPLIT DISCLOSE(x, "{}"), ",", field
 
  'the name is in the 2nd field but is it a Folder name or File name?
  SPLIT field(1), ":", names
 
  'extract actual name value from names array
  name = MID(names(1), 2, LEN(names(1)) - 2)
  IF DEBUG THEN ? "Name: ";name  '<<< debug: got name right?
 
  'extract path from 6th field   
  path = DISCLOSE(RIGHTOF(field(5), ":"))
 
  'I think either "\" or "/" is being mistaken for escape code but works so... you know...
  IF MID(path, LEN(path)) = CHR(47) OR MID(path, LEN(path)) = CHR(92) THEN path = MID(path, 1, LEN(path) - 1)
  IF debug THEN ? "Path: ";path '<<<<<< debug: got path right?
 
  pathedName = path + CHR(92) + name
  IF DEBUG THEN ? "Pathed Name: ";pathedName
   
  'debug: view each return one at a time
  IF DEBUG THEN
    INPUT "OK, press enter to continue, any other + enter to quit ";wate
   
    'This doesn't always stop DIRWALK ???
    IF LEN(TRIM(wate)) THEN sto = FALSE : EXIT FUNC
    ?
  FI
 
  IF LCASE(RIGHT(pathedName, 4)) = ".bas" THEN container << pathedName
  IF x <> "" THEN sto = TRUE
END

DIRWALK "." USE sto(x)
SORT container

'check and file results
FOR i IN container DO ? i
tsave "BAS files.txt", container


--- End code ---

Attached is a view of a debug session when everything was working to my satisfaction (good enough). You need to see the string DIRWALK returns until it's USE function returns FALSE.

Here is output file, BAS files.txt:
--- Code: ---C:\Users\marka\Desktop\SmallBasic\Small BASIIC  DESKTOP/2018 new computer/Backup\Handy.bas
C:\Users\marka\Desktop\SmallBasic\Small BASIIC  DESKTOP/2018 new computer/Backup\Lander update.bas
C:\Users\marka\Desktop\SmallBasic\Small BASIIC  DESKTOP/2018 new computer/Backup\check environment variables.bas
C:\Users\marka\Desktop\SmallBasic\Small BASIIC  DESKTOP/2018 new computer/Backup\japanese pattern.bas
C:\Users\marka\Desktop\SmallBasic\Small BASIIC  DESKTOP/2018 new computer/Backup\window subcommands.bas
C:\Users\marka\Desktop\SmallBasic\Small BASIIC  DESKTOP/2018 new computer\Ascii to multi message.bas
C:\Users\marka\Desktop\SmallBasic\Small BASIIC  DESKTOP/2018 new computer\Bar Code by Galileo.bas
C:\Users\marka\Desktop\SmallBasic\Small BASIIC  DESKTOP/2018 new computer\Chaos_1xt.bas
C:\Users\marka\Desktop\SmallBasic\Small BASIIC  DESKTOP/2018 new computer\Eye Test #1001.bas
C:\Users\marka\Desktop\SmallBasic\Small BASIIC  DESKTOP/2018 new computer\Goldwave by Johnno.bas
C:\Users\marka\Desktop\SmallBasic\Small BASIIC  DESKTOP/2018 new computer\Interesting Interference Pattern.bas
C:\Users\marka\Desktop\SmallBasic\Small BASIIC  DESKTOP/2018 new computer\Lander update.bas
C:\Users\marka\Desktop\SmallBasic\Small BASIIC  DESKTOP/2018 new computer\MDL test.bas
C:\Users\marka\Desktop\SmallBasic\Small BASIIC  DESKTOP/2018 new computer\Mystic Memories.bas
C:\Users\marka\Desktop\SmallBasic\Small BASIIC  DESKTOP/2018 new computer\Piston_Acceleration.bas
C:\Users\marka\Desktop\SmallBasic\Small BASIIC  DESKTOP/2018 new computer\Screen Saver #3 Mystic Rectangles.bas
C:\Users\marka\Desktop\SmallBasic\Small BASIIC  DESKTOP/2018 new computer\Shopping List.bas
C:\Users\marka\Desktop\SmallBasic\Small BASIIC  DESKTOP/2018 new computer\Sierpinski circled.bas
C:\Users\marka\Desktop\SmallBasic\Small BASIIC  DESKTOP/2018 new computer\Sierpinsky Flies a Kite.bas
C:\Users\marka\Desktop\SmallBasic\Small BASIIC  DESKTOP/2018 new computer\Sin table program.bas
C:\Users\marka\Desktop\SmallBasic\Small BASIIC  DESKTOP/2018 new computer\japanese pattern.bas
C:\Users\marka\Desktop\SmallBasic\Small BASIIC  DESKTOP/2018 new computer\seq test.bas
C:\Users\marka\Desktop\SmallBasic\Small BASIIC  DESKTOP/2018 new computer\text rotation fun .bas
C:\Users\marka\Desktop\SmallBasic\Small BASIIC  DESKTOP/2018 new computer\window ask messagebox.bas
C:\Users\marka\Desktop\SmallBasic\Small BASIIC  DESKTOP/2018 new computer\window ask test.bas
C:\Users\marka\Desktop\SmallBasic\Small BASIIC  DESKTOP/2018 new computer\window subcommands.bas
C:\Users\marka\Desktop\SmallBasic\Small BASIIC  DESKTOP/Boids\Boid watching.bas
C:\Users\marka\Desktop\SmallBasic\Small BASIIC  DESKTOP/Connect4/Back\Connect4 AI 1.bas
C:\Users\marka\Desktop\SmallBasic\Small BASIIC  DESKTOP/Connect4/Back\Connect4 start.bas
C:\Users\marka\Desktop\SmallBasic\Small BASIIC  DESKTOP/Connect4/Posts\Connect4 AI 1.bas
C:\Users\marka\Desktop\SmallBasic\Small BASIIC  DESKTOP/Connect4/Posts\Connect4 start.bas
C:\Users\marka\Desktop\SmallBasic\Small BASIIC  DESKTOP/Connect4\Connect4 AI 2.bas
C:\Users\marka\Desktop\SmallBasic\Small BASIIC  DESKTOP/Connect4\Connect4 AI 3.bas
C:\Users\marka\Desktop\SmallBasic\Small BASIIC  DESKTOP/Search Text\Seach text file.bas
C:\Users\marka\Desktop\SmallBasic\Small BASIIC  DESKTOP/Sudoku/Back\Make #3 Board Test Hiding.bas
C:\Users\marka\Desktop\SmallBasic\Small BASIIC  DESKTOP/Sudoku/Back\Make #4 Board Test Hiding.bas
C:\Users\marka\Desktop\SmallBasic\Small BASIIC  DESKTOP/Sudoku/Back\SB1 Sudoku Game.bas
C:\Users\marka\Desktop\SmallBasic\Small BASIIC  DESKTOP/Sudoku/Back\SB2  Sudoku Game Solver Editor.bas
C:\Users\marka\Desktop\SmallBasic\Small BASIIC  DESKTOP/Sudoku/Back\SB3  Sudoku Game Solver Editor.bas
C:\Users\marka\Desktop\SmallBasic\Small BASIIC  DESKTOP/Sudoku/Back\SB3_1  Sudoku Game Solver Editor.bas
C:\Users\marka\Desktop\SmallBasic\Small BASIIC  DESKTOP/Sudoku/Posted\Make #2 Sudoku Board.bas
C:\Users\marka\Desktop\SmallBasic\Small BASIIC  DESKTOP/Sudoku/Posted\Make #3 Board Test Hiding.bas
C:\Users\marka\Desktop\SmallBasic\Small BASIIC  DESKTOP/Sudoku/Posted\Make #4 Board Test Hiding.bas
C:\Users\marka\Desktop\SmallBasic\Small BASIIC  DESKTOP/Sudoku/Posted\Make Sudoku Board.bas
C:\Users\marka\Desktop\SmallBasic\Small BASIIC  DESKTOP/Sudoku/Posted\SB1 Sudoku Game.bas
C:\Users\marka\Desktop\SmallBasic\Small BASIIC  DESKTOP/Sudoku/Posted\SB2  Sudoku Game Solver Editor.bas
C:\Users\marka\Desktop\SmallBasic\Small BASIIC  DESKTOP/Sudoku/Posted\SB3  Sudoku Game Solver Editor.bas
C:\Users\marka\Desktop\SmallBasic\Small BASIIC  DESKTOP/Sudoku/Posted\SB3_1  Sudoku Game Solver Editor.bas
C:\Users\marka\Desktop\SmallBasic\Small BASIIC  DESKTOP/Sudoku/Posted\Solver - Sean Nixon.bas
C:\Users\marka\Desktop\SmallBasic\Small BASIIC  DESKTOP/Sudoku\SB3_2  Sudoku Game Solver Editor.bas
C:\Users\marka\Desktop\SmallBasic\Small BASIIC  DESKTOP/Sudoku\quick test.bas
C:\Users\marka\Desktop\SmallBasic\Small BASIIC  DESKTOP/clutter 2018\Classic animation (Galileo).bas
C:\Users\marka\Desktop\SmallBasic\Small BASIIC  DESKTOP/clutter 2018\Draw Shamrock.bas
C:\Users\marka\Desktop\SmallBasic\Small BASIIC  DESKTOP/clutter 2018\Draw Squeezed Heart.bas
C:\Users\marka\Desktop\SmallBasic\Small BASIIC  DESKTOP/clutter 2018\Draw heart experiment.bas
C:\Users\marka\Desktop\SmallBasic\Small BASIIC  DESKTOP/clutter 2018\Keyboard Input by Pete.bas
C:\Users\marka\Desktop\SmallBasic\Small BASIIC  DESKTOP/clutter 2018\Mandala Life revisited 2018-03-30.bas
C:\Users\marka\Desktop\SmallBasic\Small BASIIC  DESKTOP/clutter 2018\Prime compression Chris found.bas
C:\Users\marka\Desktop\SmallBasic\Small BASIIC  DESKTOP/clutter 2018\Shamrock Luck.bas
C:\Users\marka\Desktop\SmallBasic\Small BASIIC  DESKTOP/clutter 2018\Snail Problem.bas
C:\Users\marka\Desktop\SmallBasic\Small BASIIC  DESKTOP/clutter 2018\image modification.bas
C:\Users\marka\Desktop\SmallBasic\Small BASIIC  DESKTOP/clutter 2018\internet chess grabber by jsalai.bas
C:\Users\marka\Desktop\SmallBasic\Small BASIIC  DESKTOP/clutter 2018\seq test.bas
C:\Users\marka\Desktop\SmallBasic\Small BASIIC  DESKTOP/clutter 2018\spiral text.bas
C:\Users\marka\Desktop\SmallBasic\Small BASIIC  DESKTOP/image 2 ascii\pixelate by chris yuck!.bas
C:\Users\marka\Desktop\SmallBasic\Small BASIIC  DESKTOP\Detab Me.bas
C:\Users\marka\Desktop\SmallBasic\Small BASIIC  DESKTOP\Full factor.bas
C:\Users\marka\Desktop\SmallBasic\Small BASIIC  DESKTOP\Get key codes.bas
C:\Users\marka\Desktop\SmallBasic\Small BASIIC  DESKTOP\Handy.bas
C:\Users\marka\Desktop\SmallBasic\Small BASIIC  DESKTOP\Infinite Pong the Movie.bas
C:\Users\marka\Desktop\SmallBasic\Small BASIIC  DESKTOP\L-system plant fractals.bas
C:\Users\marka\Desktop\SmallBasic\Small BASIIC  DESKTOP\New bas file.bas
C:\Users\marka\Desktop\SmallBasic\Small BASIIC  DESKTOP\Save As bas file.bas
C:\Users\marka\Desktop\SmallBasic\Small BASIIC  DESKTOP\check environment variables.bas
C:\Users\marka\Desktop\SmallBasic\Small BASIIC  DESKTOP\checkers.bas
C:\Users\marka\Desktop\SmallBasic\Small BASIIC  DESKTOP\dir walk.bas
C:\Users\marka\Desktop\SmallBasic\Small BASIIC  DESKTOP\eval calc.bas
C:\Users\marka\Desktop\SmallBasic\Small BASIIC  DESKTOP\quick test.bas
C:\Users\marka\Desktop\SmallBasic\Small BASIIC  DESKTOP\tabs2spaces.bas


--- End code ---

Too many I's in BASIC and the alternating slants or slashes :P

I like Tomaaz challenges, both interesting and productive for me even if they fail to be impressive.

Oh sorry Chris, I guess I didn't like pixelate? was that the cat thing? I mostly didn't like it because it didn't fit the screen, the lines were too long and printing over into next line ruining the image produced.

B+:
You know this challenge was originally directed at Script Basic, I confess now that I worked up my boring example (probably not a great example of SmallBASIC) and Peter his, could someone offer a good representative one of Script Basic code? Maybe AlyssonR or (old) Mike?

Heck! I wouldn't mind seeing new Mike's version either! :) maybe a GUI sample, I would think it actually useful and not waste of time.

And D, can SpecBas do this?

"Inquiring minds want to know."

Navigation

[0] Message Index

[#] Next page

[*] Previous page

Go to full version