Yes! Here are two ways of preventing a block of code from writing... the first requires two comments to make it run / not run, the second requires one line change.
<‰
Sub doNotExecuteThisCode
For Each x In Request.Form
Response.Write x & "<br>"
Next
Response.End
End Sub
‰>
<‰
Sub doNotExecuteThisCode
For Each x In Request.Form
Response.Write x & "<br>"
Next
Response.End
End Sub
‰>
Now, to execute the code again, simply comment the Sub and End Sub lines:
<‰
'Sub doNotExecuteThisCode
For Each x In Request.Form
Response.Write x & "<br>"
Next
Response.End
'End Sub
‰>
<‰
'Sub doNotExecuteThisCode
For Each x In Request.Form
Response.Write x & "<br>"
Next
Response.End
'End Sub
‰>
The following method uses simple logic to enter a code block.
<‰
ExecuteCodeBlock = FALSE
If ExecuteCodeBlock Then
For Each x In Request.Form
Response.Write x & "<br>"
Next
Response.End
End If
‰>
<‰
ExecuteCodeBlock = FALSE
If ExecuteCodeBlock Then
For Each x In Request.Form
Response.Write x & "<br>"
Next
Response.End
End If
‰>
Now, to execute the code again, simply change the value of ExecuteCodeBlock to TRUE:
<‰
ExecuteCodeBlock = TRUE
If ExecuteCodeBlock Then
For Each x In Request.Form
Response.Write x & "<br>"
Next
Response.End
End If
‰>
<‰
ExecuteCodeBlock = TRUE
If ExecuteCodeBlock Then
For Each x In Request.Form
Response.Write x & "<br>"
Next
Response.End
End If
‰>
FWIW, the latter method is a little less efficient, since the If logic is actually tested. I use it all the time, however, since it's much easier to set a debug flag on or off to affect a group of blocks of code.
Source : http://classicasp.aspfaq.com/
No comments:
Post a Comment