⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 yabasic.htm

📁 一个小巧的BASIC解释器的源代码很小可它的确做到了
💻 HTM
📖 第 1 页 / 共 5 页
字号:
<html><head><meta http-equiv="Content-Type"content="text/html; charset=iso-8859-1"><meta name="GENERATOR" content="Microsoft FrontPage Express 2.0"><title>Description of yabasic</title></head><body bgcolor="#FFFFFF"><h1><font color="#400040">Yabasic, </font><font color="#400040"size="4">yet another basic</font><font size="4"> for Unix andWindows</font></h1><h2>Current Version: 2.45</h2><p>This document describes the syntax and features of yabasic.</p><p>In short, yabasic implements the most common (and simple)elements of the basic-language, plus some graphic facilities;anyone, who has ever written basic-programs should feel at home.</p><p>This page covers all the features of yabasic, you don't needany other text to learn it. In fact, there is no other text aboutyabasic, neither a unix-man-page nor a Windows-helpfile.</p><p>This text doesn't teach basic from scratch, it rather assumessome experience with the basic-programming-language.</p><hr><h2><a name="Table of contents">Table of contents</a></h2><ul>    <li><a href="#Unix">Yabasic under Unix</a><ul>            <li><a href="#Starting, Unix">Usage</a></li>            <li><a href="#Options, Unix">Options</a></li>            <li><a href="#Setting defaults, Unix">Setting                Defaults</a></li>        </ul>    </li>    <li><a href="#Windows 95">Yabasic under Windows</a><ul>            <li><a href="#Usage, Windows">Usage</a></li>            <li><a href="#Options, Windows">Options</a></li>            <li><a href="#Setting defaults, Windows">Setting                Defaults</a></li>        </ul>    </li>    <li><a href="#Yabasic described by examples">Yabasic        explained by examples</a><ul>            <li><a href="#A simple Program">A simple Program with                <font face="Courier New"><strong>input</strong></font>                and <font face="Courier New"><strong>print</strong></font></a></li>            <li><a href="#Arithmetic">Arithmetic</a>: <a                href="#Operators">Operators</a> and <a                href="#Functions">Functions</a></li>            <li><a href="#Making decisions">Making decisions: The                if-statement</a></li>            <li><a href="#Strings and loops">Strings and loops</a></li>            <li><a href="#Graphics and printing">Graphics and                printing</a></li>            <li><a href="#Plotting">Plotting</a></li>            <li><a href="#Data and Arrays">Data and Arrays</a></li>            <li><a href="#Files and more on input">Files and more                on input</a></li>            <li><a href="#Calling the Operating System">Interaction                with the Operating System</a></li>            <li><a href="#Peek and Poke">Peek and Poke</a></li>            <li><a href="#More on print">Pretty Printing: <font                face="Courier New"><strong>print</strong></font><font                size="3" face="Courier New"><strong> at()</strong></font></a>                and<font size="3" face="Courier New"><strong> </strong></font><a                href="#print using"><font size="3"                face="Courier New"><strong>print using</strong></font></a></li>            <li><a href="#Loose Ends">Loose Ends</a></li>        </ul>    </li>    <li><a href="#Index">Index</a><ul>            <li><a href="#Index of keywords">Index of Keywords</a></li>            <li><a href="#Index of concepts">Index of Concepts</a></li>        </ul>    </li>    <li><a href="#internals">Yabasic background</a></li>    <li><a href="#copy">Copyleft </a></li></ul><hr><h1><a name="Unix">Unix</a></h1><h2><a name="Starting, Unix">Starting</a></h2><p>There are three way to start yabasic:</p><table border="0">    <tr>        <td valign="top"><strong>1.</strong></td>        <td valign="top">You may write your basic-program to a        file (e.g. foo.yab) and call yabasic with this file as an        argument:<blockquote>            <blockquote>                <p><code><strong>yabasic</strong></code><font                face="Courier"><code><strong> </strong></code></font><font                face="Courier New"><code><strong>foo.yab</strong></code>                </font></p>            </blockquote>        </blockquote>        <p>this will make yabasic execute your program.</p>        </td>    </tr>    <tr>        <td valign="top"><strong>2.</strong></td>        <td valign="top">You may start you yabasic without any        filename. Typing just<blockquote>            <blockquote>                <p><code><strong>yabasic</strong></code></p>            </blockquote>        </blockquote>        <p>makes yabasic start and prompt for commands to        execute; after you have typed in your program, press <code><strong>RETURN</strong></code>        twice and yabasic will execute your commands. This        behavior allows yabasic to be used as some sort of fancy        desktop calculator.</p>        </td>    </tr>    <tr>        <td valign="top"><strong>3.</strong></td>        <td valign="top">You may put your program into a file and        insert the following text as the <strong>very first line</strong>:<blockquote>            <blockquote>                <p><code><strong>#!/usr/bin/yabasic</strong></code></p>            </blockquote>        </blockquote>        <p>This is only an example and you should substitute for <code><strong>/usr/bin/yabasic</strong></code>        the full pathname of yabasic on your computer. Yabasic        will treat the line starting with <code><strong>#!</strong></code>        as a comment, but Unix will invoke yabasic to execute        this program.</p>        </td>    </tr></table><p><a href="#Table of contents">Back to table of contents ...</a></p><hr><h2><a name="Options, Unix">Options</a></h2><dl>    <dt><code><strong>-h</strong></code></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>-fg</strong></code><strong> </strong><font        face="Times New Roman"><em><strong><var>foreground-color</var></strong></em></font></dt>    <dd>Sets the foreground color for graphics. The usual X        colornames like <em>red, green</em> are accepted.</dd>    <dt><code><strong>-bg</strong></code><strong> </strong><font        face="Times New Roman"><em><strong><var>background-color</var></strong></em></font><strong>        </strong></dt>    <dd>Sets the background color. </dd>    <dt><code><strong>-geometry</strong></code><strong> </strong><font        face="Times New Roman"><em><strong><var>geometry-string</var></strong></em></font><strong>        </strong></dt>    <dd>The usual X geometry-string will work (e.g. <code>+10+10</code>),        but any window size will be ignored.</dd>    <dt><code><strong>-display</strong></code><strong> </strong><font        face="Times New Roman"><em><strong><var>Name-of-Display</var></strong></em></font><strong>        </strong></dt>    <dd>Name of the Display, where the window should appear. </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. </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 infolevel 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>    <dt>&nbsp;</dt>    <dt><a href="#Table of contents">Back to table of contents        ...</a></dt></dl><hr><h2><a name="Setting defaults, Unix">Setting defaults</a></h2><p>The colors, text-font and the window position should be set onthe <a href="#options">command-line </a>, or specified in theusers resource file (this is usually the file<fontface="Courier New"><strong> .Xresources</strong></font> in yourhome-directory); e.g.: </p><blockquote>    <pre>  <strong>yabasic*foreground: blue  yabasic*background: gold  yabasic*geometry: +10+10	  yabasic*font: 9x15</strong></pre></blockquote><p><font size="3">This sets the foreground of the graphics-windowto blue, the background to gold, the window will appear atposition 10,10 and the text-font will be 9x15.</font></p><p><a href="#Table of contents">Back to table of contents ...</a></p><hr><h1><a name="Windows 95">Windows</a></h1><h2><a name="Usage, Windows">Usage</a></h2><p>After you have run the setup program, yabasic can be invokedin three ways: </p><table border="0">    <tr>        <td valign="top"><strong>1.</strong></td>        <td>Choose &quot;yabasic&quot; from the start-menu:        Yabasic will come up with a console window and wait for a        program to be typed in right away. </td>    </tr>    <tr>        <td valign="top"><strong>2.</strong></td>        <td>Click with the right mousebutton on your desktop.        Choose &quot;new&quot; from the context-menu that        appears; this will create a new icon on your desktop. The        context-menu of this icon has the two entries        &quot;execute&quot; and &quot;edit&quot;; a double-click        executes the program.</td>    </tr>    <tr>        <td valign="top"><strong>3.</strong></td>        <td>Create a file containing your yabasic-program. This

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -