Qbasicnews.com
May 20, 2019, 07:25:04 AM *
Welcome, Guest. Please login or register.

Login with username, password and session length
News: Back to Qbasicnews.com | QB Online Help | FAQ | Chat | All Basic Code | QB Knowledge Base
 
   Home   Help Search Login Register  
Poll
Question: is this program good  (Voting closed: November 26, 2005, 03:54:28 PM)
yes most defently - 0 (0%)
its ok - 1 (50%)
it stinks - 1 (50%)
Total Voters: 1

Pages: 1 [2]
  Print  
Author Topic: search program  (Read 6995 times)
Moneo
Na_th_an
*****
Posts: 1971


« Reply #15 on: November 26, 2005, 10:26:48 PM »

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 from: "tannervp"
Quote from: "everett"
Code:

.....
input "drive"; d$
input "dir"; s$
input "file type"; f$
input "name"; n$
shell "dir d$:\s$n$f$/b > \search\search.txt"
end

maybe it should be shell "dir d$:\s$\n$.f$/b >\search\search.txt"

You got the right idea, except for the way you build the SHELL command string. Take a look at this:

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.
*****
Logged
everett
Member
*
Posts: 29


« Reply #16 on: November 26, 2005, 11:58:34 PM »

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
Logged
everett
Member
*
Posts: 29


« Reply #17 on: November 27, 2005, 12:08:24 AM »

that change dosenot work
Logged
everett
Member
*
Posts: 29


« Reply #18 on: November 27, 2005, 12:09:04 AM »

Quote from: "Moneo"
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 from: "tannervp"
Quote from: "everett"
Code:

.....
input "drive"; d$
input "dir"; s$
input "file type"; f$
input "name"; n$
shell "dir d$:\s$n$f$/b > \search\search.txt"
end

maybe it should be shell "dir d$:\s$\n$.f$/b >\search\search.txt"

You got the right idea, except for the way you build the SHELL command string. Take a look at this:

here
shell "dir "+d$+":\"+s$+"\"+n$+"."+"f$"+"/b>search\search.txt"here

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.
*****
Logged
Moneo
Na_th_an
*****
Posts: 1971


« Reply #19 on: November 28, 2005, 12:06:44 AM »

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.
*****
Logged
Moneo
Na_th_an
*****
Posts: 1971


« Reply #20 on: December 02, 2005, 03:30:46 PM »

Everett,

With the fix as in my post above:

shell "dir "+d$+":\"+s$+"\"+n$+"."+f$+"/b>search\search.txt"

Did it now work for you? It shouldn't have taken you 5 days to figure it out, LOL.  :wink:
*****
Logged
Pages: 1 [2]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.21 | SMF © 2015, Simple Machines Valid XHTML 1.0! Valid CSS!