search program - Printable Version +- Qbasicnews.com (http://qbasicnews.com/newforum) +-- Forum: QBasic (http://qbasicnews.com/newforum/forum-4.html) +--- Forum: QB Projects (http://qbasicnews.com/newforum/forum-12.html) +--- Thread: search program (/thread-8449.html) |
search program - everett - 11-27-2005 [/code] cls print "the results will be in search.txt" print "made by everett gillert" print "email everett.gillert@gmail.com" input "drive"; d$ input "dir"; s$ input "file type"; f$ input "name"; n$ if s$ = "\" then goto sub1 else if s$ = "" then goto sub1 else if s$ = " " then goto sub1 else shell "dir "+d$+":\"+s$+"\"+n$+"."+f$+"/b/a-d>search.txt end sub1: shell "dir "+d$+":\"+n$+"."+f$+"/b/a-d>search.txt return [/code] search program - tannervp - 11-27-2005 Quote: maybe it should be shell "dir d$:\s$\n$.f$/b > \search\search.txt" search program - everett - 11-27-2005 i thout to do that but i thout pepole would know to do .bas or what ever they where looking for and i missed that dir one search program - tannervp - 11-27-2005 you messed up somewhere. I tried that and got the same file creation error search program - everett - 11-27-2005 dir \search\search.txt mabey or just search.txt search program - Moneo - 11-27-2005 tannervp, BTW your program is a nice frontend for searching files using the DIR command. Sorry, but I thought you had written an entire utility to do this. Quote:You got the right idea, except for the way you build the SHELL command string. Take a look at this:everett Wrote:maybe it should be shell "dir d$:\s$\n$.f$/b >\search\search.txt" shell "dir "+d$+":\"+s$+"\"+n$+"."+"f$"+"/b>search\search.txt" The above syntax should work for almost all the cases, except: 1) When the directory (s$) is the root directory (\). When you build the shell command you'll have \\ together, which won't work. So, test s$ after having input it, and if it's \ convert it to null, like: if s$="\" then s$="" 2) Another possibility is that the user wants to look at files that don't have a file extension, and specifies null to the file type prompt. Since most directories don't have file extension, they will be included in the output list. To avoid this, after the /b put /a-d which means that you don't want directories. You also might want to ask the user if he wants to search in sub-directories of the "dir". If so, you would need to insert a "/s" right after the f$ in the shell command string. ***** search program - everett - 11-27-2005 then i have to do this if s$ = "\" then goto sub1 else if s$ = "" then goto sub1 else if s$ = " " then goto sub1 else shell "dir "+d$+":\"+s$+"\"+n$+"."+f$+"/b>search\search.txt end sub1: shell "dir "+d$+":\"+n$+"."+f$+"/b>search\search.txt return search program - everett - 11-27-2005 that change dosenot work search program - everett - 11-27-2005 Quote:tannervp, BTW your program is a nice frontend for searching files using the DIR command. Sorry, but I thought you had written an entire utility to do this. search program - Moneo - 11-28-2005 Everett, I read your PM. You're right, my shell doesn't work. Here's my shell line: shell "dir "+d$+":\"+s$+"\"+n$+"."+"f$"+"/b>search\search.txt" It needs to be: shell "dir "+d$+":\"+s$+"\"+n$+"."+f$+"/b>search\search.txt" I had quotes around f$. I just tested it, and it works. I'll leave the other enhancemeents up to you. Let me know how it goes. ***** |