Qbasicnews.com

QBasic => QB Projects => Topic started by: everett on November 26, 2005, 03:54:28 PM



Title: search program
Post by: everett on November 26, 2005, 03:54:28 PM
i have made a costum search program :D to get it email me at everett.gillert@gmail.com and i will email it to you as i have no way to host it if you have a way tell me


post your comments on it here


Title: Re: search program
Post by: Moneo on November 26, 2005, 04:25:18 PM
Quote from: "everett"
i have made a costum search program :D to get it email me at everett.gillert@gmail.com and i will email it to you as i have no way to host it if you have a way tell me

post your comments on it here

Does your search program search for files or for data?
Give some specifications so we can get an idea what it does.
I personally don't like to test a program without knowing what it's supposed to do.
*****


Title: search program
Post by: everett on November 26, 2005, 04:30:35 PM
for files but i am editing it to include data and i will need help
as it can only search any file which can be opened by a text etidor
if you could give me a hand i would apreceat it


Title: search program
Post by: whitetiger0990 on November 26, 2005, 04:40:30 PM
well... why don't you post a nice link to it? Perferably with source code. Then maybe we'll test it =p

there's some free upload hosting thingy at http://fileanchor.com


Title: search program
Post by: everett on November 26, 2005, 04:42:58 PM
http://fileanchor.com/11318-d


Title: search program
Post by: tannervp on November 26, 2005, 04:46:22 PM
it's ok... I got an error(it is a version of the Run command on my computer... :-?:-?


Title: search program
Post by: Moneo on November 26, 2005, 04:48:37 PM
Quote from: "everett"
for files but i am editing it to include data and i will need help
as it can only search any file which can be opened by a text etidor
if you could give me a hand i would apreceat it

I wrote my own utility programs for searching files and for searching for text within files.

Why did I write these? Well at the time, about 12 years ago)  the best utilities for these searches were part of Norton Utilities. I used Norton a lot, and found that there were a bunch of things that I wanted to do that Norton did not have. So, I wrote my own utilities.

Today, DIR is just about as good a file searcher as the Norton FS program was. If your file search program does not do at least what DIR does, and at least some additional feature that you often need, than I suggest that you're wasting your time.

Pretty much the same holds true for text searching. Norton's TS would search any file, binary or text. Again, if your program is not going to better than Norton's, or mine, then why bother, since it's a lot of hard work. When I wrote my enhanced version, I decided to write one for any file (!TS), and one for text only (!TSA).
Here's the "readme" description on these utilities:
Code:


!TS      - Text Search on multiple files and subdirectories,
           with ignore file(s), summary mode, and case sensitive options,
           and skip-to-next-file facility.
         - When matching text found in a file::
           1) Press V for ViewFile to route the file to !LOOK.EXE for viewing.
           2) Press E for EditFile to route the file to DOS Edit by default,
              or create !TSEDIT.BAT to go to an editor of your choice.
         - Text may also be specified as ASCII characters in decimal or
           hexadecimal notation.
         - Records containing matching text can be extracted to a file.
           Each extracted record can also contain filename of origin.
         - Notes:
           * Running !TS from a batch file is not supported.
           * If a particular search string is not working properly,
             enclose it in quotes; it may conflict with option switches.
         - Run program without any parameters for complete description.

!TSA     - Text Search intended for ASCII files, based on the !TS utility,
           with the following additional features:
           * A search area within the records can be defined with the
             /FROM= and /TO= commandline parameters.
             The specified searchtext will only be searched for in this area.
             If /TO= is not specified, area begins at /FROM= until end
             of each record.
           * Records NOT matching the searchtext can now be extracted to
             a file by using the /REMOVE option.
           * Enables using \\ as variable length wildcards in search texts.  
           * /MFILE=filename option enables multiple search texts to be
             used by including them on separate lines of user specified file.
             However, the \\ wildcards are not supported on these multiple
             search texts. A logical "and" can be specified on /MFILE search
             texts by including 2 or 3 search texts on the same line
             separated by a $AND$ operand.
           * /LINE option will preceed extracted lines with the line number
             of the occurrence, and will also left-justify extracted lines.
         - This utility can now be invoked from a batchfile, unless
           you use the /CS option for case sensitive search text.
         - This utility was particularly useful for searching source programs
           for Y2K related problems.
         - Run program without any parameters for complete description.

*****


Title: search program
Post by: everett on November 26, 2005, 04:50:14 PM
well what is wrong with it
http://fileanchor.com/11319-d
code is there


Title: search program
Post by: tannervp on November 26, 2005, 04:57:09 PM
I get a "file creation error"


Title: search program
Post by: Moneo on November 26, 2005, 05:01:25 PM
Quote from: "everett"
well what is wrong with it
http://fileanchor.com/11319-d
code is there

The SEARCH.BAS file is a tokenized (binary) QBasic file, not an ASCII file. I use QuickBasic not QBasic, so I can't read it.

Unless you have documentation comments at the top of the program, please don't expect me to get into your program to see what it does and how it does it. In a previous post I asked you for some specifications.

If you want my help, you have to do what I request.
*****


Title: search program
Post by: everett on November 26, 2005, 05:08:27 PM
[/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]


Title: search program
Post by: tannervp on November 26, 2005, 05:16:01 PM
Quote from: "everett"
Code:

cls
print "to work create a folder called search in the folder you put this"
print "program in"
print "the results will be in search\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$
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"


Title: search program
Post by: everett on November 26, 2005, 05:19:10 PM
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


Title: search program
Post by: tannervp on November 26, 2005, 05:21:46 PM
you messed up somewhere. I tried that and got the same file creation error


Title: search program
Post by: everett on November 26, 2005, 05:24:03 PM
dir \search\search.txt
mabey
or just search.txt


Title: search program
Post by: Moneo 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.
*****


Title: search program
Post by: everett 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


Title: search program
Post by: everett on November 27, 2005, 12:08:24 AM
that change dosenot work


Title: search program
Post by: everett 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.
*****


Title: search program
Post by: Moneo 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.
*****


Title: search program
Post by: Moneo 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:
*****