📄 comlan23.htm
字号:
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<meta name="GENERATOR" content="Quadralay WebWorks Publisher Professional Edition 6.0.5">
<meta name="TEMPLATEBASE" content="book_html">
<meta name="LASTUPDATED" content="12/04/03 16:07:37">
<title>20.9.2 Arguments and returned values </title>
<STYLE TYPE="text/css">
<!--
span.Signal { text-transform: uppercase; font-family: Verdana }
-->
</STYLE>
</head>
<body link="#3366CC" vlink="#9999CC" text="#000000" alink="#0000CC" bgcolor="#FFFFFF"
background="images/backgrnd.gif">
<p><img src="images/stlogo.gif" width="106" height="83" align="left"
alt="logo here!"> </p>
<table width="331" border="0" align="right" cellpadding="0" cellspacing="0">
<tr>
<td><a href="a_refman.htm"><img src="images/navtoc.gif" width="84" height="23"
border="0" alt="TOC"> </a></td>
<td><a href="comlan22.htm"><img src="images/navprev.gif" width="80" height="23"
border="0" alt="PREV"> </a></td>
<td><a href="comlan24.htm"><img src="images/navnext.gif" width="83" height="23"
border="0" alt="NEXT"> </a></td>
<td><a href="a_refmaa.htm"><img src="images/navidx.gif" width="84" height="23"
border="0" alt="INDEX"> </a></td>
</tr>
</table>
<p><br clear="all">
</p>
<hr align="left">
<blockquote>
<h3>
<a name="1204952"> </a><font color="#003366" face="Verdana, Arial, Helvetica, sans-serif">20.9.2 Arguments and returned values</font>
</h3>
<p>
<a name="1204954"> </a><font size=2 face="Verdana, Arial, Helvetica, sans-serif">Arguments can be passed to a procedure, and are referenced using <font size=2 face=Courier><strong>$1</strong></font>, <font size=2 face=Courier><strong>$2</strong></font> and so on. If arguments are passed, they are always passed by value, that is a unique copy is made for the procedure to use, that exists only in the scope of the procedure.</font>
</p>
<p>
<a name="1204955"> </a><font size=2 face="Verdana, Arial, Helvetica, sans-serif">The number of arguments given to the procedure is available in the pseudo-variable <font size=2 face=Courier><strong>$#</strong></font>. The list of arguments can be referenced using the pseudo-variable <font size=2 face=Courier><strong>$*</strong></font>. An argument may be specified using the value of a variable; for example if the variable <font size=2 face=Courier><strong>i</strong></font> had the value 4, the expression <font size=2 face=Courier><strong>$(i)</strong></font> would be equivalent to <font size=2 face=Courier><strong>$4</strong></font>.</font>
</p>
<p>
<a name="1204956"> </a><font size=2 face="Verdana, Arial, Helvetica, sans-serif">When an argument is used in an operation that requires an integer (for example, <font size=2 face=Courier><strong>x=$4</strong></font>) the argument is considered to be an integer expression and is evaluated when it is referenced. It is an error to use an argument in an integer operation when the value of the argument is not an integer expression.</font>
</p>
<p>
<a name="1204957"> </a><font size=2 face="Verdana, Arial, Helvetica, sans-serif">The type of an argument is evaluated when it is referenced. Run-time errors will occur if an argument turns out to be invalid in its context. For example, if a procedure is executed that contains the line:</font>
</p>
<a name="1204958"> </a><font size=2 face=Courier><strong>x = $4 + 20<br></strong></font>
<p>
<a name="1204959"> </a><font size=2 face="Verdana, Arial, Helvetica, sans-serif">and <font size=2 face=Courier><strong>$4</strong></font> evaluates to a string, the message:</font>
</p>
<a name="1204960"> </a><font size=2 face=Courier><strong>error-illegal operation on type(s): (string) + (int)<br></strong></font>
<p>
<a name="1204961"> </a><font size=2 face="Verdana, Arial, Helvetica, sans-serif">will be displayed, and execution of the procedure will stop.</font>
</p>
<p>
<a name="1204962"> </a><font size=2 face="Verdana, Arial, Helvetica, sans-serif">Any kind of value can be returned from a procedure by assigning to the pseudo-variable <font size=2 face=Courier><strong>$$</strong></font>.</font>
</p>
</blockquote>
<hr>
<table width="331" border="0" align="left" cellpadding="0" cellspacing="0">
<tr>
<td><a href="a_refman.htm"><img src="images/navtoc.gif" width="84" height="23"
border="0" alt="TOC"> </a></td>
<td><a href="comlan22.htm"><img src="images/navprev.gif" width="80" height="23"
border="0" alt="PREV"> </a></td>
<td><a href="comlan24.htm"><img src="images/navnext.gif" width="83" height="23"
border="0" alt="NEXT"> </a></td>
<td><a href="a_refmaa.htm"><img src="images/navidx.gif" width="84" height="23"
border="0" alt="INDEX"> </a></td>
</tr>
</table>
<font size=1 face="Verdana, Arial, Helvetica, sans-serif"> © 2001, 2002, 2003 STMicroelectronics. All Rights Reserved.<br>
ADCS 7250966F</font>
</body>
</html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -