📄 4.htm
字号:
</font>
</div>
<p><font face="arial" color="#000000" size="2" style="line-height: 25px">
如果指令档行是ASP的输出指令(包括等号和变数),请不要在等号和定界符号间使用空格。</font></p>
<p><font face="arial" color="#000000" size="2" style="line-height: 25px">例如:</font></p>
<div style="line-height: 25px; background-color: #d7d7d7">
<font face="Arial" size="3" style="line-height: 25px">
<pre style="line-height: 25px"><%= str SubscrLName %></pre>
</font>
</div>
<p><font face="arial" color="#3e76d7" size="2" style="line-height: 25px">
<b style="line-height: 25px">缩排<br style="line-height: 25px">
</b></font></p>
<p><font face="arial" color="#000000" size="2" style="line-height: 25px">
缩排能使程式码间的逻辑关系变得更加清楚。</font></p>
<p><font face="arial" color="#000000" size="2" style="line-height: 25px">
如果指令档区段不只一行,并且它处於指令档定界符号之後,请统一地将它们内缩两个空格。如果是只有一行的指令档,那就和指令档定界符号放在同一行。</font></p>
<p><font face="arial" color="#000000" size="2" style="line-height: 25px">
除了程序(函式和子程式)以外,请将ASP 定界符号(<% ... %>)间的所有程式码都缩进至少两个空格。</font></p>
<p><font face="arial" color="#000000" size="2" style="line-height: 25px">
以下也需要缩进两个空格:</font></p>
<font face="arial" color="#000000" size="2" style="line-height: 25px">
<ul style="line-height: 25px">
<li style="line-height: 25px">逻辑语法的中断点<br style="line-height: 25px">
</li>
<li style="line-height: 25px">巢式回圈语法和HTML元素<br style="line-height: 25px">
</li>
<li style="line-height: 25px">函式主体<br style="line-height: 25px">
</li>
<li style="line-height: 25px">回圈语法开始的地方<br style="line-height: 25px">
</li>
</ul>
</font>
<p><font face="arial" color="#000000" size="2" style="line-height: 25px">
以下的例子显示一些VBScript 或 Jscript中的缩排规则:</font></p>
<p><font face="arial" color="#3e78d7" size="2" style="line-height: 25px">
<b style="line-height: 25px">单行指令档<br style="line-height: 25px">
</b></font></p>
<div style="line-height: 25px; background-color: #d7d7d7">
<font face="Arial" size="3" style="line-height: 25px">
<pre style="line-height: 25px"><% Dim strLastName %></pre>
</font>
</div>
<p><font face="arial" color="#3e78d7" size="2" style="line-height: 25px">
<b style="line-height: 25px">逻辑语法<br style="line-height: 25px">
</b></font></p>
<div style="line-height: 25px; background-color: #d7d7d7">
<font face="Arial" size="3" style="line-height: 25px">
<pre style="line-height: 25px"><%
' This example demonstrates a script with
'a nested block of logic.
Dim vntOutput
Set vntExample = Server.CreateObject(" MyComponents.Component.1")
vnt Output = varExample.Text
If vntOutput = "" Then
Response.Write "An error has occurred"
Else
Response.Write vntOutput
End If
%></pre>
</font>
</div>
<p><font face="arial" color="#3e78d7" size="2" style="line-height: 25px">
<b style="line-height: 25px">VBScipt中的函式<br style="line-height: 25px">
</b></font></p>
<div style="line-height: 25px; background-color: #d7d7d7">
<font face="Arial" size="3" style="line-height: 25px">
<pre style="line-height: 25px"><%
Function CalcMortgageRate()
Statement_1
End Function
%></pre>
</font>
</div>
<p><font face="arial" color="#3e78d7" size="2" style="line-height: 25px">
<b style="line-height: 25px">Jscript函式<br style="line-height: 25px">
</b></font></p>
<div style="line-height: 25px; background-color: #d7d7d7">
<font face="Arial" size="3" style="line-height: 25px">
<pre style="line-height: 25px"><%
// This is an example of a function.
function calc MortgageRate()
{
statement1
statement2
}
%></pre>
</font>
</div>
<p><font face="arial" color="#3e76d7" size="2" style="line-height: 25px">
<b style="line-height: 25px">预设语言<br style="line-height: 25px">
</b></font></p>
<p><font face="arial" color="#000000" size="2" style="line-height: 25px">使用 @<font face="arial" color="#3e80d7" size="2" style="line-height: 25px"><b style="line-height: 25px"> LANGUAGE </b></font>指令可以覆写伺服器的预设指令档语言(VBScript)。举个例子,为确保预设语言是JScript,请将下面的程式码放在每个ASP网页的上方。</font></p>
<div style="line-height: 25px; background-color: #d7d7d7">
<font face="Arial" size="3" style="line-height: 25px">
<pre style="line-height: 25px"><%@ LANGUAGE=JScript %></pre>
</font>
</div>
<p><font face="arial" color="#000000" size="2" style="line-height: 25px">
为了让伺服器端处理 <SCRIPT> 标签页,请使用RUNAT属性。</font></p>
<div style="line-height: 25px; background-color: #d7d7d7">
<font face="Arial" size="3" style="line-height: 25px">
<pre style="line-height: 25px">< SCRIPT LANGUAGE="Script Language" RUNAT=SERVER >.</pre>
</font>
</div>
<p><font face="arial" color="#000000" size="2" style="line-height: 25px">
请注意,不要在等号两边留下空格</font></p>
<p><font face="arial" color="#3e76d7" size="2" style="line-height: 25px">
<b style="line-height: 25px">指令档的编排顺序<br style="line-height: 25px">
</b></font></p>
<p><font face="arial" color="#000000" size="2" style="line-height: 25px">
建议依照网页由上而下的顺序来排列 .
asp档案中指令档的配置。经过组织、排列的指令档能产生易读的网页,某些情况下还可以执行地更好。除非有特别的说明,下列几点对VBScript和Jscript
均适用。</font></p>
<font face="arial" color="#000000" size="2" style="line-height: 25px">
<ul style="line-height: 25px">
<li style="line-height: 25px">指定语言<br style="line-height: 25px">
</li>
<li style="line-height: 25px">使用<font face="arial" color="#3e80d7" size="2" style="line-height: 25px"><b style="line-height: 25px"> Option
Explicit </b></font>语法(只针对VBScript)<br style="line-height: 25px">
</li>
<li style="line-height: 25px">列出函式库<br style="line-height: 25px">
</li>
<li style="line-height: 25px">宣告网页变数的范围。<br style="line-height: 25px">
</li>
<li style="line-height: 25px">给网页变数值。<br style="line-height: 25px">
</li>
<li style="line-height: 25px">编写HTML和内嵌指令档。<br style="line-height: 25px">
</li>
<li style="line-height: 25px">列出内嵌指令档中呼叫的函式。<br style="line-height: 25px">
</li>
</ul>
</font>
<p><font face="arial" color="#3e78d7" size="2" style="line-height: 25px">
<b style="line-height: 25px">编排顺序<br style="line-height: 25px">
</b></font></p>
<div style="line-height: 25px; background-color: #d7d7d7">
<font face="Arial" size="3" style="line-height: 25px">
<pre style="line-height: 25px"><%@ LANGUAGE=VBScript % >
<% Option Explicit % >
< HTML >
< HEAD >
< TITLE > Variable Sample </ TITLE >
</ HEAD >
< BODY BGCOLOR="White" topmargin="10" leftmargin="10" >
<!-- Display Header -- >
<FONT SIZE="4" FACE="Arial, Helvetica"> <B> Variable Sample </ B></ FONT>
< BR >
< HR >
< H3 > Integer Manipulation </ H3 >
<%
' Declare variable.
Dim intVariable
' Assign the variable an integer value.
int Variable = 5
%></pre>
</font>
</div>
<p><font face="arial" color="#000000" size="2" style="line-height: 25px">
对於VBScript,使用Option Explicit来强制显示宣告变数,这可以预防变数名称拼错而导致在指令档执行时所产生的错误。</font></p>
<p><font face="arial" color="#000000" size="2" style="line-height: 25px">
要宣告网页属於交易性质,请在网页的第一行加上<font face="arial" color="#3e80d7" size="2" style="line-height: 25px"><b style="line-height: 25px"> <%@
TRANSACTION=value % > </b></font>指令。</font></p>
<p><font face="arial" color="#3e78d7" size="2" style="line-height: 25px">
<b style="line-height: 25px">交易性质的网页<br style="line-height: 25px">
</b></font></p>
<div style="line-height: 25px; background-color: #d7d7d7">
<font face="Arial" size="3" style="line-height: 25px">
<pre style="line-height: 25px"><%@ TRANSACTION=Required LANGUAGE=VBScript % >
<% Option Explicit % >
< HTML >
< HEAD >
.
.
.</pre>
</font>
</div>
<p><font face="arial" color="#3e76d7" size="2" style="line-height: 25px">
<b style="line-height: 25px">物件与程序名称<br style="line-height: 25px">
</b></font></p>
<p><font face="arial" color="#000000" size="2" style="line-height: 25px">
为了在变数中区别物件名称和程序名称,您可以用动词作为物件名称或是程序名称的开头。在物件名称或程序名称中的每一单字都用大写字母开头。对於一些典型的动作,表4-1列出了建议使用来命名物件的规则。</font></p>
<center style="line-height: 25px">
<table border="0" style="line-height: 25px">
<tbody style="line-height: 25px">
<tr style="line-height: 25px">
<td align="middle" style="line-height: 25px">
<font face="arial" color="#000000" size="2" style="line-height: 25px">
表4-1 物件和程序的命名规则</font></td>
</tr>
</table>
</center><center style="line-height: 25px">
<table border="1" style="line-height: 25px">
<tbody style="line-height: 25px">
<tr style="line-height: 25px">
<th style="line-height: 25px"><font size="2" style="line-height: 25px">
名称</font> </th>
<th style="line-height: 25px"><font size="2" style="line-height: 25px">
功能</font> </th>
<th style="line-height: 25px"><font size="2" style="line-height: 25px">
范例</font></th>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -