20-5 ?用範?三?MATLAB 程?碼??

bڭ̹ǶisL{ACӤH|}o MATLAB {A÷J㦨@ӭӤuc]Toolbox^AHKLHϥΡCOboiL{A{X``ݭnקAFK޲zAڭ̧]b{XAp@ؤFMaݨoǻAO@ܭnu@C

]گSOdzƤF@ӭӤH}ouc web AYɦaX MATLAB {ɮפnAæCXCMAnϥγoӥ\AҦ{]p̦bg MATLAB {ɡArŦX@dzWdAodzWdiUCdҺb̩G

Example]fileAccess/utility/index.asp^G

bWzAڭ̨ϥ JScript ӤήɩXӨC@ MATLAB 禡A÷JbWCPɧڭ̤]ھڨC@ɮ׮榡PAӤ禡ɮס]Function Files^MZɮס]Script Files^A}ܡCdҪlXpUG

lɡ]fileAccess/utility/index.asp^G]ǦϰUYi^
<%@language=JScript%>
<% title="Utility Toolbox: MATLAB {" %>
<%
function getMFileUsage(fileName){
	fso = new ActiveXObject("Scripting.FileSystemObject");
	fid=fso.OpenTextFile(fileName, 1);
	contents=fid.ReadAll();
	fid.Close();
	lines=contents.split("\n");
	output=new Object();

	// ====== Check if a function
	pattern=/^\s*function\s/i;
	line=lines[0];
	output.isFunction=false;
	if (line.match(pattern) != null)
		output.isFunction=true;

	// ====== Get H1 help
	pattern=/^%\s*(.*)/i;
	output.h1="";
	for (i=0; i<lines.length; i++)
		if (lines[i].match(pattern) != null){
			output.h1=RegExp.$1;
			break;
		}
	
	// ====== Usage line
	pattern=/^%\s*Usage:\s*(.*)/i;
	output.usage="";
	startLine=-1;
	for (i=0; i<lines.length; i++)
		if (lines[i].match(pattern) != null){
			output.usage=RegExp.$1;
			startLine=i;
			break;
		}

	// ====== Argument documentation
	pattern=/^%\s*(.*)/i;
	output.argumentDoc="";
	if (startLine>=0)
		for (i=startLine+1; i<lines.length; i++)
			if ((lines[i].match(pattern) != null) && (RegExp.$1 != ""))
				output.argumentDoc = output.argumentDoc + "\\n" + RegExp.$1;
			else
				break;

	// ====== Return the final output
	return(output);
}
%>

<html>
<head>
	<title><%=title%></title>
	<meta HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=big5">
	<meta HTTP-EQUIV="Expires" CONTENT="0">
	<style>
		td {font-family: "з", "helvetica,arial", "Tahoma"}
		A:link {text-decoration: none}
		A:hover {text-decoration: underline}
	</style>
</head>

<body background="/jang/graphics/background/yellow.gif">
<font face="з">
<h2 align=center><%=title%></h2>
<h3 align=center><a target=_blank href="/jang">iP</a></h3>
<hr>

