Snitz Forums 2000
Snitz Forums 2000
Home | Profile | Register | Active Topics | Members | Search | FAQ
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 Community Forums
 Code Support: ASP (Non-Forum Related)
 replacing text only if 2 things exist...
 New Topic  Topic Locked
 Printer Friendly
Author Previous Topic Topic Next Topic  

Da_Stimulator
DEV Team Forum Moderator

USA
3373 Posts

Posted - 11 November 2001 :  22:42:37  Show Profile  Send Da_Stimulator an AOL message  Send Da_Stimulator a Yahoo! Message
Sorta complicated, I only want to replace text if two things exist, <%= and %>, and on each separate account also...

For example, if I have the following code:

<%
'stuff here
%>

The stuff is <%=here%> <-there

The outcome would be:

<%
'stuff here
%>

The stuff is " & here & " <-there

I have the following function to do this, BUT it also replaces %> that exist in other places, and I dont want it to do that. I remember seeing something on 4guys about this but hell if I could find it again. The concept this is based on is a response.writer. I know they already exist, but they either suck, or arent for distribution. This one is going to be for free distribution, so webmasters can use them on there own site.

Here's the function that processes the string... It dosnt insert the response.writes yet, but I was going to have it do that after it filters everything else


Function ProcessScript(stringdata)

if Trim(stringdata) = "" then
Exit Function
end if

te = stringdata

repstr1 = Chr(34) & "<" & Chr(37) & "="
repstr1a = String(3, 34) & " & "

repstr2 = Chr(37) & ">" & Chr(34)
repstr2a = strReverse(repstr1a)

repstr3 = "<" & Chr(37) & "="
repstr3a = Chr(34) & " & "

repstr4 = Chr(37) & ">"
repstr4a = strReverse(repstr3a)

te = replace(te, repstr1, repstr1a, 1, -1, 1)
te = replace(te, repstr2, repstr2a, 1, -1, 1)
te = replace(te, repstr3, repstr3a, 1, -1, 1)
te = replace(te, repstr4, repstr4a, 1, -1, 1)

ProcessScript = te
End Function


----
-Eric (da_stimulator)
Stims Snitz Test area - Running 3.3.03, 4 beta, Huw's code, and Davio's code
Need a Mod? Check out the Mod Resource

redbrad0
Advanced Member

USA
3725 Posts

Posted - 12 November 2001 :  10:24:40  Show Profile  Visit redbrad0's Homepage  Send redbrad0 an AOL message
Well I am not sure if you saw it on my site Stim but I did write one. It could be alot better, but it does work. This one basically takes html and convertes it to Response.Write with the correct line tags and everything. The only problem is when you include asp in the html. But maybe it will give you some ideas. I wrote this maybe 1.5 - 2 years ago so I dont even remember what the code looks like but here is the link

http://www.freeaspcode.net/wizards/response.write.asp

Brad
Web Hosting with SQL Server @ $24.95 per month
Snitz Mod Archive

Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Topic Locked
 Printer Friendly
Jump To:
Snitz Forums 2000 © 2000-2021 Snitz™ Communications Go To Top Of Page
This page was generated in 0.27 seconds. Powered By: Snitz Forums 2000 Version 3.4.07