|
|
 |
| ASP.NET 1.0 and 1.1 Professional For advanced ASP.NET 1.x coders. Beginning-level questions will be redirected to other forums. NOT for "classic" ASP 3 or the newer ASP.NET 2.0 and 3.5 |
Welcome to the p2p.wrox.com Forums.
You are currently viewing the ASP.NET 1.0 and 1.1 Professional section of the Wrox p2p Programmer to Programmer discussion community. This is a community of more than 40,000 computer programmers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining our free Wrox p2p community you can post your own programming questions and respond to other programmers questions. Registered users also don't have to see the ads that are displayed to guests. Registration is fast, simple and absolutely free so please, join today!
Join today and post to win prizes! Post more to increase your chances of being Wroxs top poster of the month.
|
 |

June 5th, 2007, 10:24 PM
|
|
Registered User
|
|
Join Date: Jun 2007
Location: Chicago, IL, USA.
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Find&Replace
Hello Everyone,
I have a question regarding the use of Find&Replace Function....
I'm using a Find&Replace script technique to insert code snipets into an Webpage.aspx
e.g. By Entering a Unique (Keyword) and then Replace with the (Code Snipnet).
Now this all seems to work Fine. But the problem I started noticing, is that as the Wedpage grows insize because I am always adding new (datagrid Code to it)with the additional volume (code Snipets) being always added. That it takes longer and longer for the Find&Replace to Work.
Is there a way to get The Find&Replace to go Directly to the
(Keywords) instead of Searching thru all of the Codes being
added? (or) Start Searching From the Top of the Webpage first???
Is there someway to Optimize the Find&Replace Solution? Ideally I't would be nice if it could Find the
(Keywords) straight away, instead of combing thru everything...and using up precious time. Any insight would be Appreciated. Thank You.
|

June 6th, 2007, 08:50 AM
|
 |
Friend of Wrox
Points: 16,368, Level: 55 |
|
|
Join Date: Aug 2003
Location: Clifton Park, New York, USA.
Posts: 5,394
Thanks: 0
Thanked 2 Times in 2 Posts
|
|
This is what a search and replace does. It's how it works. How do you expect for the search to find something if it doesn't go thru everything?? That's the whole point. Do you know where the keywords are already? Can you navigate to them?
I have not found that search and replace is slow in Visual Studio (I assume that is what you are asking about, you have not specified). Perhaps your code files are getting too big and you could break apart functionality to keep the individual files smaller.
Is it possible that you have the search settings set to search all files or all open documents instead of just the current document? Searching thru other files would be noticeably slower.
- Peter
|

June 6th, 2007, 10:29 AM
|
|
Registered User
|
|
Join Date: Jun 2007
Location: Chicago, IL, USA.
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Hello planoie,
Let me explain about the Webpage use, The Datagrid being added to the Webpage is for different clients, each DataGrid contains infomation unique for that client only. Now instead of always having to manually adding new Datagrids to the Webpage as needed. I have written a FindnReplace Code to run and automatically add the new Datagrid as necessary, using certain (keyword) with the FindnReplace code. Now with 1-10 clients on the Webpage it works extremely fast and efficient. I noticed as the Webpage grows in size the efficiency starts to bog down...This is Not Good... So hence my dilemma. I was hoping for a some kind of solution to get the FindnReplace technique to somehow go directly to the (Keywords), Or Read from the Top of the Webpage. The (Keywords) I have been using are TextWords. Would it make any difference if I changed the Keywords to Somekind of Unique (Sysbols)=$$~~$$) instead ???
If only there were a way to keep the FindnReplace Code from having to read thru Everything - somehow to block it and only read what you want it to read. This is where my thoughts are. I'm not sure if this is possible??? Here is my Replace Code snipet. . . If you can think of Something that would be great. . .Thank You.
__________________________________________________ __________________________________________________ ___________________________________________
void btnReplace_Click(object sender, EventArgs e) {
txtReplace.Text = txtContents.Text;
txtFound.Text ="";
if(CheckEmpty())
{
DirectoryInfo DI= new DirectoryInfo(txtFolder.Text);
if(DI.Exists)
{
int FileCount=0;
lstFound.Items.Clear();
foreach(FileInfo FI in DI.GetFiles())
{
if(FI.Extension==txtFileExt.Text || txtFileExt.Text=="" ||txtFileExt.Text=="*.*")
{
try
{
StreamReader SR= new StreamReader(FI.OpenRead());
String s;
String temp="";
int pos=0;
s=SR.ReadLine();
while(s!=null)
{
temp=temp+s+"\r\n";
s=SR.ReadLine();
}
temp=temp.Substring(0,temp.Length-2);
SR.Close();
if(temp.IndexOf(txtFind.Text)>=0)
{
pos=temp.IndexOf(txtFind.Text);
//txtFound.Text =txtFound.Text +FI.Name + " Char:"+pos+System.Environment.NewLine;
lstFound.Items.Add(FI.Name + " Char:"+pos+System.Environment.NewLine);
//MessageBox.Show("temp:"+temp+ " "+"txtFind:"+txtFind.Text+" txtReplace:"+txtRepla ce.Text);
temp=temp.Replace(txtFind.Text,txtReplace.Text = txtContents.Text.Trim());
//MessageBox.Show("temp: "+temp);
FI.Delete();
StreamWriter SW= new StreamWriter(FI.OpenWrite());
SW.Write(temp);
SW.Close();
FileCount++;
}
}
catch(Exception)
{
MessageBoxShow.Text = ("Error opening file!");
}
}
} // Foreach Loop Ends Here
txtFound.Text =txtFound.Text + "Replace Completed Successfully..."+System.Environment.NewLine + "No of Occurences :" +FileCount;
} // IF Loop Ends Here
else
MessageBoxShow.Text = ("Please enter a valid directory path!");
}
|

June 6th, 2007, 10:40 AM
|
 |
Friend of Wrox
Points: 16,368, Level: 55 |
|
|
Join Date: Aug 2003
Location: Clifton Park, New York, USA.
Posts: 5,394
Thanks: 0
Thanked 2 Times in 2 Posts
|
|
Why not build the application flexible so that you can change the client configuration instead of essentially reprogramming it? This sounds like more of a fundamental design problem. Perhaps you need to rethink how the application is built.
Can you explain a bit more about the variation from client to client? Are you creating multiple instances of the same application for different clients? Is this one application that have client context switching? It's is not obvious what solution to provide without some additional information.
Regarding the performance of the search: I think you are stuck with what you have. Simply put, a search searches everything within the file, character by character. No matter how you slice and dice the file contents, you still have to go thru all the lines and all the chars to find anything. But based on my previous comment, there may very well be a much more programmatically elegant, efficient and configurable way to build the application that may likely eliminate all this searching and replacing.
- Peter
|
| Thread Tools |
Search this Thread |
|
|
|
| Display Modes |
Linear Mode
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
|
 |