<h3><img src="/jang/graphics/dots/redball.gif">²n</h3>
<blockquote>uc MATLAB `ΪΨơA]wja^mC</blockquote>

<%
fso = new ActiveXObject("Scripting.FileSystemObject");
fullPath = Server.MapPath(".");

webPath=Request.ServerVariables("PATH_INFO");
realPath=Request.ServerVariables("PATH_TRANSLATED");
rarWebPath=fso.GetParentFolderName(webPath)+".rar";
rarRealPath=fso.GetParentFolderName(realPath)+".rar";
rarFile=fso.GetFileName(fso.GetParentFolderName(realPath))+".rar";
if (fso.FileExists(rarRealPath)){
%>
<h3><img src="/jang/graphics/dots/redball.gif">ӥؿYɡG<a href="<%=rarWebPath%>"><%=rarFile%></a></h3>
<%}%>

<h3><img src="/jang/graphics/dots/redball.gif">ݭn@Ϊuc</h3>
<blockquote>LC</blockquote>

<!== CX -->
<h3><img src="/jang/graphics/dots/redball.gif">ƦC</h3>
<table border=1 align=center>
<tr>
<th>ɮצW<th>C<th>ƥΪk<th>ɮפjp
<%
fd = fso.GetFolder(fullPath);
fc = new Enumerator(fd.Files);
for (; !fc.atEnd(); fc.moveNext()){
	fileName=fc.item()+"";
	ext=fso.GetExtensionName(fileName);
	if ((ext=="m") || (ext=="M")){
		f = fso.GetFile(fileName);
		out=getMFileUsage(fileName);
		if (out.isFunction){
			Response.write("\n<tr>\n");
			Response.write("<td><a target=_blank href=\"" + f.Name + "\">" + f.Name + "</a></td>");
			Response.write("<td>" + out.h1 + "&nbsp;</td>");
			doc=out.argumentDoc;
			doc=doc.replace(/"/g, "\\\"");		// Nr즳 " N \"
			doc=doc.replace(/'/g, "\\\'");		// Nr즳 ' N \'
			if (doc!="")
				Response.write("<td><a href='javascript:alert(\"" + doc + "\")'>" + out.usage + "</a>&nbsp;</td>");
			else
				Response.write("<td>" + out.usage + "</td>");
			Response.write("<td align=right>" + f.Size + "</td>");
		}
	}
}
%>
</table>

<!== CXZ -->
<h3><img src="/jang/graphics/dots/redball.gif">ZC</h3>
<table border=1 align=center>
<tr>
<th>ɮצW<th>C<th>ɮפjp
<%
fd = fso.GetFolder(fullPath);
fc = new Enumerator(fd.Files);
for (; !fc.atEnd(); fc.moveNext()){
	fileName=fc.item()+"";
	items=fileName.split(".");
	ext=items[items.length-1];
	if ((ext=="m") || (ext=="M")){
		f = fso.GetFile(fileName);
		out=getMFileUsage(fileName);
		if (!out.isFunction){
			Response.write("\n<tr>\n");
			Response.write("<td><a href=\"" + f.Name + "\">" + f.Name + "</a></td>");
			Response.write("<td>" + out.h1 + "&nbsp;</td>");
			Response.write("<td align=right>" + f.Size + "</td>");
		}
	}
}
%>
</table>

<!== CXLɮ -->
<h3><img src="/jang/graphics/dots/redball.gif">Lɮ</h3>
<table border=1 align=center>
<tr>
<th>ɮצW<th>ɮפjp
<%
fd = fso.GetFolder(fullPath);
fc = new Enumerator(fd.Files);
for (; !fc.atEnd(); fc.moveNext()){
	fileName=fc.item()+"";
	items=fileName.split(".");
	ext=items[items.length-1];
	if ((ext!="m") && (ext!="M")){
		f = fso.GetFile(fileName);
		Response.write("\n<tr>\n");
		Response.write("<td><a href=\"" + f.Name + "\">" + f.Name + "</a></td>");
		Response.write("<td align=right>" + f.Size + "</td>");
	}
}
%>
</table>

<h3><img src="/jang/graphics/dots/redball.gif">LGpظmAucOHϥ</h3>
<ul>
<li>бNؿ index.asp mA toolbox ؿAPɦb IIS uؿw]v[J index.aspAɷOHgssA toolbox ؿA index.asp Y|۰ʧXU MATLAB {XAåߨܦbWC
<li>F index.asp TaXAA MATLAB {XŦXUCWdG
	<ul>
	<li>YOơAĤ@CĤ@ӭ^rOufunctionvC
	<li>LרƩάOZAĤ@Cѷ|QXӡAmuCv줺C
	<li>Ĥ@CauUsage: vѦCA|QXӡAmuƥΪkvC
	<li>uUsage: v᪺sѦCA|QJMX޼ƪAAIUhƥΪkɡA|Hĵi覡XӡC
	</ul>
<li>ϨƫKLHƨϥΡAЦbgƮɡA`NUCƶG
	<ul>
	<li>CӨƥЦ@̤jWMקAHܭtdC
	<li>ҦA]iHϥΤAȥHMĤ@ؼСC
	<li>O@Ǫz]vAҦ mex  dll ɮתl C {XAФnJؿC
	</ul>
<li>pG toolbox |O /jang/toolbox/utility ɡAindex.asp |۰ʥh /jang/toolbox/utility.asp ñN toolbox YɡC]]pGAs toolboxAOons@ .rar ɮסAébP@hؿC^
<li>̫AOonR{bAҬݨ쪺rAíק糧DrB@̤jWBuc²nBݭn@ΪucC
</ul>

<hr>

<script language="JavaScript">
document.write("Last updated on " + document.lastModified + ".")
</script>

<a href="/jang/sandbox/asp/lib/editfile.asp?FileName=<%=Request.ServerVariables("PATH_INFO")%>"><img align=right border=0 src="/jang/graphics/invisible.gif"></a>
</font>
</body>
</html>


JScript {]pPΡGΩAݪ ASP