User Tag List

Page 1 of 2 1 2 LastLast
Results 1 to 10 of 11

Thread: Searching a directory and sub directories for text

  1. #1
    Clickteam Clickteam
    LB's Avatar
    Join Date
    Jun 2007
    Location
    Richardson, Texas, North America
    Posts
    8,937
    Mentioned
    4 Post(s)
    Tagged
    0 Thread(s)

    Searching a directory and sub directories for text

    This is a very simple 2 and a half event search system that searches every file of a certian extension for a string of text within the file. It records the file path and the location of the text it found in an array object for usage elsewhere. It can easily be customized and have more features and such added (such as wildcard searching both in the search string and the filenames) but I left that out because that is besides the point of the example

    Enjoy,
    -LB
    Attached files Attached files
    Working as fast as I can on Fusion 3

  2. #2
    Clicker Multimedia Fusion 2 DeveloperInstall Creator Pro

    Join Date
    May 2010
    Posts
    536
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: Searching a directory and sub directories for text

    Hey, LB! Thank you for spending the time and effort to putting together this great example!

    I can see why it was easier to build the example than to try to explain it (even though it is only two or three events long). I do have a few questions, especially since it uses objects I've never used before.

    1.) When using the File-Folder object, what does the "On File while browsing loop" action do?

    2.) I see from the condition statement how you specified lower-case (using the Lower$). However, I can't seem to replicate that when I try to reconstruct the expression myself (without typing it in manually). How did you set up case-sensitivity?

    3.) What does the Binary object do? Furthermore, does the Binary Quickload object just read the contents of the Binary object? And why is the file size significant that the Binary object gets the file size of files found in the target directory?

    4.) I see you placed text stating how the Array object is set up: "X" represents the search ID, while "Y" represents the path to the file. I am confused how you have "Y 0" and "Y 1", though in a two-dimensional array.

    5.) I see that "Y 0" represents the path to the file with a search hit, and that "Y 1" represents where in the target file the search criteria was found. The big question is, how can I pull that information from the array and create hyperlinks to the target files? Would I use perhaps an Edit box to capture the text of each hit, then use some other object to create hyperlinks?


    As always, I very much appreciate the time and effort you (and others) spend in teaching newbies like me how to better use MMF2! Have a great day!



    Most sincerely,

    RGBreality

  3. #3
    Clickteam Clickteam
    LB's Avatar
    Join Date
    Jun 2007
    Location
    Richardson, Texas, North America
    Posts
    8,937
    Mentioned
    4 Post(s)
    Tagged
    0 Thread(s)

    Re: Searching a directory and sub directories for text

    Quote Originally Posted by RGBreality
    1.) When using the File-Folder object, what does the "On File while browsing loop" action do?
    Think of it as the ForEach obejct works. This basically loops through every file in the folder and all subfolders of the directory you specify. I sued the On File condition because there isn't a point in searching inside of a folder, since folders don't contain any data. The files in the folders contain the data.

    Quote Originally Posted by RGBreality
    2.) I see from the condition statement how you specified lower-case (using the Lower$). However, I can't seem to replicate that when I try to reconstruct the expression myself (without typing it in manually). How did you set up case-sensitivity?
    This makes it case-insensitive, so that it does't matter if it is .txt or .TXT or.tXT, ect. This expression is from the special object, under Strings -> Convert String to Lower case (and there is also upper case)

    Quote Originally Posted by RGBreality
    3.) What does the Binary object do? Furthermore, does the Binary Quickload object just read the contents of the Binary object? And why is the file size significant that the Binary object gets the file size of files found in the target directory?
    The binary object is an advanced extension that lets you load files and manually edit each and every byte. This is how real programming works, with bytes and shorts and longs and chars, ect. The Binary Quickload object loads the file data into the binary object faster than binary object can do so it self. This makes it take less time to load the files. It is still possible to laod fiels without Binary Quickload, it will just not be quick Furthermore the binary object loads the file into it self, so of course it will have the same size as the file unless you resize it. It is basicalled a 1-D array.

    Quote Originally Posted by RGBreality
    4.) I see you placed text stating how the Array object is set up: "X" represents the search ID, while "Y" represents the path to the file. I am confused how you have "Y 0" and "Y 1", though in a two-dimensional array.
    I think you need to re-read the comment. X is indeed the search ID because where x = any number, that will correspond to a location in the array on the X axis. Then you need the Y value 0 or 1 for if you want to get the path to the file, or the location in the file where the text was found.

    Quote Originally Posted by RGBreality
    5.) I see that "Y 0" represents the path to the file with a search hit, and that "Y 1" represents where in the target file the search criteria was found. The big question is, how can I pull that information from the array and create hyperlinks to the target files? Would I use perhaps an Edit box to capture the text of each hit, then use some other object to create hyperlinks?
    For the hyperlinks, you have two options. You can use an alterable string with blue underlined text and have the Flash Player object or Cursor obejct change the cursor to a click-hand when over it, then go to the file when clicked, or you can use the Rich Edit obejct set to read only, use 2.0 features, and detect URLs automatically. Then just make an event "Hyperlink clicked: {use whatever method you like to then open the file}
    Working as fast as I can on Fusion 3

  4. #4
    Clicker Multimedia Fusion 2 DeveloperInstall Creator Pro

    Join Date
    May 2010
    Posts
    536
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: Searching a directory and sub directories for text

    Hey, LB! Thank you for you thorough post and explanation!

    I started working on expanding your search example (based on your work). I set up two Rich Edit objects: one to display the "Hit results" (the actual words which contain the search string), and another to display the file path. I was able to successfully set up the file path Rich Edit object, and am able to highlight a file path, click a button, then have a File-Folder object open it in the default Web browser.

    However, I am stuck on a few things, which I was hoping you might be able to assist me with:

    1.) I couldn't figure out how to acquire the actual "search hits."

    2.) Instead of opening the files in an external Web browser, I'd like to open the HTML files in a Web Control object. How would I do that?

    3.) Despite setting up a Rich Edit object, enabling 2.0 functionality, and setting up the "File link" box to read-only, the file paths did not come across as links. How would I set them up as hyperlinks? I don't mind setting up the results to return as "simulated links" (where I make them blue underlined text and I use a Cursor control to change the cursor icon), but how would each file path be selected automatically?


    Thank you again for all your help and feedback! I'm definitely learning a lot from absorbing from you gurus!

    Have a great day!



    Most appreciatively,

    RGBreality
    Attached files Attached files

  5. #5
    Clickteam Clickteam
    LB's Avatar
    Join Date
    Jun 2007
    Location
    Richardson, Texas, North America
    Posts
    8,937
    Mentioned
    4 Post(s)
    Tagged
    0 Thread(s)

    Re: Searching a directory and sub directories for text

    Quote Originally Posted by RGBreality
    1.) I couldn't figure out how to acquire the actual "search hits."
    I don't understand this, do you mean like the # of total finds? That is simple the width of the array.

    Quote Originally Posted by RGBreality
    2.) Instead of opening the files in an external Web browser, I'd like to open the HTML files in a Web Control object. How would I do that?
    Same way, but with the Web COntrol object

    Quote Originally Posted by RGBreality
    3.) Despite setting up a Rich Edit object, enabling 2.0 functionality, and setting up the "File link" box to read-only, the file paths did not come across as links. How would I set them up as hyperlinks? I don't mind setting up the results to return as "simulated links" (where I make them blue underlined text and I use a Cursor control to change the cursor icon), but how would each file path be selected automatically?
    Well, because of how the internet hyperlink system all works, you have to typ it like this:
    file:///C:\My%20File.txt
    Working as fast as I can on Fusion 3

  6. #6
    Clicker Multimedia Fusion 2 DeveloperInstall Creator Pro

    Join Date
    May 2010
    Posts
    536
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: Searching a directory and sub directories for text

    Ah, I see. So I just need to place

    "file:///"+

    in front of the search result from the File-Folder object, and I would have a URL which the Web Control object could locate.

    I found that using a list box (instead of an Edit box) to capture the file path hits was easier. I'm now able to double-click on any hit and open it in a Web Control object.

    I have a few more questions, though... (Isn't that a surprise!)

    1.) How would I set up case-sensitive or wildcard searches? What I am a little fuzzy about is whether the string in which I'm searching is being searched through the contents of files, or only the file names? If it is being searched only through file names, then case-sensitivity is probably a moot point.

    2.) I have a feeling that the search is only searching file names and not text within files. If I perform text searches on text strings I know would be there (such as the company name), I receive no hits. That is likely because the company name is not used in any file names in our documentation. So, how would I be able to search text in files?

    3.)How can I search for multiple extensions in a single search?

    Thank you again for your help!


    Most graciously,

    RGBreality

  7. #7
    Clickteam Clickteam
    LB's Avatar
    Join Date
    Jun 2007
    Location
    Richardson, Texas, North America
    Posts
    8,937
    Mentioned
    4 Post(s)
    Tagged
    0 Thread(s)

    Re: Searching a directory and sub directories for text

    Quote Originally Posted by RGBreality
    1.) How would I set up case-sensitive or wildcard searches? What I am a little fuzzy about is whether the string in which I'm searching is being searched through the contents of files, or only the file names? If it is being searched only through file names, then case-sensitivity is probably a moot point.
    Well, seeing as the program loads the contents of the file into it and then runs a loop through the contents of the file, I think that counts as searching the contents of the file and not the file name.

    Quote Originally Posted by RGBreality
    2.) I have a feeling that the search is only searching file names and not text within files. If I perform text searches on text strings I know would be there (such as the company name), I receive no hits. That is likely because the company name is not used in any file names in our documentation. So, how would I be able to search text in files?
    As said above, it already does search inside the files. It does not check the filename at all.

    Quote Originally Posted by RGBreality
    3.)How can I search for multiple extensions in a single search?
    I don't understand what you mean here, would you explain please?
    Working as fast as I can on Fusion 3

  8. #8
    Clicker Multimedia Fusion 2 DeveloperInstall Creator Pro

    Join Date
    May 2010
    Posts
    536
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: Searching a directory and sub directories for text

    Hey, LB!

    I uploaded my existing iteration of the text search application, along with HTML files as part of one product document. In this ZIP file, I didn't include any of the supporting files which would allow the HTML to display graphics intact; but the text is there.

    I am wondering why text searches which should bring up hits are not bringing them up. For example, perform the search on the word "Ultimus" (which is the name of the company I work for). The word "Ultimus appears both in file names and text content in these HTML files.

    Yet, when I perform a search on a single letter (such as "e" or "a"), I get plenty of hits.

    Let me clarify my question regarding how to perform a search for multiple extensions in a single search query. Suppose that instead of only searching for HTML files (.HTM), I also wanted to search through PDF files (.PDF). How could I set up a search query (and an Edit box) that would allow multiple file extension types to be included in a single search?

    You will see in the MMF2 file that I now use a List View object to display search results: one column displays the name of the document in which the search hit was found, and the second displays the file path.

    Unfortunately, now that I am using a List View object, I am struggling with how to set up events that if the user double-clicks on the content of the first column (the "line"), then the content of the second column in the same row would be selected and sent to the Web Control object for opening. How would I set something like that up?

    My next level of ambition with this is to not display HTML file in isolation from the rest of the product document. I would ultimately like to be able to open the main page of the pertinent document ("index.html"), then have the HTML file in question display. That way, the reader has context where in the document the search result took place (very much as if they did the search in a native CHM or HTML Help file directly). But that's the next step. If you have any ideas on how I'd implement that, I'd be very open to your ideas!

    Ultimately, I think once this text search is properly developed, I'll post it here for others to use for their search needs.

    As always, thank you for your help!


    Most graciously...

    RGBreality
    Attached files Attached files

  9. #9
    Clickteam Clickteam
    LB's Avatar
    Join Date
    Jun 2007
    Location
    Richardson, Texas, North America
    Posts
    8,937
    Mentioned
    4 Post(s)
    Tagged
    0 Thread(s)

    Re: Searching a directory and sub directories for text

    First off, you are searching for .htm files when all your documents are html. Don't forget the L, lol.

    And about the multiple extensions, you could just delete the condition that compares the extension you are looking for to the extension of the file that was found. If you want to limit the extensions you will need to be a bit more complex. And if you even still more want to do real wild card searches (like in windows file browser if you type file*text.t*t it would allow the asterisks to be anything) then you would have to do things that I do not yet know how to do. :blush:

    And I also forgot to respond to one thing you questioned eariler; to make it case sensitive, you need to get rid of the lower$ expressions from the text comparing condition so that it must be an exact match.
    Working as fast as I can on Fusion 3

  10. #10
    Clicker Multimedia Fusion 2 DeveloperInstall Creator Pro

    Join Date
    May 2010
    Posts
    536
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: Searching a directory and sub directories for text

    Hey, LB!

    You know, I had been banging my head against the wall for days on why I wasn't getting search hits in the actual documentation--until I looked at the documentation I GENERATE MYSELF and realized I output to .HTML... Sigh... I was about to write you that I finally figured out what I was doing wrong!

    Here's an idea that just occurred to me which I haven't tried yet... If I wanted to be able to search against more than one file extension (but a limited number, rather than just all files), suppose I had another Edit box in which the user could enter a second file extension (such as PDF). Then, in the condition which you authored which states "On File While Browsing Loop..." I were to insert an "OR" operand, then duplicate your comparison of the first file extension type with the file extension provided? Would something like that work?...

    What a great project this is turning out to be!

    As always, thank you for your feedback and great guru knowledge!


    Most appreciatively...

    RGBreality

Page 1 of 2 1 2 LastLast

Similar Threads

  1. list of directories
    By ChrisBurrows in forum Multimedia Fusion 2 - Technical Support
    Replies: 6
    Last Post: 17th April 2012, 10:14 AM
  2. Coping entire directories?
    By ChrisBurrows in forum Multimedia Fusion 2 - Technical Support
    Replies: 8
    Last Post: 17th April 2012, 09:05 AM
  3. ftp object : How can you view directories?
    By MikeB in forum Multimedia Fusion 2 - Technical Support
    Replies: 0
    Last Post: 25th November 2008, 03:55 AM
  4. Copy files and directories
    By juanjo in forum Multimedia Fusion 2 - Technical Support
    Replies: 6
    Last Post: 18th April 2008, 10:16 PM
  5. Which object to use to select Directories?
    By MelliGeorgiou in forum Multimedia Fusion 2 - Technical Support
    Replies: 2
    Last Post: 29th October 2006, 02:40 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •