23-2 ?數定義檔?使用

ڭ̥iHN`Ϊ禡Ab@Ө禡wqɤAMAqL{A[JɮסANiHϥΦ禡wqɤҩwq禡CWSH ҥΪ禡ɮסAiH㦳ɦWAڭ̳q`N禡ɮתɦW]w fun]oOڭӤHߺDAA]iHΤPɦW^AHϧOC

ҦpAڭ̥iHNp1n`M禡Ab sumFunction.funApUG

lɡ]sumFunction.fun^G]ǦϰUYi^
// ƭp 1 [ n `M
function sum(n) {
	var i, total=0;
	for (i=1; i<=n; i++)
		total = total + i;
	return(total);
}

YnIsɮשҩwq禡Aq`ڭ̥ND{ɦWאּ wsfAèϥΤUz覡ӾɤJ禡wqɡG

<script src="sumFunction.fun"></script> ҦpG

lɡ]sum03.wsf^G]ǦϰUYi^
<job>
<script src="sumFunction.fun"></script>
<script>
// IsƥHp 1 [ n `M
n = 40;
WScript.Echo("1+2+...+" + n + " = " + sum(n));
</script>
</job>

Ʀܧڭ̥iHѤP{yҡAөIs JavaScript 禡ApUG

lɡ]sum04.wsf^G]ǦϰUYi^
<job>
<script src="sumFunction.fun"></script>

<script language=jscript>
// bP{yIsP@Ө
n = 40;
WScript.Echo("1+2+...+" + n + " = " + sum(n) + " (via Jscript)");
</script>

<script language=vbscript>
n = 40
WScript.Echo("1+2+...+" & n & " = " & sum(n) & " (via Vbscript)")
</script>

</job>

bWzdҤAڭ̨ϥ JScript M VBScript өIsP@ӡ] JScript Ӽg^ơAioP˪GAܦpUG

1+2+...+40 = 820 (via Jscript) 1+2+...+40 = 820 (via VBScript) ƹWAڭ̥iHϥΦPˤ@ӨƩwqɩȤݪ JavaScript]Ω^BAݪ JScript]Ω ASP^B JScript]Ω WSH^AFu@TYv̰ҬɡAuObɤJƩwqɮɡAҥΪykɬۦPC]ڭ̭nɤJƩwq file.funAhbWzTҤUҥΪɤJOCXpUG
JScript {]pPΡGΩ WSH