13-1 ?芥暩

璝璶ミ莱ノ祘Α祘Α絏碞璶家舱てModularized獽矗蔼ㄤ狡ㄏノReusability级糶 ASP 祘Α絏и碞莱赣猔種祘Α絏狡┦砞猭盢狡瞷场だ糶Θㄧ计┪嘿ㄧΑ獽狡ㄏノ

 JScript ㄒ瓃祘Α絏琌衡パ 1  n 羆㎝

<%
function sum(n) {
	var i, total;
	total = 0;
	for (i=1; i<=n; i++)
		total = total + i
	return(total);
}
%>
絛ㄒいи碞琌瓃ㄧ计ㄓ璸衡パ 1  20 羆㎝

Examplesum01.asp

瓃絛ㄒ﹍郎

﹍郎sum01.aspη︹跋办ㄢī
<%@language=jscript%>
<%title="ㄏノ JScript ㄧ计絛ㄒ"%>
<!--#include file="head.inc"-->
<hr>

<%
function sum(n) {
	var i, total=0;
	for (i=1; i<=n; i++)
		total = total + i;
	return(total);
}

n = 20;
Response.write("1+2+...+" + n + " = " + sum(n) + "\n");
Response.write("(Computed by server-side JScript)");
%>

<hr>
<!--#include file="foot.inc"-->

ㄧ计璝ノ VBScript ㄓ级糶祘Α絏

<%
function sum(n)
	dim i, total
	total = 0
	for i = 1 to n
		total = total + i
	next
	sum = total
end function
%>
 VBScript ㄧ计㊣よΑǎ絛ㄒ

Examplesum01_vbs.asp

瓃絛ㄒ﹍郎

﹍郎sum01_vbs.aspη︹跋办ㄢī
<%title="ㄏノ VBScript ㄧ计絛ㄒ"%>
<!--#include file="head.inc"-->
<hr>

<%
function sum(n)
	dim i, total
	total = 0
	for i = 1 to n
		total = total + i
	next
	sum = total
end function

n = 20
response.write("1+2+...+" & n & " = " & sum(n) & chr(13) & chr(10))
response.write("(Computed by server-side VBScript)")
%>

<hr>
<!!--#include file="foot.inc"-->

ㄏノㄧ计JScript ㎝ VBScript Τㄇぃぇ矪俱瞶


JScript 祘Α砞璸籔莱ノノ狝竟狠 ASP 吏挂