📄 yabasic.htm
字号:
file should have the extension ".yab". Double-click on this file then invokes yabasic, to execute your program. </td> </tr></table><p><a href="#Table of contents">Back to table of contents ...</a></p><hr><h2><a name="Options, Windows">Options</a></h2><dl> <dt><code><strong>-h</strong></code><strong> </strong></dt> <dd>Prints out a short help message; <code><strong>-help</strong></code> or <code><strong>-?</strong></code> are accepted as well. </dd> <dt><code><strong>-geometry</strong></code><strong> </strong><font face="Times New Roman"><em><strong><var>geometry-string</var></strong></em></font> </dt> <dd>E.g. <code><strong>+20+10</strong></code> will place the graphic-window 10 pixels below and 20 pixels left of the upper left corner of the screen.</dd> <dt><code><strong>-font</strong></code><strong> </strong><font face="Times New Roman"><em><strong><var>Name-of-font</var></strong></em></font></dt> <dd>Name of the font which will be used for graphics text. Can be any of: <br> <code><strong>decorative, dontcare, modern, roman, script, swiss</strong></code> <br> You can append (without space) a fontsize to any of these identifiers, i.e. <font face="Courier New"><strong>swiss30</strong></font> chooses a swiss font, 30 pixels high.</dd> <dt><code><strong>-i</strong></code></dt> <dd>Sets the initial <a name="infolevel">infolevel</a>. This controls the amount of information one gets about the progress of program execution, Every level contains all lower levels (e.g. <code><strong>w</strong></code> contains <code><strong>f</strong></code> and <code><strong>e</strong></code>) and can be one of: <dl> <dt><code><strong>d</strong></code><strong> </strong></dt> <dd>Set the inoflevel to <em><strong>diagnostic</strong></em><em> </em>: This gives detailed debugging information; much more output than you'd probably like to read. </dd> <dt><code><strong>n</strong></code></dt> <dd><em><strong>note</strong></em><em> </em>: Useful information; e.g. about execution time and memory consumption. </dd> <dt><code><strong>w</strong></code> </dt> <dd><em><strong>warning</strong></em><em> </em>: Gives you warnings, that something has gone wrong (e.g. division by zero); nevertheless execution proceeds. </dd> <dt><code><strong>e</strong></code> </dt> <dd><em><strong>error</strong></em><em> </em>: A serious error (e.g. an array boundary violation) has occurred, stopping the program. </dd> <dt><code><strong>f</strong></code> </dt> <dd><em><strong>fatal</strong></em><em> </em>: Something has gone wrong and cannot be fixed; the interpreter exits immediately. This happens most often in the course of an arithmetic fault (floating point exception) but can also be a sign of an internal error within yabasic. </dd> </dl> <p>The default infolevel is <code><strong>w</strong></code>. </p> </dd> <dt><font face="Courier New"><strong>-licence</strong></font></dt> <dd>This makes yabasic print out its copyleft; have a look and you will see, that almost anything is allowed.</dd></dl><p><a href="#Table of contents">Back to table of contents ...</a></p><hr><h2><a name="Setting defaults, Windows">Setting defaults</a></h2><p>To choose the default-values for graphic-font, fontsize andwindow position, you have to edit the registry.</p><p>Yabasic stores its defaults under:</p><blockquote> <p><font face="Courier New"><strong>HKEY_LOCAL_MACHINE/SOFTWARE/Yabasic</strong></font></p></blockquote><p>You may edit the subkeys "font" and"geometry"; these subkeys accept the same values as thecorresponding <a href="#Options, Windows">command line options</a><font face="Courier New"><strong>-font</strong></font> and <fontface="Courier New"><strong>-geometry</strong></font>. Commandline options take precedence over registry defaults.</p><p><a href="#Table of contents">Back to table of contents ...</a></p><hr><h1><a name="Yabasic described by examples">Yabasic explained byexamples</a></h1><h2><a name="A simple Program">A simple Program</a></h2><p>This is the first example:</p><blockquote> <pre><strong>REM this is the first yabasic-programinput "Enter two numbers:" a,bprint a,"+",b,"=",a+bprint "Please enter your Name:";INPUT a$print "Hello ",a$," !"</strong></pre></blockquote><p>This program produces the following output (user input isdisplayed like <font face="Courier New"><em><strong><u>this</u></strong></em></font>):</p><blockquote> <pre><strong>Enter two numbers: </strong><fontcolor="#000000"><em><strong><u>2 3</u></strong></em></font><strong>2+3=5Please enter your Name: </strong><em><strong><u>Bill</u></strong></em><strong>Hello Bill !</strong></pre></blockquote><p>This simple program contains three different commands:</p><dl> <dt><a name="REM"><font face="Courier New"><strong>REM</strong></font></a></dt> <dd>The <font face="Courier New"><strong>REM</strong></font>-statement introduces comments; everything after <font face="Courier New"><strong>REM</strong></font> up to the end of the line is ignored.</dd> <dt><a name="input"><font face="Courier New"><strong>input</strong></font></a></dt> <dd>This statement reads one or more variables from the user. The optional prompt-string after the <font face="Courier New"><strong>input</strong></font>-statement (<font face="Courier New">"<strong>Enter a number:</strong>"</font>) is printed on the terminal prior to reading any input. Note that there is no semicolon after this prompt-string. To learn more about, how input chops a line into pieces you may refer to the section <a href="#More on input">More on Input</a>. To learn, how to read input from the keyboard without delay, check out <a href="#Getting a key from the keyboard">Getting a key from the keyboard</a>.</dd> <dt><a name="print"><font face="Courier New"><strong>print</strong></font></a></dt> <dd>The print-statement writes all its arguments to the screen; after writing its last argument, <font face="Courier New"><strong>print</strong></font> goes to the next line (as in<font face="Courier New"> <strong>print "Hello ",a$," !"</strong></font>); to avoid this automatic newline, place a colon after the last argument (as in<font face="Courier New"> <strong>print "Please enter your Name:";</strong></font>). Note that print can be abbreviated with a single question mark (?). If you want to print (or input) at a specific location, you may go to the section <a href="#Printing at a Random Position">Prining on your Screen</a>.</dd></dl><p>Furthermore some general properties of yabasic should benoted:</p><dl> <dt><a name="Case"><strong>Case</strong></a></dt> <dd>Commands can be entered in any case: <font face="Courier New"><strong>input</strong></font> is the same as <font face="Courier New"><strong>INPUT</strong></font> and even as <font face="Courier New"><strong>InPUt</strong></font><strong>. This applies to every command in yabasic but not to variables, i.e. </strong><font face="Courier New"><strong>a$</strong></font><strong> and </strong><font face="Courier New"><strong>A$</strong></font><strong> are different variables.</strong></dd> <dt><a name="Variables"><strong>Variables</strong></a></dt> <dd>Variable names are case sensitive (i.e. types of variables: <font face="Courier New"><strong>a$</strong></font> and <font face="Courier New"><strong>A$</strong></font> are different) and can be of any length. There are two sorts of variables:</dd> <dt> </dt> <dd><dl> <dt>String variables</dt> <dd>e.g.<font face="Courier New"> <strong>a$</strong></font>, <font face="Courier New"><strong>b12$</strong></font> or <font face="Courier New"><strong>VeryLongName$</strong> </font>may contain strings of any length. String variables always have a Dollar-sign (<font face="Courier New"><strong>$</strong></font>) as the last character of their names.</dd> <dt>Numerical variables</dt> <dd>e.g. <font face="Courier New"><strong>a</strong></font>, <font face="Courier New"><strong>c3po</strong></font> or <font face="Courier New"><strong>ThisIsAnEvenLongerName</strong></font> contain real numbers like 2, -1.3, 15.3e44 or 0.</dd> </dl> <p>Variables (with the exception of arrays) need not be declared, their initial values are "" (for string variables) and 0.0 (for numerical variables).</p> </dd></dl><p><a href="#Table of contents">Back to table of contents ...</a></p><hr><h2><a name="Arithmetic">Arithmetic</a></h2><h3><a name="Operators">Operators</a></h3><p>Yabasic has five arithmetic operators: <fontface="Courier New"><strong>+</strong></font> (addition), <fontface="Courier New"><strong>-</strong></font> (subtraction), <fontface="Courier New"><strong>*</strong></font> (multiplication), <fontface="Courier New"><strong>/</strong></font><strong> </strong>(division)and <font face="Courier New"><strong>^</strong></font> (power);they all behave as expected, i.e. this line of code</p><blockquote> <pre><strong>print 1+2,2*3,4/2,2^3</strong></pre></blockquote><p>produces this line of output:</p><blockquote> <pre><strong>3 6 2 8</strong></pre></blockquote><p>Note that the power operator (<font face="Courier New"><strong>^</strong></font>)handles fractional powers: <font face="Courier New"><strong>8^(1/3)</strong></font>gives <font face="Courier New"><strong>2</strong></font> as aresult.</p><h3><a name="Functions">Functions</a></h3><p>This section demonstrates and explains the arithmeticfunctions of yabasic.</p><dl> <dt><a name="Trigonometric functions:"><strong>Trigonometric functions:</strong></a></dt> <dd>There are 6 trigonometric functions:<dl> <dd><pre><strong>print sin(1.0),cos(pi),tan(3)print asin(0.5),acos(0.7)print atan(2),atan(1,2)</strong></pre> </dd> </dl> </dd> <dd>These lines produce this output:<dl> <dd><pre><strong>0.841471 -1 -0.1425470.523599 0.7953991.10715 0.463648</strong></pre> </dd> </dl> </dd> <dd>As you can see yabasic can calculate sine, cosine, tangent and their inverses. And, if you have an eye for trigonometry, you may have noticed that all these functions expect their argument in radians; to facilitate the transformation from degrees to radians (<font face="Courier New"><strong>radian=degree*pi/180</strong></font>), there is a predefined variable named <font face="Courier New"><strong>pi</strong></font> (or <font face="Courier New"><strong>PI</strong></font>) which has an initial value of 3.14159.</dd></dl>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -