Author |
Topic  |
|
Da_Stimulator
DEV Team Forum Moderator
    
USA
3373 Posts |
Posted - 12 November 2001 : 05:09:00
|
Go here and put the following in the 'input' box.
<% 'just testing %>
<%=test%>
See what the outcome is...
Explanation If you havnt guessed, eventually this will be a somewhat advanced response.writer - but its in its VERY early stages right now (so early the response.writes arent even put in yet...)
Problem If you'll notice the outcome when you hit submit... its not right, theres an extra %> in there that shouldnt be. I have NO clue whats wrong...
The source Below is the function that processes the script. The rest of the script is just blah... this is the main thing, so your not missing much. stringdata is 'request.form("input")' - so... pretty self explanatory...
The function
Function ProcessScript(stringdata) if Trim(stringdata) = "" then Exit Function end if te = stringdata if (Instr(1, te, Chr(37) & ">", 1) > 0) then te1a = split(te, Chr(37) & ">" & Chr(34)) te1asize = Ubound(te1a) if te1asize > 0 then For I=0 to te1asize If (Instr(1, te1a(I), "<" & Chr(37) & "=", 1) > 0) or (Instr(1, te1a(I), Chr(34) & "<" & Chr(37) & "=", 1) > 0) then 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)
te1a(I) = replace(te1a(I), repstr1, repstr1a, 1, -1, 1) 'te(I) = replace(te(I), repstr2, repstr2a, 1, -1, 1) 'te1a(I) = replace(te1a(I), repstr3, repstr3a, 1, -1, 1) 'te(I) = replace(te(I), repstr4, repstr4a, 1, -1, 1) te1a(I) = te1a(I) & " & " & String(3, Chr(34)) else te1a(I) = te1a(I) & Chr(37) & ">" & Chr(34) end if Next te = Join(te1a) else te = te end if te1 = split(te, Chr(37) & ">") te1size = Ubound(te1) if te1size > 0 then For I=0 to te1size If (Instr(1, te1(I), "<" & Chr(37) & "=", 1) > 0) or (Instr(1, te1(I), Chr(34) & "<" & Chr(37) & "=", 1) > 0) then 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)
te1(I) = replace(te1(I), repstr1, repstr1a, 1, -1, 1) 'te(I) = replace(te(I), repstr2, repstr2a, 1, -1, 1) te1(I) = replace(te1(I), repstr3, repstr3a, 1, -1, 1) 'te(I) = replace(te(I), repstr4, repstr4a, 1, -1, 1) te1(I) = te1(I) & " & " else te1(I) = te1(I) & Chr(37) & ">" end if Next te = Join(te1) else te = te end if else te = te end if
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
Edited by - da_stimulator on 12 November 2001 05:42:41 |
|
paco
Junior Member
 
Spain
187 Posts |
Posted - 12 November 2001 : 05:36:20
|
What about this idea (bad syntax), not too elegant but should work.
sub replacer (beginFrom, myString)
dim pos
pos = inString (beginFrom, myString,"<%=")
mystring (pos) = """ ' bad syntax mystring(pos +1) = "&" mystring(pos +2) = ""
pos = inString (pos,myString,"%>") mystring (pos) = "&" ' bad syntax mystring(pos +1) = """
end sub
|
 |
|
Da_Stimulator
DEV Team Forum Moderator
    
USA
3373 Posts |
Posted - 12 November 2001 : 05:41:53
|
I think you missed the point. I want to keep main script blocks in place... eg
<% 'stuff %>
stays there, but
<%=stuff%>
is converted into " & stuff & "
and
"<%=stuff%>"
is converted into """ & stuff & """
<%=stuff%>" is converted into " & stuff & """ "<%=stuff%> is converted into """ & stuff & "
etc etc etc...
The above function works, it just adds some stuff, because my error checking is off somwhere, I just cant spot it.
---- -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 |
 |
|
paco
Junior Member
 
Spain
187 Posts |
Posted - 12 November 2001 : 05:50:27
|
Lets see if I understand.
You want to always replace <%= ... %> with "& .. &" but you want <% ... %> to stay always in place.
The only difference between these two kinds of blocks is that the one you want to change is the one that begins with <%= instead of begining with "<%" (with no =).
Is that right? If it is, that's what my piece of code does.
|
 |
|
Da_Stimulator
DEV Team Forum Moderator
    
USA
3373 Posts |
Posted - 12 November 2001 : 05:53:53
|
yes thats right, your piece of code didnt work :(, and only replaced one instance of it.
---- -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 |
 |
|
paco
Junior Member
 
Spain
187 Posts |
Posted - 12 November 2001 : 06:05:52
|
It has bad syntax. I just wanted to show you my idea.
I don't think we can do this
mystring (pos)
with a string in vbscript. It just represents the character at that position
The algorithm of my idea is something like this:
while we don't find the end of the string...
1 search for "<%=" and grab the position of that 2 replace it with "& 3 search for the closing "%>" begining searching from the position where we found "<%=" 4 replace closing %> with &" 5 search again for "<%=" starting after the position where we found the last closing %> (this is number 1 again) ...
I would use inString as it returns the position of the first occurence
|
 |
|
Da_Stimulator
DEV Team Forum Moderator
    
USA
3373 Posts |
Posted - 12 November 2001 : 06:09:25
|
here's what my script does... it splits each occurance of %> into an array... so
<% this %> <% that %> <%=this%> <%=that%>
would each have its own set
it then finds out whether each block is a <%= or just <%. If its <%=, it processes it to output the required format. if its just <% then it leaves it as is.
Its functional and works. There is just an error I missed somewhere that adds the %> to the end of the line. I have no requirement to replace my entire function, just to spot the error.
---- -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 |
 |
|
paco
Junior Member
 
Spain
187 Posts |
Posted - 12 November 2001 : 06:30:52
|
I don't know if this is the problem but I spoted this:
te1asize = Ubound(te1a) For I=0 to te1asize
You are accesing one element too much
|
 |
|
Da_Stimulator
DEV Team Forum Moderator
    
USA
3373 Posts |
Posted - 12 November 2001 : 06:36:33
|
woohoo! you got it :) that fixed it, thx :P
---- -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 |
 |
|
paco
Junior Member
 
Spain
187 Posts |
Posted - 12 November 2001 : 06:38:53
|

|
 |
|
|
Topic  |
|
|
|