ASP Code Formatting Demo 2


FormatCode Code Formatter is based on serveral powerful syntax parser engines so you can exactly control the appearance of your source code. Here is the code formatting demo of FormatCode ASP Code Formatter to prove the ability of code formatting functions of FormatCode:

   <!-- Before Code Formatting -->

   <%@ language=VBScript %>
   <html>
   <head>
   <title>Crossbow Soft</title>
   <link rel="stylesheet" href="style.css">
   </head>
   <body bgcolor="#ffffff">
   <div align="center">
     <table border="1" cellpadding="0" cellspacing="0">
       <tr><td width="100%"><%=gbook_name%></td></tr>
     </table>
   </div>
   <%
   call htmlend()
   Response.End:end sub
   sub addto()
   'Add guest name to database
   dim username, email, homeurl, qq, body, addtime, sql, Rs, ip, face, brow

   username=htmlencode2(trim(Request.form("username")))
   email=htmlencode2(trim(Request.form("email")))

   if username = "" then
   message="Your nickname cannot be null!\n"
   elseif username = "root" then
   message="Your nickname cannot be root!\n"
   end if

   sql="select * from retain where userid='"&userid&"'"
   set nrs = Server.CreateObject("ADODB.Recordset")
   nrs.open sql,conn,1,1
   do while not nrs.eof
   if username <>"" and username = nrs("retain_name") then
   message=message&"Your nickname was forbidden by administrator!\n"
   end if
   nrs.movenext
   loop
   nrs.close
   set nrs = nothing

   if email <> "" and IsValidEmail(email)=false then
   message=message&"Your email maybe wrong?\n"
   end if

   if body <> "" and Len(body)> bodymax then
   message=message&"Sorry, message length cannot over "&bodymax&" words!\n"
   end if

   if brow = "" then
   brow="image/em01.gif"
   end if
   if message<> "" then
   call error(""&message&"")
   else

   'Connect ADO now
   sql = "select * from gbook"
   Set Rs = Server.CreateObject("ADODB.Recordset")
   Rs.open sql,conn,3,2
   Rs.addnew
   Rs("username")=username
   Rs("email")=email
   Rs("homeurl")=homeurl
   Rs("qq")=qq
   Rs("body")=body
   Rs("face")=face
   Rs("brow")=brow
   Rs("ip")=ip
   Rs("addtime")=now
   Rs("userid")=userid
   Rs.update
   Rs.close

   sql="select * from admin where id="&userid
   Rs.open sql,conn,3,2
   if date <> today_time then
   Rs("today_count") = 1
   else
   Rs("today_count") = Rs("today_count")+1
   end if
   Rs("today_time") = date
   Rs.update
   Rs.close

   set Rs = nothing
   conn.close
   set conn = nothing

   Response.redirect "index.asp?userid="&userid
   Response.End
   end if
   end sub
   %>
   </body>
   </html>


   <!-- After Code Formatting -->

   <%@ language=VBScript %>
   <html>
   <head>
   <title>Crossbow Soft</title>
   <link rel="stylesheet" href="style.css">
   </head>
   <body bgcolor="#ffffff">
   <div align="center">
     <table border="1" cellpadding="0" cellspacing="0">
       <tr><td width="100%"><%=gbook_name%></td></tr>
     </table>
   </div>
   <%
   Call htmlend()
   Response.End
   End Sub

   Sub addto()
       'Add guest name to database
       Dim username, email, homeurl, qq, body, addtime, sql, Rs, ip, face, brow

       username = htmlencode2(Trim(Request.form("username")))
       email = htmlencode2(Trim(Request.form("email")))

       If username = "" Then
           message = "Your nickname cannot be null!\n"
       ElseIf username = "root" Then
           message = "Your nickname cannot be root!\n"
       End If

       sql = "select * from retain where userid='"&userid&"'"
       Set nrs = Server.CreateObject("ADODB.Recordset")
       nrs.open sql, conn, 1, 1

       Do While Not nrs.EOF

           If username <>"" And username = nrs("retain_name") Then
               message = message&"Your nickname was forbidden by administrator!\n"
           End If

           nrs.movenext
       Loop

       nrs.Close
       Set nrs = Nothing

       If email <> "" And IsValidEmail(email) = False Then
           message = message&"Your email maybe wrong?\n"
       End If

       If body <> "" And Len(body)> bodymax Then
           message = message&"Sorry, message length cannot over "&bodymax&" words!\n"
       End If

       If brow = "" Then
           brow = "image/em01.gif"
       End If

       If message<> "" Then
           Call Error(""&message&"")
       Else

           'Connect ADO now
           sql = "select * from gbook"
           Set Rs = Server.CreateObject("ADODB.Recordset")
           Rs.open sql, conn, 3, 2
           Rs.addnew
           Rs("username") = username
           Rs("email") = email
           Rs("homeurl") = homeurl
           Rs("qq") = qq
           Rs("body") = body
           Rs("face") = face
           Rs("brow") = brow
           Rs("ip") = ip
           Rs("addtime") = Now
           Rs("userid") = userid
           Rs.update
           Rs.Close

           sql = "select * from admin where id="&userid
           Rs.open sql, conn, 3, 2

           If Date <> today_time Then
               Rs("today_count") = 1
           Else
               Rs("today_count") = Rs("today_count") + 1
           End If

           Rs("today_time") = Date
           Rs.update
           Rs.Close

           Set Rs = Nothing
           conn.Close
           Set conn = Nothing

           Response.redirect "index.asp?userid="&userid
           Response.End
       End If

   End Sub
   %>
   </body>
   </html>


Click here to preview the ASP Code Formatting Demo 1.

With FormatCode ASP Code Formatters, you can format and transform any foreign ASP source code to meet your preferred coding style or any common code convention in several seconds!