BlitzCoder Essentials
•
Home Page
•
About BlitzCoder
•
Contributors
•
Terms of Use
•
Email Us
Main Areas
•
BlitzCoder Chat
•
Discussions
•
Articles/Tutorials
•
Code Database
•
Link Database
•
Showcase Area
•
Worklogs
•
Competitions
Special Areas
•
Undocumented
Other Blitz Sites
•
Blitz Basic Home
•
Blitz Showcase
•
BlitzPlay Library
Forum Login
Username:
Password:
•
Register Now!
BlitzCoder Code Archives Page
Main Codes Page
"Recursion without functions"
, by thechange
Search through directory structure without making use of functions or types.
Code
; Recursive directory search without the use of: ; ; * Functions ; * Types (linked lists) ; ; Using only: ; ; * Goto, Gosub ; * Array of strings ; ; This algorithm was used for a program in STOS Basic on the Atari :) Graphics 500 , 800 , 0 , 2 Dim Folders$( 9999 ) ; Unique levels Folders$( 0 ) = "C:" Repeat Dir = ReadDir ( Folders$( Folder ) ) File$ = NextFile ( Dir ) If File$ = "" Goto NoMoreFiles Repeat If FileType ( Folders$( Folder ) + "\" + File$ ) = 2 Gosub AddFolder If FileType ( Folders$( Folder ) + "\" + File$ ) = 1 Gosub AddFile File$ = NextFile ( Dir ) Until File$ = "" Folder = Folder + 1 Until Folders$( Folder ) = "" Goto Complete .AddFolder If File$ = "." Or File$ = ".." Return Print Folders$( Folder ) + "\" + File$ + "
" AddFolder = AddFolder + 1 Folders$( AddFolder ) = Folders$( Folder ) + "\" + File$ Return .AddFile Print Folders$( Folder ) + "\" + File$ Return .NoMoreFiles Print "No more files" WaitKey End .Complete Print "Done" WaitKey End
Copyright(c) 2000-2004, BlitzCoder. All Rights Reserved.
Code software created by Krylar's Kreations