Download the free trial version
Basic4android Video
Features
Tutorials and manuals
Showcase
Screenshots

Go Back   Android Development Forum - Basic4android > Basic4ppc (Windows Mobile) > Questions (Windows Mobile)
Documentation Wiki Register Members List B4P Search Today's Posts Mark Forums Read

Questions (Windows Mobile) Post any question regarding Basic4ppc.

Searching all text files in a directory

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 08-16-2008, 01:55 PM
Basic4ppc Veteran
 
Join Date: Apr 2008
Location: Gosford NSW Australia
Posts: 223
Send a message via MSN to tsteward
Default Searching all text files in a directory

Any ideas how I might quickly search all text files (with the extension 'txt') in a single folder for given text?
Reply With Quote
  #2 (permalink)  
Old 08-16-2008, 02:12 PM
Cableguy's Avatar
Basic4ppc Expert
 
Join Date: Apr 2007
Location: N 41º11'30.30" W 8º39'46.60"
Posts: 2,313
Awards Showcase
Forum Contributer 
Total Awards: 1
Default

List all files is easy, searching for a particular string in any of those files...
The easiest way is to load esch file and do the search in each of them, populating some sort of "Hit-list" with the results...
But that would be very time and resouce consuming..
__________________
Paulo Gomes - Porto, Portugal - Living/Working in France-Saumur
Mobile Device: Samsung Galaxy S, Android 2.3.4 CUstom ROM
Laptop: Toshiba NB100-130 (running on Win7Ultimate)
B4PPC DLL Version Listing - B4Android DLL Version Listing
Reply With Quote
  #3 (permalink)  
Old 08-16-2008, 02:37 PM
Basic4ppc Veteran
 
Join Date: Apr 2008
Location: Gosford NSW Australia
Posts: 223
Send a message via MSN to tsteward
Default

Quote:
Originally Posted by Cableguy View Post
List all files is easy, searching for a particular string in any of those files...
The easiest way is to load esch file and do the search in each of them, populating some sort of "Hit-list" with the results...
But that would be very time and resouce consuming..
Yeah well that is what I have done so far.
I guess I was hoping someone had some other method.

My Code(obviously I will replace the message box with populating a list)
Code:
ALFiles.Clear
  FileSearch(ALFiles,SubString(wikiDir,
0,StrLength(wikiDir)-1),"*.txt")
  
For f=0 To ALFiles.Count-1
   FileOpen (c1, ALFiles.Item(f), cRead ,, cASCII)
   contents = FileReadToEnd(c1)
   FileClose (c1)
   r=StrIndexOf(contents,
"[" & currentpage & "]",0'+ StrIndexOf(contents,"][" & currentpage & "]]",0)
   s = StrIndexOf(contents, "][" & currentpage & "]",0)
   
If r>-1 AND s = -1 Then
    
Msgbox(ALFiles.Item(f) & crlf & "Is Backlink")
   
End If
  
Next
Reply With Quote
  #4 (permalink)  
Old 01-03-2009, 10:18 AM
Basic4ppc Veteran
 
Join Date: Apr 2008
Location: Gosford NSW Australia
Posts: 223
Send a message via MSN to tsteward
Default Search Subdirectories

How can I get all the *.txt files in the current directory and ALL sub directories. Not sure how to find and keep track of all the sub dirs
__________________
PC: Dual core 3.4ghz 2gb ram
PPC: I-mate Jasjam
Reply With Quote
  #5 (permalink)  
Old 01-03-2009, 01:35 PM
klaus's Avatar
Basic4ppc Expert
 
Join Date: Oct 2007
Location: Fully, Switzerland
Posts: 3,827
Awards Showcase
Forum Contributer Beta Tester Competition Winner 
Total Awards: 3
Default

Here you have an example, it goes only 3 levels of subdirectories deep, if you need more you can add the needed code.

Best regards.
Attached Files
File Type: sbp SearchSubDirs.sbp (1.3 KB, 32 views)
__________________
Klaus
Switzerland
Reply With Quote
  #6 (permalink)  
Old 01-03-2009, 05:08 PM
specci48's Avatar
Basic4ppc Expert
 
Join Date: Apr 2007
Location: Germany
Posts: 993
Awards Showcase
Beta Tester Forum Contributer 
Total Awards: 2
Default

Just to complete this thread: The solution is here.
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
Text Files Erel Tutorials 14 04-24-2009 09:26 AM
Downloadfile and text files N1c0_ds Questions (Windows Mobile) 3 10-17-2008 03:55 AM
How to find files in a directory pmu5757 Questions (Windows Mobile) 2 05-07-2008 01:37 PM
Text editor for INI files Softselect Questions (Windows Mobile) 2 11-15-2007 07:50 AM
Dividing the code into text files... Cableguy Questions (Windows Mobile) 5 05-21-2007 04:21 PM


All times are GMT. The time now is 04:48 AM.


Powered by vBulletin® Version 3.6.12
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.0