Offset 1, 8 lines modified | Offset 1, 8 lines modified |
1 | <FILENAME·filename="index.html"><html><head><title>The·KTurtle·Handbook</title><link·rel="stylesheet"·type="text/css"·href="help:/common/kde-default.css"><link·rel="stylesheet"·type="text/css"·href="help:/common/kde-docs.css"><link·rel="stylesheet"·type="text/css"·href="help:/common/kde-localised.css"><meta·name="generator"·content="DocBook·XSL·Stylesheets·V1.76.1"><meta·name="description"·content="KTurtle·is·an·educational·programming·environment·that·aims·to·make·learning·how·to·program·as·easy·as·possible.·To·achieve·this·KTurtle·makes·all·programming·tools·available·from·the·user·interface.·The·programming·language·used·is·TurtleScript·which·allows·its·commands·to·be·translated."><meta·name="keywords"·content="KDE,·kdeedu,·KTurtle,·education,·language,·native,·programming,·TurtleScript,·Logo,·turtle"><link·rel="home"·href="index.html"·title="The·KTurtle·Handbook"><link·rel="next"·href="introduction.html"·title="Chapter 1. Introduction"><meta·http-equiv="Content-Type"·content="text/html;·charset=utf-8"><me·✂ | 1 | <FILENAME·filename="index.html"><html><head><title>The·KTurtle·Handbook</title><link·rel="stylesheet"·type="text/css"·href="help:/common/kde-default.css"><link·rel="stylesheet"·type="text/css"·href="help:/common/kde-docs.css"><link·rel="stylesheet"·type="text/css"·href="help:/common/kde-localised.css"><meta·name="generator"·content="DocBook·XSL·Stylesheets·V1.76.1"><meta·name="description"·content="KTurtle·is·an·educational·programming·environment·that·aims·to·make·learning·how·to·program·as·easy·as·possible.·To·achieve·this·KTurtle·makes·all·programming·tools·available·from·the·user·interface.·The·programming·language·used·is·TurtleScript·which·allows·its·commands·to·be·translated."><meta·name="keywords"·content="KDE,·kdeedu,·KTurtle,·education,·language,·native,·programming,·TurtleScript,·Logo,·turtle"><link·rel="home"·href="index.html"·title="The·KTurtle·Handbook"><link·rel="next"·href="introduction.html"·title="Chapter 1. Introduction"><meta·http-equiv="Content-Type"·content="text/html;·charset=utf-8"><me·✂ |
2 | a·programming·language·loosely·based·on·and·inspired·by·Logo.·The·goal·of·<span·class="application">KTurtle</span>·is·to·make·programming·as·easy·and·accessible·as·possible.·This·makes·<span·class="application">KTurtle</span>·suitable·for·teaching·kids·the·basics·of·math,·geometry·and... | 2 | a·programming·language·loosely·based·on·and·inspired·by·Logo.·The·goal·of·<span·class="application">KTurtle</span>·is·to·make·programming·as·easy·and·accessible·as·possible.·This·makes·<span·class="application">KTurtle</span>·suitable·for·teaching·kids·the·basics·of·math,·geometry·and... |
3 | programming.·One·of·the·main·features·of·TurtleScript·is·the·ability·to·translate·the·commands·into·the·speaking·language·of·the·programmer.</p><p><span·class="application">KTurtle</span>·is·named·after·<span·class="quote">“<span·class="quote">the·turtle</span>”</span>·that·plays·a·central·role·in·the·programming·environment.·The·student·will·usually·instruct·the·turtle,·using·the·TurtleScript·commands,·to·make·a·drawing·on·<a·class="link"·href="the-canvas.html"·title="The·Canvas">the·canvas</a>.</p><div·class="sect1"><div·class="titlepage"><div><div><h2·class="title"·style="clear:·both"><a·name="what-is-turtlelang"></a>What·is·TurtleScript?</h2></div></div></div><p>TurtleScript,·the·programming·language·used·in·<span·class="application">KTurtle</span>,·is·inspired·by·the·Logo·family·of·programming·languages.·The·first·version·of·Logo·was·created·by·Seymour·Papert·of·MIT·Artificial·Intelligence·Laboratory·in·1967·as·an·offshoot·of·the·LISP·programming·language.·From·then·many·versions·of·Logo·have·been·releas·✂ | 3 | programming.·One·of·the·main·features·of·TurtleScript·is·the·ability·to·translate·the·commands·into·the·speaking·language·of·the·programmer.</p><p><span·class="application">KTurtle</span>·is·named·after·<span·class="quote">“<span·class="quote">the·turtle</span>”</span>·that·plays·a·central·role·in·the·programming·environment.·The·student·will·usually·instruct·the·turtle,·using·the·TurtleScript·commands,·to·make·a·drawing·on·<a·class="link"·href="the-canvas.html"·title="The·Canvas">the·canvas</a>.</p><div·class="sect1"><div·class="titlepage"><div><div><h2·class="title"·style="clear:·both"><a·name="what-is-turtlelang"></a>What·is·TurtleScript?</h2></div></div></div><p>TurtleScript,·the·programming·language·used·in·<span·class="application">KTurtle</span>,·is·inspired·by·the·Logo·family·of·programming·languages.·The·first·version·of·Logo·was·created·by·Seymour·Papert·of·MIT·Artificial·Intelligence·Laboratory·in·1967·as·an·offshoot·of·the·LISP·programming·language.·From·then·many·versions·of·Logo·have·been·releas·✂ |
4 | purposes.·The·MIT·is·still·maintains·<a·class="ulink"·href="http://el.media.mit.edu/logo-foundation/"·target="_top">a·website·on·Logo</a>·containing·a·list·of·several·popular·implementation·of·the·language.</p><p>TurtleScript·shares·a·feature·found·in·many·other·implementations·of·Logo:·the·ability·to·translate·the·commands·to·suit·the·native·language·of·the·student.·This·feature·makes·it·easier·for·students·that·have·no·or·little·understanding·of·English·to·get·started.·Besides·this·feature·<span·class="application">KTurtle</span>·has·<a·class="link"·href="features-of-kturtle.html"·title="Features·of·KTurtle">many·other·features</a>·aimed·at·easing·the·students·initial·experience·with·programming.</p></div><FILENAME·filename="features-of-kturtle.html"><html><head><title>Features·of·KTurtle</title><link·rel="stylesheet"·type="text/css"·href="help:/common/kde-default.css"><link·rel="stylesheet"·type="text/css"·href="help:/common/kde-docs.css"><link·rel="stylesheet"·type="text/css"·href="help:/common/kde-locali·✂ | 4 | purposes.·The·MIT·is·still·maintains·<a·class="ulink"·href="http://el.media.mit.edu/logo-foundation/"·target="_top">a·website·on·Logo</a>·containing·a·list·of·several·popular·implementation·of·the·language.</p><p>TurtleScript·shares·a·feature·found·in·many·other·implementations·of·Logo:·the·ability·to·translate·the·commands·to·suit·the·native·language·of·the·student.·This·feature·makes·it·easier·for·students·that·have·no·or·little·understanding·of·English·to·get·started.·Besides·this·feature·<span·class="application">KTurtle</span>·has·<a·class="link"·href="features-of-kturtle.html"·title="Features·of·KTurtle">many·other·features</a>·aimed·at·easing·the·students·initial·experience·with·programming.</p></div><FILENAME·filename="features-of-kturtle.html"><html><head><title>Features·of·KTurtle</title><link·rel="stylesheet"·type="text/css"·href="help:/common/kde-default.css"><link·rel="stylesheet"·type="text/css"·href="help:/common/kde-docs.css"><link·rel="stylesheet"·type="text/css"·href="help:/common/kde-locali·✂ |
5 | </p><div·class="itemizedlist"><ul·class="itemizedlist"·type="disc"><li·class="listitem"><p>An·integrated·environment·with·TurtleScript·interpreter,·<a·class="link"·href="using-kturtle.html#the-editor"·title="The·Editor">editor</a>,·<a·class="link"·href="the-canvas.html"·title="The·Canvas">canvas</a>·and·other·tools·all·in·one·application·(no·extra·dependencies).</p></li><li·class="listitem"><p>The·ability·to·translate·the·TurtleScript·commands·using·the·translation·framework·of·<acronym·class="acronym">KDE</acronym>.</p></li><li·class="listitem"><p>TurtleScript·supports·user·defined·functions,·recursion·and·dynamic·type·switching.</p></li><li·class="listitem"><p>The·execution·can·be·slowed·down,·paused·or·stopped·at·any·time.</p></li><li·class="listitem"><p>A·powerful·<a·class="link"·href="using-kturtle.html#the-editor"·title="The·Editor">editor</a>·featuring·intuitive·syntax·highlighting,·line·numbering,·error·markers,·visual·execution·and·more.</p></li><li·class="listitem"><p>The·<a·class="link"·href="the-c·✂ | 5 | </p><div·class="itemizedlist"><ul·class="itemizedlist"·type="disc"><li·class="listitem"><p>An·integrated·environment·with·TurtleScript·interpreter,·<a·class="link"·href="using-kturtle.html#the-editor"·title="The·Editor">editor</a>,·<a·class="link"·href="the-canvas.html"·title="The·Canvas">canvas</a>·and·other·tools·all·in·one·application·(no·extra·dependencies).</p></li><li·class="listitem"><p>The·ability·to·translate·the·TurtleScript·commands·using·the·translation·framework·of·<acronym·class="acronym">KDE</acronym>.</p></li><li·class="listitem"><p>TurtleScript·supports·user·defined·functions,·recursion·and·dynamic·type·switching.</p></li><li·class="listitem"><p>The·execution·can·be·slowed·down,·paused·or·stopped·at·any·time.</p></li><li·class="listitem"><p>A·powerful·<a·class="link"·href="using-kturtle.html#the-editor"·title="The·Editor">editor</a>·featuring·intuitive·syntax·highlighting,·line·numbering,·error·markers,·visual·execution·and·more.</p></li><li·class="listitem"><p>The·<a·class="link"·href="the-c·✂ |
6 | </p></div></div><div·id="footer"><div·class="navCenter"><table·class="navigation"><tr><td·class="prevCell"><a·accesskey="p"·href="introduction.html">Prev</a></td><td·class="upCell"><a·accesskey="h"·href="index.html">Contents</a></td><td·class="nextCell"><a·accesskey="n"·href="using-kturtle.html">Next</a></td></tr><tr><td·class="prevCell">Introduction </td><td·class="upCell">Introduction</td><td·class="nextCell"> Using·<span·class="application">KTurtle</span></td></tr></table></div><div·id="footer_text">Would·you·like·to·make·a·comment·or·contribute·an·update·to·this·page?<br>Send·feedback·to·the·<a·href="mailto:kde-doc-english@kde.org"·class="footer_email">KDE·Docs·Team</a></div></div></div></body></html></FILENAME></div></div><div·id="footer"><div·class="navCenter"><table·class="navigation"><tr><td·class="prevCell"><a·accesskey="p"·href="index.html">Prev</a></td><td·class="upCell"><a·accesskey="h"·href="index.html">Contents</a></td><td·class="nextCell"><a·accesskey="n"·href="features-of-kturtle.html">Next</a·✂ | 6 | </p></div></div><div·id="footer"><div·class="navCenter"><table·class="navigation"><tr><td·class="prevCell"><a·accesskey="p"·href="introduction.html">Prev</a></td><td·class="upCell"><a·accesskey="h"·href="index.html">Contents</a></td><td·class="nextCell"><a·accesskey="n"·href="using-kturtle.html">Next</a></td></tr><tr><td·class="prevCell">Introduction </td><td·class="upCell">Introduction</td><td·class="nextCell"> Using·<span·class="application">KTurtle</span></td></tr></table></div><div·id="footer_text">Would·you·like·to·make·a·comment·or·contribute·an·update·to·this·page?<br>Send·feedback·to·the·<a·href="mailto:kde-doc-english@kde.org"·class="footer_email">KDE·Docs·Team</a></div></div></div></body></html></FILENAME></div></div><div·id="footer"><div·class="navCenter"><table·class="navigation"><tr><td·class="prevCell"><a·accesskey="p"·href="index.html">Prev</a></td><td·class="upCell"><a·accesskey="h"·href="index.html">Contents</a></td><td·class="nextCell"><a·accesskey="n"·href="features-of-kturtle.html">Next</a·✂ |
7 | ······additional·TurtleScript·files·from·the·Internet.</p></dd></dl></div><div·class="variablelist"><a·name="file-save"></a><dl><dt><span·class="term"><span·xmlns:doc="http://nwalsh.com/xsl/documentation/1.0"·class="guiitem"><span·class="guimenu">File</span></span>·→·<span·xmlns:doc="http://nwalsh.com/xsl/documentation/1.0"·class="guiitem"><span·class="guimenuitem">Save</span></span>·(<span·class="shortcut"><strong><span·class="keycap"><strong>Ctrl</strong></span>+<span·class="keycap"><strong>S</strong></span></strong></span>)</span></dt><dd><p>Saves·the·currently·opened·TurtleScript·file.</p></dd></dl></div><div·class="variablelist"><a·name="file-save-as"></a><dl><dt><span·class="term"><span·xmlns:doc="http://nwalsh.com/xsl/documentation/1.0"·class="guiitem"><span·class="guimenu">File</span></span>·→·<span·xmlns:doc="http://nwalsh.com/xsl/documentation/1.0"·class="guiitem"><span·class="guimenuitem">Save·As...</span></span></span></dt><dd><p>Saves·the·currently·opened·TurtleScript·file·on·a·specified·location·✂ | 7 | ······additional·TurtleScript·files·from·the·Internet.</p></dd></dl></div><div·class="variablelist"><a·name="file-save"></a><dl><dt><span·class="term"><span·xmlns:doc="http://nwalsh.com/xsl/documentation/1.0"·class="guiitem"><span·class="guimenu">File</span></span>·→·<span·xmlns:doc="http://nwalsh.com/xsl/documentation/1.0"·class="guiitem"><span·class="guimenuitem">Save</span></span>·(<span·class="shortcut"><strong><span·class="keycap"><strong>Ctrl</strong></span>+<span·class="keycap"><strong>S</strong></span></strong></span>)</span></dt><dd><p>Saves·the·currently·opened·TurtleScript·file.</p></dd></dl></div><div·class="variablelist"><a·name="file-save-as"></a><dl><dt><span·class="term"><span·xmlns:doc="http://nwalsh.com/xsl/documentation/1.0"·class="guiitem"><span·class="guimenu">File</span></span>·→·<span·xmlns:doc="http://nwalsh.com/xsl/documentation/1.0"·class="guiitem"><span·class="guimenuitem">Save·As...</span></span></span></dt><dd><p>Saves·the·currently·opened·TurtleScript·file·on·a·specified·location·✂ |
8 | <span·xmlns:doc="http://nwalsh.com/xsl/documentation/1.0"·class="guiitem"><span·class="guimenu">Help</span></span>·→·<span·xmlns:doc="http://nwalsh.com/xsl/documentation/1.0"·class="guiitem"><span·class="guimenuitem"><span·class="application">KTurtle</span>·Handbook</span></span>·(<span·class="shortcut"><strong><span·class="keycap"><strong>F1</strong></span></strong></span>) | 8 | <span·xmlns:doc="http://nwalsh.com/xsl/documentation/1.0"·class="guiitem"><span·class="guimenu">Help</span></span>·→·<span·xmlns:doc="http://nwalsh.com/xsl/documentation/1.0"·class="guiitem"><span·class="guimenuitem"><span·class="application">KTurtle</span>·Handbook</span></span>·(<span·class="shortcut"><strong><span·class="keycap"><strong>F1</strong></span></strong></span>) |
Offset 134, 82 lines modified | Offset 134, 82 lines modified |
134 | } | 134 | } |
135 | </pre></div></div><div·class="sect2"><div·class="titlepage"><div><div><h3·class="title"><a·name="comparing-operators"></a>Comparing·operators</h3></div></div></div><p>Consider·this·simple·comparison: | 135 | </pre></div></div><div·class="sect2"><div·class="titlepage"><div><div><h3·class="title"><a·name="comparing-operators"></a>Comparing·operators</h3></div></div></div><p>Consider·this·simple·comparison: |
136 | </p><pre·class="screen"> | 136 | </p><pre·class="screen"> |
137 | $answer·=·10·>·3 | 137 | $answer·=·10·>·3 |
138 | </pre><p> | 138 | </pre><p> |
139 | Here·<strong·class="userinput"><code>10</code></strong>·is·compared·to·<strong·class="userinput"><code>3</code></strong>·with·the·'greater·than'·operator.·The·result·of·this·comparison,·the·<a·class="link"·href="reference.html#boolean-value"·title="Boolean·(true/false)·values">boolean·value</a>·<strong·class="userinput"><code>true</code></strong>·is·stored·in·the·<a·class="link"·href="assignment-of-variables.html"·title="Assignment·of·variables">variable</a>·<strong·class="userinput"><code>$answer</code></strong>.</p><p>All·<a·class="link"·href="reference.html#number"·title="Numbers">numbers</a>·and·<a·class="link"·href="assignment-of-variables.html"·title="Assignment·of·variables">variables</a>·(that·contain·numbers)·can·be·compared·to·each·other·with·comparing·operators.</p><p> | 139 | Here·<strong·class="userinput"><code>10</code></strong>·is·compared·to·<strong·class="userinput"><code>3</code></strong>·with·the·'greater·than'·operator.·The·result·of·this·comparison,·the·<a·class="link"·href="reference.html#boolean-value"·title="Boolean·(true/false)·values">boolean·value</a>·<strong·class="userinput"><code>true</code></strong>·is·stored·in·the·<a·class="link"·href="assignment-of-variables.html"·title="Assignment·of·variables">variable</a>·<strong·class="userinput"><code>$answer</code></strong>.</p><p>All·<a·class="link"·href="reference.html#number"·title="Numbers">numbers</a>·and·<a·class="link"·href="assignment-of-variables.html"·title="Assignment·of·variables">variables</a>·(that·contain·numbers)·can·be·compared·to·each·other·with·comparing·operators.</p><p> |
140 | Here·are·all·possible·comparing·operators: | 140 | Here·are·all·possible·comparing·operators: |
141 | </p><div·class="table"><a·name="idp149455928"></a><p·class="title"><b>Table 4.1. Types·of·questions</b></p><div·class="table-contents"><table·summary="Types·of·questions"·border="1"><colgroup><col><col><col></colgroup><tbody><tr><td><strong·class="userinput"><code>$A·==·$B</code></strong></td><td>equals</td><td>answer·is·<span·class="quote">“<span·class="quote">true</span>”</span>·if·<strong·class="userinput"><code>$A</code></strong>·equals·<strong·class="userinput"><code>$B</code></strong></td></tr><tr><td><strong·class="userinput"><code>$A·!=·$B</code></strong></td><td>not-equals</td><td>answer·is·<span·class="quote">“<span·class="quote">true</span>”</span>·if·<strong·class="userinput"><code>$A</code></strong>·does·not·equal·<strong·class="userinput"><code>$B</code></strong></td></tr><tr><td><strong·class="userinput"><code>$A·>·$B</code></strong></td><td>greater·than</td><td>answer·is·<span·class="quote">“<span·class="quote">true</span>”</span>·if·<strong·class="userinput"><code>$A</code></strong>·is·gre·✂ | 141 | </p><div·class="table"><a·name="idp149435448"></a><p·class="title"><b>Table 4.1. Types·of·questions</b></p><div·class="table-contents"><table·summary="Types·of·questions"·border="1"><colgroup><col><col><col></colgroup><tbody><tr><td><strong·class="userinput"><code>$A·==·$B</code></strong></td><td>equals</td><td>answer·is·<span·class="quote">“<span·class="quote">true</span>”</span>·if·<strong·class="userinput"><code>$A</code></strong>·equals·<strong·class="userinput"><code>$B</code></strong></td></tr><tr><td><strong·class="userinput"><code>$A·!=·$B</code></strong></td><td>not-equals</td><td>answer·is·<span·class="quote">“<span·class="quote">true</span>”</span>·if·<strong·class="userinput"><code>$A</code></strong>·does·not·equal·<strong·class="userinput"><code>$B</code></strong></td></tr><tr><td><strong·class="userinput"><code>$A·>·$B</code></strong></td><td>greater·than</td><td>answer·is·<span·class="quote">“<span·class="quote">true</span>”</span>·if·<strong·class="userinput"><code>$A</code></strong>·is·gre·✂ |
142 | Please·note·that·$A·and·$B·have·to·be·<a·class="link"·href="reference.html#number"·title="Numbers">numbers</a>·or·<a·class="link"·href="assignment-of-variables.html"·title="Assignment·of·variables">variables</a>·that·contain·numbers.</p></div></div></div><div·id="footer"><div·class="navCenter"><table·class="navigation"><tr><td·class="prevCell"><a·accesskey="p"·href="reference.html">Prev</a></td><td·class="upCell"><a·accesskey="h"·href="index.html">Contents</a></td><td·class="nextCell"><a·accesskey="n"·href="commands.html">Next</a></td></tr><tr><td·class="prevCell">TurtleScript·Programming·Reference </td><td·class="upCell">TurtleScript·Programming·Reference</td><td·class="nextCell"> Commands</td></tr></table></div><div·id="footer_text">Would·you·like·to·make·a·comment·or·contribute·an·update·to·this·page?<br>Send·feedback·to·the·<a·href="mailto:kde-doc-english@kde.org"·class="footer_email">KDE·Docs·Team</a></div></div></div></body></html></FILENAME><FILENAME·filename="commands.html"><html><head><title>Commands·✂ | 142 | Please·note·that·$A·and·$B·have·to·be·<a·class="link"·href="reference.html#number"·title="Numbers">numbers</a>·or·<a·class="link"·href="assignment-of-variables.html"·title="Assignment·of·variables">variables</a>·that·contain·numbers.</p></div></div></div><div·id="footer"><div·class="navCenter"><table·class="navigation"><tr><td·class="prevCell"><a·accesskey="p"·href="reference.html">Prev</a></td><td·class="upCell"><a·accesskey="h"·href="index.html">Contents</a></td><td·class="nextCell"><a·accesskey="n"·href="commands.html">Next</a></td></tr><tr><td·class="prevCell">TurtleScript·Programming·Reference </td><td·class="upCell">TurtleScript·Programming·Reference</td><td·class="nextCell"> Commands</td></tr></table></div><div·id="footer_text">Would·you·like·to·make·a·comment·or·contribute·an·update·to·this·page?<br>Send·feedback·to·the·<a·href="mailto:kde-doc-english@kde.org"·class="footer_email">KDE·Docs·Team</a></div></div></div></body></html></FILENAME><FILENAME·filename="commands.html"><html><head><title>Commands·✂ |
143 | ······<strong·class="userinput"><code>forward</code></strong>·moves·the·turtle·forward·by·the·amount·of·X·pixels.·When·the·pen·is·down·the·turtle·will·leave·a·trail.·<strong·class="userinput"><code>forward</code></strong>·can·be·abbreviated·to·<strong·class="userinput"><code>fw</code></strong></p></dd></dl></div><div·class="variablelist"><a·name="backward"></a><dl><dt><span·class="term">backward·(bw)<a·class="indexterm"·name="idp149484088"></a></span></dt><dd><pre·class="screen">backward·X</pre><p> | 143 | ······<strong·class="userinput"><code>forward</code></strong>·moves·the·turtle·forward·by·the·amount·of·X·pixels.·When·the·pen·is·down·the·turtle·will·leave·a·trail.·<strong·class="userinput"><code>forward</code></strong>·can·be·abbreviated·to·<strong·class="userinput"><code>fw</code></strong></p></dd></dl></div><div·class="variablelist"><a·name="backward"></a><dl><dt><span·class="term">backward·(bw)<a·class="indexterm"·name="idp149463608"></a></span></dt><dd><pre·class="screen">backward·X</pre><p> |
144 | ······<strong·class="userinput"><code>backward</code></strong>·moves·the·turtle·backward·by·the·amount·of·X·pixels.·When·the·pen·is·down·the·turtle·will·leave·a·trail.·<strong·class="userinput"><code>backward</code></strong>·can·be·abbreviated·to·<strong·class="userinput"><code>bw</code></strong>.</p></dd></dl></div><div·class="variablelist"><a·name="turnleft"></a><dl><dt><span·class="term">turnleft·(tl)<a·class="indexterm"·name="idp149487928"></a></span></dt><dd><pre·class="screen">turnleft·X</pre><p> | 144 | ······<strong·class="userinput"><code>backward</code></strong>·moves·the·turtle·backward·by·the·amount·of·X·pixels.·When·the·pen·is·down·the·turtle·will·leave·a·trail.·<strong·class="userinput"><code>backward</code></strong>·can·be·abbreviated·to·<strong·class="userinput"><code>bw</code></strong>.</p></dd></dl></div><div·class="variablelist"><a·name="turnleft"></a><dl><dt><span·class="term">turnleft·(tl)<a·class="indexterm"·name="idp149467448"></a></span></dt><dd><pre·class="screen">turnleft·X</pre><p> |
145 | ······<strong·class="userinput"><code>turnleft</code></strong>·commands·the·turtle·to·turn·an·amount·of·X·degrees·to·the·left.·<strong·class="userinput"><code>turnleft</code></strong>·can·be·abbreviated·to·<strong·class="userinput"><code>tl</code></strong>.</p></dd></dl></div><div·class="variablelist"><a·name="turnright"></a><dl><dt><span·class="term">turnright·(tr)<a·class="indexterm"·name="idp149491768"></a></span></dt><dd><pre·class="screen">turnright·X</pre><p> | 145 | ······<strong·class="userinput"><code>turnleft</code></strong>·commands·the·turtle·to·turn·an·amount·of·X·degrees·to·the·left.·<strong·class="userinput"><code>turnleft</code></strong>·can·be·abbreviated·to·<strong·class="userinput"><code>tl</code></strong>.</p></dd></dl></div><div·class="variablelist"><a·name="turnright"></a><dl><dt><span·class="term">turnright·(tr)<a·class="indexterm"·name="idp149471288"></a></span></dt><dd><pre·class="screen">turnright·X</pre><p> |
146 | ······<strong·class="userinput"><code>turnright</code></strong>·the·turtle·to·turn·an·amount·of·X·degrees·to·the·right.·<strong·class="userinput"><code>turnright</code></strong>·can·be·abbreviated·to·<strong·class="userinput"><code>tr</code></strong>.</p></dd></dl></div><div·class="variablelist"><a·name="direction"></a><dl><dt><span·class="term">direction·(dir)<a·class="indexterm"·name="idp149495608"></a></span></dt><dd><pre·class="screen">direction·X</pre><p> | 146 | ······<strong·class="userinput"><code>turnright</code></strong>·the·turtle·to·turn·an·amount·of·X·degrees·to·the·right.·<strong·class="userinput"><code>turnright</code></strong>·can·be·abbreviated·to·<strong·class="userinput"><code>tr</code></strong>.</p></dd></dl></div><div·class="variablelist"><a·name="direction"></a><dl><dt><span·class="term">direction·(dir)<a·class="indexterm"·name="idp149475128"></a></span></dt><dd><pre·class="screen">direction·X</pre><p> |
147 | ······<strong·class="userinput"><code>direction</code></strong>·set·the·turtle's·direction·to·an·amount·of·X·degrees·counting·from·zero,·and·thus·is·not·relative·to·the·turtle's·previous·direction.·<strong·class="userinput"><code>direction</code></strong>·can·be·abbreviated·to·<strong·class="userinput"><code>dir</code></strong>.</p></dd></dl></div><div·class="variablelist"><a·name="getdirection"></a><dl><dt><span·class="term">getdirection<a·class="indexterm"·name="idp149499448"></a></span></dt><dd><pre·class="screen">getdirection</pre><p> | 147 | ······<strong·class="userinput"><code>direction</code></strong>·set·the·turtle's·direction·to·an·amount·of·X·degrees·counting·from·zero,·and·thus·is·not·relative·to·the·turtle's·previous·direction.·<strong·class="userinput"><code>direction</code></strong>·can·be·abbreviated·to·<strong·class="userinput"><code>dir</code></strong>.</p></dd></dl></div><div·class="variablelist"><a·name="getdirection"></a><dl><dt><span·class="term">getdirection<a·class="indexterm"·name="idp149478968"></a></span></dt><dd><pre·class="screen">getdirection</pre><p> |
148 | ······<strong·class="userinput"><code>getdirection</code></strong>·returns·the·turtle's·direction·as·an·amount·of·degrees·counting·from·zero,·where·zero·is·the·direction·when·the·turtle·is·pointing·upwards.</p></dd></dl></div><div·class="variablelist"><a·name="center"></a><dl><dt><span·class="term">center<a·class="indexterm"·name="idp149502520"></a></span></dt><dd><pre·class="screen">center</pre><p> | 148 | ······<strong·class="userinput"><code>getdirection</code></strong>·returns·the·turtle's·direction·as·an·amount·of·degrees·counting·from·zero,·where·zero·is·the·direction·when·the·turtle·is·pointing·upwards.</p></dd></dl></div><div·class="variablelist"><a·name="center"></a><dl><dt><span·class="term">center<a·class="indexterm"·name="idp149482040"></a></span></dt><dd><pre·class="screen">center</pre><p> |
149 | ······<strong·class="userinput"><code>center</code></strong>·moves·the·turtle·to·the·center·on·the·canvas.</p></dd></dl></div><div·class="variablelist"><a·name="go"></a><dl><dt><span·class="term">go<a·class="indexterm"·name="idp149505592"></a></span></dt><dd><pre·class="screen">go·X,Y</pre><p> | 149 | ······<strong·class="userinput"><code>center</code></strong>·moves·the·turtle·to·the·center·on·the·canvas.</p></dd></dl></div><div·class="variablelist"><a·name="go"></a><dl><dt><span·class="term">go<a·class="indexterm"·name="idp149485112"></a></span></dt><dd><pre·class="screen">go·X,Y</pre><p> |
150 | ······<strong·class="userinput"><code>go</code></strong>·commands·the·turtle·to·go·to·a·certain·place·on·the·canvas.·This·place·is·X·<a·class="glossterm"·href="Glossary.html#pixels"><em·class="glossterm">pixels</em></a>·from·the·left·of·the·canvas,·and·Y·<a·class="glossterm"·href="Glossary.html#pixels"><em·class="glossterm">pixels</em></a>·from·the·top·of·the·canvas.</p></dd></dl></div><div·class="variablelist"><a·name="gox"></a><dl><dt><span·class="term">gox<a·class="indexterm"·name="idp149509688"></a></span></dt><dd><pre·class="screen">gox·X</pre><p> | 150 | ······<strong·class="userinput"><code>go</code></strong>·commands·the·turtle·to·go·to·a·certain·place·on·the·canvas.·This·place·is·X·<a·class="glossterm"·href="Glossary.html#pixels"><em·class="glossterm">pixels</em></a>·from·the·left·of·the·canvas,·and·Y·<a·class="glossterm"·href="Glossary.html#pixels"><em·class="glossterm">pixels</em></a>·from·the·top·of·the·canvas.</p></dd></dl></div><div·class="variablelist"><a·name="gox"></a><dl><dt><span·class="term">gox<a·class="indexterm"·name="idp149489208"></a></span></dt><dd><pre·class="screen">gox·X</pre><p> |
151 | ······<strong·class="userinput"><code>gox</code></strong>·using·this·command·the·turtle·will·move·to·X·<a·class="glossterm"·href="Glossary.html#pixels"><em·class="glossterm">pixels</em></a>·from·the·left·of·the·canvas·whilst·staying·at·the·same·height.·<strong·class="userinput"><code>gox</code></strong>·can·be·abbreviated·to·<strong·class="userinput"><code>gx</code></strong>.</p></dd></dl></div><div·class="variablelist"><a·name="goy"></a><dl><dt><span·class="term">goy<a·class="indexterm"·name="idp149514040"></a></span></dt><dd><pre·class="screen">goy·Y</pre><p> | 151 | ······<strong·class="userinput"><code>gox</code></strong>·using·this·command·the·turtle·will·move·to·X·<a·class="glossterm"·href="Glossary.html#pixels"><em·class="glossterm">pixels</em></a>·from·the·left·of·the·canvas·whilst·staying·at·the·same·height.·<strong·class="userinput"><code>gox</code></strong>·can·be·abbreviated·to·<strong·class="userinput"><code>gx</code></strong>.</p></dd></dl></div><div·class="variablelist"><a·name="goy"></a><dl><dt><span·class="term">goy<a·class="indexterm"·name="idp149493560"></a></span></dt><dd><pre·class="screen">goy·Y</pre><p> |
152 | ······<strong·class="userinput"><code>goy</code></strong>·using·this·command·the·turtle·will·move·to·Y·<a·class="glossterm"·href="Glossary.html#pixels"><em·class="glossterm">pixels</em></a>·from·the·top·of·the·canvas·whilst·staying·at·the·same·distance·from·the·left·border·of·the·canvas.·<strong·class="userinput"><code>goy</code></strong>·can·be·abbreviated·to·<strong·class="userinput"><code>gy</code></strong>.</p></dd></dl></div><div·class="note"·style="margin-left:·0.5in;·margin-right:·0.5in;"><h3·class="title">Note</h3><p>Using·the·commands·<strong·class="userinput"><code>go</code></strong>,·<strong·class="userinput"><code>gox</code></strong>,·<strong·class="userinput"><code>goy</code></strong>·and·<strong·class="userinput"><code>center</code></strong>·the·turtle·will·not·draw·a·line,·no·matter·if·the·pen·is·up·or·down.</p></div></div><div·class="sect2"><div·class="titlepage"><div><div><h3·class="title"><a·name="locate-the-turtle"></a>Where·is·the·turtle?</h3></div></div></div><p>There·are·two·commands·whi·✂ | 152 | ······<strong·class="userinput"><code>goy</code></strong>·using·this·command·the·turtle·will·move·to·Y·<a·class="glossterm"·href="Glossary.html#pixels"><em·class="glossterm">pixels</em></a>·from·the·top·of·the·canvas·whilst·staying·at·the·same·distance·from·the·left·border·of·the·canvas.·<strong·class="userinput"><code>goy</code></strong>·can·be·abbreviated·to·<strong·class="userinput"><code>gy</code></strong>.</p></dd></dl></div><div·class="note"·style="margin-left:·0.5in;·margin-right:·0.5in;"><h3·class="title">Note</h3><p>Using·the·commands·<strong·class="userinput"><code>go</code></strong>,·<strong·class="userinput"><code>gox</code></strong>,·<strong·class="userinput"><code>goy</code></strong>·and·<strong·class="userinput"><code>center</code></strong>·the·turtle·will·not·draw·a·line,·no·matter·if·the·pen·is·up·or·down.</p></div></div><div·class="sect2"><div·class="titlepage"><div><div><h3·class="title"><a·name="locate-the-turtle"></a>Where·is·the·turtle?</h3></div></div></div><p>There·are·two·commands·whi·✂ |
153 | ······<strong·class="userinput"><code>getx</code></strong>·returns·the·number·of·pixels·from·the·left·of·the·canvas·to·the·current·position·of·the·turtle.</p></dd></dl></div><div·class="variablelist"><a·name="gety"></a><dl><dt><span·class="term">gety<a·class="indexterm"·name="idp149577912"></a></span></dt><dd><p> | 153 | ······<strong·class="userinput"><code>getx</code></strong>·returns·the·number·of·pixels·from·the·left·of·the·canvas·to·the·current·position·of·the·turtle.</p></dd></dl></div><div·class="variablelist"><a·name="gety"></a><dl><dt><span·class="term">gety<a·class="indexterm"·name="idp149504184"></a></span></dt><dd><p> |
154 | ······<strong·class="userinput"><code>gety</code></strong>·returns·the·number·of·pixels·from·the·top·of·the·canvas·to·the·current·position·of·the·turtle.</p></dd></dl></div></div><div·class="sect2"><div·class="titlepage"><div><div><h3·class="title"><a·name="pen"></a>The·turtle·has·a·pen</h3></div></div></div><p>The·turtle·has·a·pen·that·draws·a·line·when·the·turtle·moves.·There·are·a·few·commands·to·control·the·pen.·In·this·section·we·explain·these·commands.</p><div·class="variablelist"><a·name="penup"></a><dl><dt><span·class="term">penup·(pu)<a·class="indexterm"·name="idp149582008"></a></span></dt><dd><pre·class="screen">penup</pre><p> | 154 | ······<strong·class="userinput"><code>gety</code></strong>·returns·the·number·of·pixels·from·the·top·of·the·canvas·to·the·current·position·of·the·turtle.</p></dd></dl></div></div><div·class="sect2"><div·class="titlepage"><div><div><h3·class="title"><a·name="pen"></a>The·turtle·has·a·pen</h3></div></div></div><p>The·turtle·has·a·pen·that·draws·a·line·when·the·turtle·moves.·There·are·a·few·commands·to·control·the·pen.·In·this·section·we·explain·these·commands.</p><div·class="variablelist"><a·name="penup"></a><dl><dt><span·class="term">penup·(pu)<a·class="indexterm"·name="idp149508280"></a></span></dt><dd><pre·class="screen">penup</pre><p> |
155 | ······<strong·class="userinput"><code>penup</code></strong>·lifts·the·pen·from·the·canvas.·When·the·pen·is·<span·class="quote">“<span·class="quote">up</span>”</span>·no·line·will·be·drawn·when·the·turtle·moves.·See·also·<strong·class="userinput"><code>pendown</code></strong>.·<strong·class="userinput"><code>penup</code></strong>·can·be·abbreviated·to·<strong·class="userinput"><code>pu</code></strong>.</p></dd></dl></div><div·class="variablelist"><a·name="pendown"></a><dl><dt><span·class="term">pendown·(pd)<a·class="indexterm"·name="idp149586616"></a></span></dt><dd><pre·class="screen">pendown</pre><p> | 155 | ······<strong·class="userinput"><code>penup</code></strong>·lifts·the·pen·from·the·canvas.·When·the·pen·is·<span·class="quote">“<span·class="quote">up</span>”</span>·no·line·will·be·drawn·when·the·turtle·moves.·See·also·<strong·class="userinput"><code>pendown</code></strong>.·<strong·class="userinput"><code>penup</code></strong>·can·be·abbreviated·to·<strong·class="userinput"><code>pu</code></strong>.</p></dd></dl></div><div·class="variablelist"><a·name="pendown"></a><dl><dt><span·class="term">pendown·(pd)<a·class="indexterm"·name="idp149512888"></a></span></dt><dd><pre·class="screen">pendown</pre><p> |
156 | ······<strong·class="userinput"><code>pendown</code></strong>·presses·the·pen·down·on·the·canvas.·When·the·pen·is·press·<span·class="quote">“<span·class="quote">down</span>”</span>·on·the·canvas·a·line·will·be·drawn·when·the·turtle·moves.·See·also·<strong·class="userinput"><code>penup</code></strong>.·<strong·class="userinput"><code>pendown</code></strong>·can·be·abbreviated·to·<strong·class="userinput"><code>pd</code></strong>.</p></dd></dl></div><div·class="variablelist"><a·name="setpenwidth"></a><dl><dt><span·class="term">penwidth·(pw)<a·class="indexterm"·name="idp149591224"></a></span></dt><dd><pre·class="screen">penwidth·X</pre><p> | 156 | ······<strong·class="userinput"><code>pendown</code></strong>·presses·the·pen·down·on·the·canvas.·When·the·pen·is·press·<span·class="quote">“<span·class="quote">down</span>”</span>·on·the·canvas·a·line·will·be·drawn·when·the·turtle·moves.·See·also·<strong·class="userinput"><code>penup</code></strong>.·<strong·class="userinput"><code>pendown</code></strong>·can·be·abbreviated·to·<strong·class="userinput"><code>pd</code></strong>.</p></dd></dl></div><div·class="variablelist"><a·name="setpenwidth"></a><dl><dt><span·class="term">penwidth·(pw)<a·class="indexterm"·name="idp149517496"></a></span></dt><dd><pre·class="screen">penwidth·X</pre><p> |
157 | ······<strong·class="userinput"><code>penwidth</code></strong>·sets·the·width·of·the·pen·(the·line·width)·to·an·amount·of·X·<a·class="glossterm"·href="Glossary.html#pixels"><em·class="glossterm">pixels</em></a>.·<strong·class="userinput"><code>penwidth</code></strong>·can·be·abbreviated·to·<strong·class="userinput"><code>pw</code></strong>.</p></dd></dl></div><div·class="variablelist"><a·name="setfgcolor"></a><dl><dt><span·class="term">pencolor·(pc)<a·class="indexterm"·name="idp149595576"></a></span></dt><dd><pre·class="screen">pencolor·R,G,B</pre><p> | 157 | ······<strong·class="userinput"><code>penwidth</code></strong>·sets·the·width·of·the·pen·(the·line·width)·to·an·amount·of·X·<a·class="glossterm"·href="Glossary.html#pixels"><em·class="glossterm">pixels</em></a>.·<strong·class="userinput"><code>penwidth</code></strong>·can·be·abbreviated·to·<strong·class="userinput"><code>pw</code></strong>.</p></dd></dl></div><div·class="variablelist"><a·name="setfgcolor"></a><dl><dt><span·class="term">pencolor·(pc)<a·class="indexterm"·name="idp149521848"></a></span></dt><dd><pre·class="screen">pencolor·R,G,B</pre><p> |
158 | ······<strong·class="userinput"><code>pencolor</code></strong>·sets·the·color·of·the·pen.·<strong·class="userinput"><code>pencolor</code></strong>·takes·an·<a·class="glossterm"·href="Glossary.html#rgb"><em·class="glossterm">RGB·combination</em></a>·as·input.·<strong·class="userinput"><code>pencolor</code></strong>·can·be·abbreviated·to·<strong·class="userinput"><code>pc</code></strong>.</p></dd></dl></div></div><div·class="sect2"><div·class="titlepage"><div><div><h3·class="title"><a·name="canvas"></a>Commands·to·control·the·canvas</h3></div></div></div><p>There·are·several·commands·to·control·the·canvas.</p><div·class="variablelist"><a·name="resizecanvas"></a><dl><dt><span·class="term">canvassize·(cs)<a·class="indexterm"·name="idp149601592"></a></span></dt><dd><pre·class="screen">canvassize·X,Y</pre><p> | 158 | ······<strong·class="userinput"><code>pencolor</code></strong>·sets·the·color·of·the·pen.·<strong·class="userinput"><code>pencolor</code></strong>·takes·an·<a·class="glossterm"·href="Glossary.html#rgb"><em·class="glossterm">RGB·combination</em></a>·as·input.·<strong·class="userinput"><code>pencolor</code></strong>·can·be·abbreviated·to·<strong·class="userinput"><code>pc</code></strong>.</p></dd></dl></div></div><div·class="sect2"><div·class="titlepage"><div><div><h3·class="title"><a·name="canvas"></a>Commands·to·control·the·canvas</h3></div></div></div><p>There·are·several·commands·to·control·the·canvas.</p><div·class="variablelist"><a·name="resizecanvas"></a><dl><dt><span·class="term">canvassize·(cs)<a·class="indexterm"·name="idp149581112"></a></span></dt><dd><pre·class="screen">canvassize·X,Y</pre><p> |
159 | ······With·the·<strong·class="userinput"><code>canvassize</code></strong>·command·you·can·set·the·size·of·the·canvas.·It·takes·X·and·Y·as·input,·where·X·is·the·new·canvas·width·in·<a·class="glossterm"·href="Glossary.html#pixels"><em·class="glossterm">pixels</em></a>,·and·Y·is·the·new·height·of·the·canvas·in·<a·class="glossterm"·href="Glossary.html#pixels"><em·class="glossterm">pixels</em></a>.·<strong·class="userinput"><code>canvassize</code></strong>·can·be·abbreviated·to·<strong·class="userinput"><code>cs</code></strong>.</p></dd></dl></div><div·class="variablelist"><a·name="setbgcolor"></a><dl><dt><span·class="term">canvascolor·(cc)<a·class="indexterm"·name="idp149606456"></a></span></dt><dd><pre·class="screen">canvascolor·R,G,B</pre><p> | 159 | ······With·the·<strong·class="userinput"><code>canvassize</code></strong>·command·you·can·set·the·size·of·the·canvas.·It·takes·X·and·Y·as·input,·where·X·is·the·new·canvas·width·in·<a·class="glossterm"·href="Glossary.html#pixels"><em·class="glossterm">pixels</em></a>,·and·Y·is·the·new·height·of·the·canvas·in·<a·class="glossterm"·href="Glossary.html#pixels"><em·class="glossterm">pixels</em></a>.·<strong·class="userinput"><code>canvassize</code></strong>·can·be·abbreviated·to·<strong·class="userinput"><code>cs</code></strong>.</p></dd></dl></div><div·class="variablelist"><a·name="setbgcolor"></a><dl><dt><span·class="term">canvascolor·(cc)<a·class="indexterm"·name="idp149585976"></a></span></dt><dd><pre·class="screen">canvascolor·R,G,B</pre><p> |
160 | ······<strong·class="userinput"><code>canvascolor</code></strong>·set·the·color·of·the·canvas.·<strong·class="userinput"><code>canvascolor</code></strong>·takes·an·<a·class="glossterm"·href="Glossary.html#rgb"><em·class="glossterm">RGB·combination</em></a>·as·input.·<strong·class="userinput"><code>canvascolor</code></strong>·can·be·abbreviated·to·<strong·class="userinput"><code>cc</code></strong>.</p></dd></dl></div></div><div·class="sect2"><div·class="titlepage"><div><div><h3·class="title"><a·name="clean"></a>Commands·to·clean·up</h3></div></div></div><p>There·are·two·commands·to·clean·up·the·canvas·after·you·have·made·a·mess.</p><div·class="variablelist"><a·name="clear"></a><dl><dt><span·class="term">clear·(ccl)<a·class="indexterm"·name="idp149612472"></a></span></dt><dd><pre·class="screen">clear</pre><p> | 160 | ······<strong·class="userinput"><code>canvascolor</code></strong>·set·the·color·of·the·canvas.·<strong·class="userinput"><code>canvascolor</code></strong>·takes·an·<a·class="glossterm"·href="Glossary.html#rgb"><em·class="glossterm">RGB·combination</em></a>·as·input.·<strong·class="userinput"><code>canvascolor</code></strong>·can·be·abbreviated·to·<strong·class="userinput"><code>cc</code></strong>.</p></dd></dl></div></div><div·class="sect2"><div·class="titlepage"><div><div><h3·class="title"><a·name="clean"></a>Commands·to·clean·up</h3></div></div></div><p>There·are·two·commands·to·clean·up·the·canvas·after·you·have·made·a·mess.</p><div·class="variablelist"><a·name="clear"></a><dl><dt><span·class="term">clear·(ccl)<a·class="indexterm"·name="idp149591992"></a></span></dt><dd><pre·class="screen">clear</pre><p> |
161 | ······With·<strong·class="userinput"><code>clear</code></strong>·you·can·clean·all·drawings·from·the·canvas.·All·other·things·remain:·the·position·and·angle·of·the·turtle,·the·canvascolor,·the·visibility·of·the·turtle,·and·the·canvas·size.</p></dd></dl></div><div·class="variablelist"><a·name="reset"></a><dl><dt><span·class="term">reset<a·class="indexterm"·name="idp149615544"></a></span></dt><dd><pre·class="screen">reset</pre><p> | 161 | ······With·<strong·class="userinput"><code>clear</code></strong>·you·can·clean·all·drawings·from·the·canvas.·All·other·things·remain:·the·position·and·angle·of·the·turtle,·the·canvascolor,·the·visibility·of·the·turtle,·and·the·canvas·size.</p></dd></dl></div><div·class="variablelist"><a·name="reset"></a><dl><dt><span·class="term">reset<a·class="indexterm"·name="idp149595064"></a></span></dt><dd><pre·class="screen">reset</pre><p> |
162 | ······<strong·class="userinput"><code>reset</code></strong>·cleans·much·more·thoroughly·than·the·<strong·class="userinput"><code>clear</code></strong>·command.·After·a·<strong·class="userinput"><code>reset</code></strong>·command·everything·is·like·is·was·when·you·had·just·started·<span·class="application">KTurtle</span>.·The·turtle·is·positioned·at·the·middle·of·the·screen,·the·canvas·color·is·white,·the·turtle·draws·a·black·line·on·the·canvas·and·the·canvassize·is·set·to·400·x·400·pixels.</p></dd></dl></div></div><div·class="sect2"><div·class="titlepage"><div><div><h3·class="title"><a·name="sprites"></a>The·turtle·is·a·sprite</h3></div></div></div><p>First·a·brief·explanation·of·what·sprites·are:·sprites·are·small·pictures·that·can·be·moved·around·the·screen,·like·we·often·see·in·computer·games.·Our·turtle·is·also·a·sprite.·For·more·info·see·the·glossary·on·<a·class="glossterm"·href="commands.html#sprites"><em·class="glossterm">sprites</em></a>.·</p><p>Next·you·will·find·a·full·overview·on·all·commands·to·w·✂ | 162 | ······<strong·class="userinput"><code>reset</code></strong>·cleans·much·more·thoroughly·than·the·<strong·class="userinput"><code>clear</code></strong>·command.·After·a·<strong·class="userinput"><code>reset</code></strong>·command·everything·is·like·is·was·when·you·had·just·started·<span·class="application">KTurtle</span>.·The·turtle·is·positioned·at·the·middle·of·the·screen,·the·canvas·color·is·white,·the·turtle·draws·a·black·line·on·the·canvas·and·the·canvassize·is·set·to·400·x·400·pixels.</p></dd></dl></div></div><div·class="sect2"><div·class="titlepage"><div><div><h3·class="title"><a·name="sprites"></a>The·turtle·is·a·sprite</h3></div></div></div><p>First·a·brief·explanation·of·what·sprites·are:·sprites·are·small·pictures·that·can·be·moved·around·the·screen,·like·we·often·see·in·computer·games.·Our·turtle·is·also·a·sprite.·For·more·info·see·the·glossary·on·<a·class="glossterm"·href="commands.html#sprites"><em·class="glossterm">sprites</em></a>.·</p><p>Next·you·will·find·a·full·overview·on·all·commands·to·w·✂ |
163 | ······<strong·class="userinput"><code>spriteshow</code></strong>·makes·the·turtle·visible·again·after·it·has·been·hidden.·<strong·class="userinput"><code>spriteshow</code></strong>·can·be·abbreviated·to·<strong·class="userinput"><code>ss</code></strong>.</p></dd></dl></div><div·class="variablelist"><a·name="spritehide"></a><dl><dt><span·class="term">spritehide·(sh)<a·class="indexterm"·name="idp149626552"></a></span></dt><dd><pre·class="screen">spritehide</pre><p> | 163 | ······<strong·class="userinput"><code>spriteshow</code></strong>·makes·the·turtle·visible·again·after·it·has·been·hidden.·<strong·class="userinput"><code>spriteshow</code></strong>·can·be·abbreviated·to·<strong·class="userinput"><code>ss</code></strong>.</p></dd></dl></div><div·class="variablelist"><a·name="spritehide"></a><dl><dt><span·class="term">spritehide·(sh)<a·class="indexterm"·name="idp149606072"></a></span></dt><dd><pre·class="screen">spritehide</pre><p> |
164 | ······<strong·class="userinput"><code>spritehide</code></strong>·hides·the·turtle.·This·can·be·used·if·the·turtle·does·not·fit·in·your·drawing.·<strong·class="userinput"><code>spritehide</code></strong>·can·be·abbreviated·to·<strong·class="userinput"><code>sh</code></strong>.</p></dd></dl></div></div><div·class="sect2"><div·class="titlepage"><div><div><h3·class="title"><a·name="writing"></a>Can·the·turtle·write?</h3></div></div></div><p>The·answer·is:·<span·class="quote">“<span·class="quote">yes</span>”</span>.·The·turtle·can·write:·it·writes·just·about·everything·you·command·it·to.</p><div·class="variablelist"><a·name="print"></a><dl><dt><span·class="term">print<a·class="indexterm"·name="idp149632056"></a></span></dt><dd><pre·class="screen">print·X</pre><p> | 164 | ······<strong·class="userinput"><code>spritehide</code></strong>·hides·the·turtle.·This·can·be·used·if·the·turtle·does·not·fit·in·your·drawing.·<strong·class="userinput"><code>spritehide</code></strong>·can·be·abbreviated·to·<strong·class="userinput"><code>sh</code></strong>.</p></dd></dl></div></div><div·class="sect2"><div·class="titlepage"><div><div><h3·class="title"><a·name="writing"></a>Can·the·turtle·write?</h3></div></div></div><p>The·answer·is:·<span·class="quote">“<span·class="quote">yes</span>”</span>.·The·turtle·can·write:·it·writes·just·about·everything·you·command·it·to.</p><div·class="variablelist"><a·name="print"></a><dl><dt><span·class="term">print<a·class="indexterm"·name="idp149611576"></a></span></dt><dd><pre·class="screen">print·X</pre><p> |
165 | ······The·<strong·class="userinput"><code>print</code></strong>·command·is·used·to·command·the·turtle·to·write·something·on·the·canvas.·<strong·class="userinput"><code>print</code></strong>·takes·numbers·and·strings·as·input.·You·can·<strong·class="userinput"><code>print</code></strong>·various·numbers·and·strings·using·the·<span·class="quote">“<span·class="quote">+</span>”</span>·symbol.·See·here·a·small·example: | 165 | ······The·<strong·class="userinput"><code>print</code></strong>·command·is·used·to·command·the·turtle·to·write·something·on·the·canvas.·<strong·class="userinput"><code>print</code></strong>·takes·numbers·and·strings·as·input.·You·can·<strong·class="userinput"><code>print</code></strong>·various·numbers·and·strings·using·the·<span·class="quote">“<span·class="quote">+</span>”</span>·symbol.·See·here·a·small·example: |
166 | </p><pre·class="screen"> | 166 | </p><pre·class="screen"> |
167 | $year·=·2003 | 167 | $year·=·2003 |
168 | $author·=·"Cies" | 168 | $author·=·"Cies" |
169 | print·$author·+·"·started·the·KTurtle·project·in·"·+·$year·+·"·and·still·enjoys·working·on·it!" | 169 | print·$author·+·"·started·the·KTurtle·project·in·"·+·$year·+·"·and·still·enjoys·working·on·it!" |
170 | </pre><p> | 170 | </pre><p> |
171 | ······</p></dd></dl></div><div·class="variablelist"><a·name="fontsize"></a><dl><dt><span·class="term">fontsize<a·class="indexterm"·name="idp149636792"></a></span></dt><dd><pre·class="screen">fontsize·X</pre><p> | 171 | ······</p></dd></dl></div><div·class="variablelist"><a·name="fontsize"></a><dl><dt><span·class="term">fontsize<a·class="indexterm"·name="idp149616312"></a></span></dt><dd><pre·class="screen">fontsize·X</pre><p> |
172 | ······<strong·class="userinput"><code>fontsize</code></strong>·sets·the·size·of·the·font·that·is·used·by·<strong·class="userinput"><code>print</code></strong>.·<strong·class="userinput"><code>fontsize</code></strong>·takes·one·input·which·should·be·a·number.·The·size·is·set·in·<a·class="glossterm"·href="Glossary.html#pixels"><em·class="glossterm">pixels</em></a>.</p></dd></dl></div></div><div·class="sect2"><div·class="titlepage"><div><div><h3·class="title"><a·name="math-commands"></a>Mathematical·commands</h3></div></div></div><p>The·following·commands·are·<span·class="application">KTurtle</span>'s·more·advanced·mathematical·commands.</p><div·class="variablelist"><a·name="round"></a><dl><dt><span·class="term">round<a·class="indexterm"·name="idp149642808"></a></span></dt><dd><pre·class="screen">round(x)</pre><p> | 172 | ······<strong·class="userinput"><code>fontsize</code></strong>·sets·the·size·of·the·font·that·is·used·by·<strong·class="userinput"><code>print</code></strong>.·<strong·class="userinput"><code>fontsize</code></strong>·takes·one·input·which·should·be·a·number.·The·size·is·set·in·<a·class="glossterm"·href="Glossary.html#pixels"><em·class="glossterm">pixels</em></a>.</p></dd></dl></div></div><div·class="sect2"><div·class="titlepage"><div><div><h3·class="title"><a·name="math-commands"></a>Mathematical·commands</h3></div></div></div><p>The·following·commands·are·<span·class="application">KTurtle</span>'s·more·advanced·mathematical·commands.</p><div·class="variablelist"><a·name="round"></a><dl><dt><span·class="term">round<a·class="indexterm"·name="idp149622328"></a></span></dt><dd><pre·class="screen">round(x)</pre><p> |
173 | ······<strong·class="userinput"><code>round</code></strong>·the·given·number·to·the·nearest·integer. | 173 | ······<strong·class="userinput"><code>round</code></strong>·the·given·number·to·the·nearest·integer. |
174 | </p><pre·class="screen"> | 174 | </p><pre·class="screen"> |
175 | print·round(10.8) | 175 | print·round(10.8) |
176 | forward·20 | 176 | forward·20 |
177 | print·round(10.3) | 177 | print·round(10.3) |
178 | </pre><p> | 178 | </pre><p> |
179 | ······With·this·code·the·turtle·will·print·the·numbers·11·and·10.</p></dd></dl></div><div·class="variablelist"><a·name="random"></a><dl><dt><span·class="term">random·(rnd)<a·class="indexterm"·name="idp149646264"></a></span></dt><dd><pre·class="screen">random·X,Y</pre><p> | 179 | ······With·this·code·the·turtle·will·print·the·numbers·11·and·10.</p></dd></dl></div><div·class="variablelist"><a·name="random"></a><dl><dt><span·class="term">random·(rnd)<a·class="indexterm"·name="idp149629880"></a></span></dt><dd><pre·class="screen">random·X,Y</pre><p> |
180 | ······<strong·class="userinput"><code>random</code></strong>·is·a·command·that·takes·input·and·gives·output.·As·input·are·required·two·numbers,·the·first·(X)·sets·the·minimum·output,·the·second·(Y)·sets·the·maximum.·The·output·is·a·randomly·chosen·number·that·is·equal·or·greater·than·the·minimum·and·equal·or·smaller·than·the·maximum.·Here·a·small·example: | 180 | ······<strong·class="userinput"><code>random</code></strong>·is·a·command·that·takes·input·and·gives·output.·As·input·are·required·two·numbers,·the·first·(X)·sets·the·minimum·output,·the·second·(Y)·sets·the·maximum.·The·output·is·a·randomly·chosen·number·that·is·equal·or·greater·than·the·minimum·and·equal·or·smaller·than·the·maximum.·Here·a·small·example: |
181 | ······</p><pre·class="screen"> | 181 | ······</p><pre·class="screen"> |
182 | repeat·500·{ | 182 | repeat·500·{ |
183 | ··$x·=·random·1,20 | 183 | ··$x·=·random·1,20 |
184 | ··forward·$x | 184 | ··forward·$x |
185 | ··turnleft·10·-·$x | 185 | ··turnleft·10·-·$x |
186 | } | 186 | } |
187 | </pre><p> | 187 | </pre><p> |
188 | ······Using·the·<strong·class="userinput"><code>random</code></strong>·command·you·can·add·a·bit·of·chaos·to·your·program.</p></dd></dl></div><div·class="variablelist"><a·name="mod"></a><dl><dt><span·class="term">mod<a·class="indexterm"·name="idp149650104"></a></span></dt><dd><pre·class="screen">mod·X,Y</pre><p> | 188 | ······Using·the·<strong·class="userinput"><code>random</code></strong>·command·you·can·add·a·bit·of·chaos·to·your·program.</p></dd></dl></div><div·class="variablelist"><a·name="mod"></a><dl><dt><span·class="term">mod<a·class="indexterm"·name="idp149633720"></a></span></dt><dd><pre·class="screen">mod·X,Y</pre><p> |
189 | ······The·<strong·class="userinput"><code>mod</code></strong>·returns·remainder·of·the·division·of·first·number·by·the·second·number.</p></dd></dl></div><div·class="variablelist"><a·name="sqrt"></a><dl><dt><span·class="term">sqrt<a·class="indexterm"·name="idp149653176"></a></span></dt><dd><pre·class="screen">sqrt·X</pre><p> | 189 | ······The·<strong·class="userinput"><code>mod</code></strong>·returns·remainder·of·the·division·of·first·number·by·the·second·number.</p></dd></dl></div><div·class="variablelist"><a·name="sqrt"></a><dl><dt><span·class="term">sqrt<a·class="indexterm"·name="idp149636792"></a></span></dt><dd><pre·class="screen">sqrt·X</pre><p> |
190 | ······The·<strong·class="userinput"><code>sqrt</code></strong>·command·is·sued·to·find·the·square·root·of·a·number,·X.</p></dd></dl></div><div·class="variablelist"><a·name="pi"></a><dl><dt><span·class="term">pi<a·class="indexterm"·name="idp149660600"></a></span></dt><dd><pre·class="screen">pi</pre><p> | 190 | ······The·<strong·class="userinput"><code>sqrt</code></strong>·command·is·sued·to·find·the·square·root·of·a·number,·X.</p></dd></dl></div><div·class="variablelist"><a·name="pi"></a><dl><dt><span·class="term">pi<a·class="indexterm"·name="idp149640120"></a></span></dt><dd><pre·class="screen">pi</pre><p> |
191 | ······This·command·returns·the·constant·Pi,·<strong·class="userinput"><code>3.14159</code></strong>.</p></dd></dl></div><div·class="variablelist"><a·name="sin"></a><a·name="cos"></a><a·name="tan"></a><dl><dt><span·class="term">sin<a·class="indexterm"·name="idp149664440"></a>,·cos<a·class="indexterm"·name="idp149664952"></a>,·tan<a·class="indexterm"·name="idp149665464"></a></span></dt><dd><p> | 191 | ······This·command·returns·the·constant·Pi,·<strong·class="userinput"><code>3.14159</code></strong>.</p></dd></dl></div><div·class="variablelist"><a·name="sin"></a><a·name="cos"></a><a·name="tan"></a><dl><dt><span·class="term">sin<a·class="indexterm"·name="idp149643960"></a>,·cos<a·class="indexterm"·name="idp149644472"></a>,·tan<a·class="indexterm"·name="idp149644984"></a></span></dt><dd><p> |
192 | </p><pre·class="screen"> | 192 | </p><pre·class="screen"> |
193 | sin·X | 193 | sin·X |
194 | cos·X | 194 | cos·X |
195 | tan·X | 195 | tan·X |
196 | </pre><p> | 196 | </pre><p> |
197 | ······These·three·commands·represent·the·world·famous·trigoniometrical·functions·<strong·class="userinput"><code>sin</code></strong>,·<strong·class="userinput"><code>cos</code></strong>·and·<strong·class="userinput"><code>tan</code></strong>.·The·input·argument·of·these·commands,·X,·is·a·<a·class="link"·href="reference.html#number"·title="Numbers">number</a>.</p></dd></dl></div><div·class="variablelist"><a·name="arcsin"></a><a·name="arccos"></a><a·name="arctan"></a><dl><dt><span·class="term">arcsin<a·class="indexterm"·name="idp149670712"></a>,·arccos<a·class="indexterm"·name="idp149671224"></a>,·arctan<a·class="indexterm"·name="idp149671736"></a></span></dt><dd><p> | 197 | ······These·three·commands·represent·the·world·famous·trigoniometrical·functions·<strong·class="userinput"><code>sin</code></strong>,·<strong·class="userinput"><code>cos</code></strong>·and·<strong·class="userinput"><code>tan</code></strong>.·The·input·argument·of·these·commands,·X,·is·a·<a·class="link"·href="reference.html#number"·title="Numbers">number</a>.</p></dd></dl></div><div·class="variablelist"><a·name="arcsin"></a><a·name="arccos"></a><a·name="arctan"></a><dl><dt><span·class="term">arcsin<a·class="indexterm"·name="idp149650232"></a>,·arccos<a·class="indexterm"·name="idp149650744"></a>,·arctan<a·class="indexterm"·name="idp149651256"></a></span></dt><dd><p> |
198 | </p><pre·class="screen"> | 198 | </p><pre·class="screen"> |
199 | arcsin·X | 199 | arcsin·X |
200 | arccos·X | 200 | arccos·X |
201 | arctan·X | 201 | arctan·X |
202 | </pre><p> | 202 | </pre><p> |
203 | ······These·commands·are·the·inverse·functions·of·<a·class="link"·href="commands.html#sin">sin</a>,·<a·class="link"·href="commands.html#cos">cos</a>·and·<a·class="link"·href="commands.html#tan">tan</a>.·The·input·argument·of·these·commands,·X,·is·a·<a·class="link"·href="reference.html#number"·title="Numbers">number</a>.</p></dd></dl></div></div><div·class="sect2"><div·class="titlepage"><div><div><h3·class="title"><a·name="dialogs"></a>Input·and·feedback·through·dialogs</h3></div></div></div><p>A·dialog·is·a·small·pop-up·window·that·provides·some·feedback·or·asks·for·some·input.·<span·class="application">KTurtle</span>·has·two·commands·for·dialogs,·namely:·<strong·class="userinput"><code>message</code></strong>·and·<strong·class="userinput"><code>ask</code></strong></p><div·class="variablelist"><a·name="message"></a><dl><dt><span·class="term">message<a·class="indexterm"·name="idp149683000"></a></span></dt><dd><pre·class="screen">message·X</pre><p> | 203 | ······These·commands·are·the·inverse·functions·of·<a·class="link"·href="commands.html#sin">sin</a>,·<a·class="link"·href="commands.html#cos">cos</a>·and·<a·class="link"·href="commands.html#tan">tan</a>.·The·input·argument·of·these·commands,·X,·is·a·<a·class="link"·href="reference.html#number"·title="Numbers">number</a>.</p></dd></dl></div></div><div·class="sect2"><div·class="titlepage"><div><div><h3·class="title"><a·name="dialogs"></a>Input·and·feedback·through·dialogs</h3></div></div></div><p>A·dialog·is·a·small·pop-up·window·that·provides·some·feedback·or·asks·for·some·input.·<span·class="application">KTurtle</span>·has·two·commands·for·dialogs,·namely:·<strong·class="userinput"><code>message</code></strong>·and·<strong·class="userinput"><code>ask</code></strong></p><div·class="variablelist"><a·name="message"></a><dl><dt><span·class="term">message<a·class="indexterm"·name="idp149658424"></a></span></dt><dd><pre·class="screen">message·X</pre><p> |
204 | ······The·<strong·class="userinput"><code>message</code></strong>·command·takes·a·<a·class="link"·href="reference.html#string"·title="Strings">string</a>·as·input.·It·shows·a·pop-up·dialog·containing·the·text·from·the·<a·class="link"·href="reference.html#string"·title="Strings">string</a>. | 204 | ······The·<strong·class="userinput"><code>message</code></strong>·command·takes·a·<a·class="link"·href="reference.html#string"·title="Strings">string</a>·as·input.·It·shows·a·pop-up·dialog·containing·the·text·from·the·<a·class="link"·href="reference.html#string"·title="Strings">string</a>. |
205 | </p><pre·class="screen"> | 205 | </p><pre·class="screen"> |
206 | message·"Cies·started·KTurtle·in·2003·and·still·enjoys·working·on·it!" | 206 | message·"Cies·started·KTurtle·in·2003·and·still·enjoys·working·on·it!" |
207 | </pre><p> | 207 | </pre><p> |
208 | ······</p></dd></dl></div><div·class="variablelist"><a·name="ask"></a><dl><dt><span·class="term">ask<a·class="indexterm"·name="idp149687480"></a></span></dt><dd><pre·class="screen">ask·X</pre><p> | 208 | ······</p></dd></dl></div><div·class="variablelist"><a·name="ask"></a><dl><dt><span·class="term">ask<a·class="indexterm"·name="idp149662904"></a></span></dt><dd><pre·class="screen">ask·X</pre><p> |
209 | ······<strong·class="userinput"><code>ask</code></strong>·takes·a·<a·class="link"·href="reference.html#string"·title="Strings">string</a>·as·input.··It·shows·this·string·in·a·pop-up·dialog·(similar·to·<a·class="link"·href="commands.html#message">message</a>),·along·with·an·input·field.··After·the·user·has·entered·a·<a·class="link"·href="reference.html#number"·title="Numbers">number</a>·or·a·<a·class="link"·href="reference.html#string"·title="Strings">string</a>·into·this,·the·result·can·be·stored·in·a·<a·class="link"·href="assignment-of-variables.html"·title="Assignment·of·variables">variable</a>·or·passed·as·an·argument·to·a·<a·class="link"·href="commands.html"·title="Commands">command</a>.·For·example: | 209 | ······<strong·class="userinput"><code>ask</code></strong>·takes·a·<a·class="link"·href="reference.html#string"·title="Strings">string</a>·as·input.··It·shows·this·string·in·a·pop-up·dialog·(similar·to·<a·class="link"·href="commands.html#message">message</a>),·along·with·an·input·field.··After·the·user·has·entered·a·<a·class="link"·href="reference.html#number"·title="Numbers">number</a>·or·a·<a·class="link"·href="reference.html#string"·title="Strings">string</a>·into·this,·the·result·can·be·stored·in·a·<a·class="link"·href="assignment-of-variables.html"·title="Assignment·of·variables">variable</a>·or·passed·as·an·argument·to·a·<a·class="link"·href="commands.html"·title="Commands">command</a>.·For·example: |
210 | </p><pre·class="screen"> | 210 | </p><pre·class="screen"> |
211 | $in·=·ask·"What·is·your·year·of·birth?" | 211 | $in·=·ask·"What·is·your·year·of·birth?" |
212 | $out·=·2003·-·$in | 212 | $out·=·2003·-·$in |
213 | print·"In·2003·you·were·"·+·$out·+·"·years·old·at·some·point." | 213 | print·"In·2003·you·were·"·+·$out·+·"·years·old·at·some·point." |
214 | </pre><p> | 214 | </pre><p> |
215 | ······If·the·user·cancels·the·input·dialog,·or·does·not·enter·anything·at·all,·the·<a·class="link"·href="assignment-of-variables.html"·title="Assignment·of·variables">variable</a>·is·empty.</p></dd></dl></div></div></div></div><div·id="footer"><div·class="navCenter"><table·class="navigation"><tr><td·class="prevCell"><a·accesskey="p"·href="operators.html">Prev</a></td><td·class="upCell"><a·accesskey="h"·href="index.html">Contents</a></td><td·class="nextCell"><a·accesskey="n"·href="assignment-of-variables.html">Next</a></td></tr><tr><td·class="prevCell">Mathematical,·boolean·and·comparing·operators </td><td·class="upCell">TurtleScript·Programming·Reference</td><td·class="nextCell"> Assignment·of·variables</td></tr></table></div><div·id="footer_text">Would·you·like·to·make·a·comment·or·contribute·an·update·to·this·page?<br>Send·feedback·to·the·<a·href="mailto:kde-doc-english@kde.org"·class="footer_email">KDE·Docs·Team</a></div></div></div></body></html></FILENAME><FILENAME·filename="assignment-of-variables.html"·✂ | 215 | ······If·the·user·cancels·the·input·dialog,·or·does·not·enter·anything·at·all,·the·<a·class="link"·href="assignment-of-variables.html"·title="Assignment·of·variables">variable</a>·is·empty.</p></dd></dl></div></div></div></div><div·id="footer"><div·class="navCenter"><table·class="navigation"><tr><td·class="prevCell"><a·accesskey="p"·href="operators.html">Prev</a></td><td·class="upCell"><a·accesskey="h"·href="index.html">Contents</a></td><td·class="nextCell"><a·accesskey="n"·href="assignment-of-variables.html">Next</a></td></tr><tr><td·class="prevCell">Mathematical,·boolean·and·comparing·operators </td><td·class="upCell">TurtleScript·Programming·Reference</td><td·class="nextCell"> Assignment·of·variables</td></tr></table></div><div·id="footer_text">Would·you·like·to·make·a·comment·or·contribute·an·update·to·this·page?<br>Send·feedback·to·the·<a·href="mailto:kde-doc-english@kde.org"·class="footer_email">KDE·Docs·Team</a></div></div></div></body></html></FILENAME><FILENAME·filename="assignment-of-variables.html"·✂ |
Offset 238, 68 lines modified | Offset 238, 68 lines modified |
238 | In·the·first·two·lines·the·variables·<strong·class="userinput"><code>$a</code></strong>·and·<strong·class="userinput"><code>$b</code></strong>·are·set·to·2004·and·25.·Then·in·two·<strong·class="userinput"><code>print</code></strong>·commands·with·a·<strong·class="userinput"><code>backward·30</code></strong>·in·between·are·executed.·The·comments·before·the·<strong·class="userinput"><code>print</code></strong>·commands·explain·what·they·are·doing.·The·command·<strong·class="userinput"><code>backward·30</code></strong>·is·there·to·make· | 238 | In·the·first·two·lines·the·variables·<strong·class="userinput"><code>$a</code></strong>·and·<strong·class="userinput"><code>$b</code></strong>·are·set·to·2004·and·25.·Then·in·two·<strong·class="userinput"><code>print</code></strong>·commands·with·a·<strong·class="userinput"><code>backward·30</code></strong>·in·between·are·executed.·The·comments·before·the·<strong·class="userinput"><code>print</code></strong>·commands·explain·what·they·are·doing.·The·command·<strong·class="userinput"><code>backward·30</code></strong>·is·there·to·make· |
239 | sure·every·output·is·on·a·new·line. | 239 | sure·every·output·is·on·a·new·line. |
240 | As·you·see·variables·can·be·used·just·as·if·their·where·what·they·contain,·you·can·use·them·with·any·kind·of·<a·class="link"·href="operators.html"·title="Mathematical,·boolean·and·comparing·operators">operators</a>·or·give·them·as·input·when·invoking·<a·class="link"·href="commands.html"·title="Commands">commands</a>.</p><p>One·more·example: | 240 | As·you·see·variables·can·be·used·just·as·if·their·where·what·they·contain,·you·can·use·them·with·any·kind·of·<a·class="link"·href="operators.html"·title="Mathematical,·boolean·and·comparing·operators">operators</a>·or·give·them·as·input·when·invoking·<a·class="link"·href="commands.html"·title="Commands">commands</a>.</p><p>One·more·example: |
241 | </p><pre·class="screen"> | 241 | </p><pre·class="screen"> |
242 | $name·=·ask·"What·is·your·name?" | 242 | $name·=·ask·"What·is·your·name?" |
243 | print·"Hi·"·+·$name·+·"!·Good·luck·while·learning·the·art·of·programming..." | 243 | print·"Hi·"·+·$name·+·"!·Good·luck·while·learning·the·art·of·programming..." |
244 | </pre><p> | 244 | </pre><p> |
245 | Pretty·straight·forward.·Again·you·can·see·that·the·variable·<strong·class="userinput"><code>$name</code></strong>,·treated·just·like·a·string.</p><p>When·using·variables·the·<a·class="link"·href="the-inspector.html"·title="The·Inspector">inspector</a>·is·very·helpful.·It·shows·you·the·contents·of·all·variables·that·are·currently·in·use.</p></div></div><div·id="footer"><div·class="navCenter"><table·class="navigation"><tr><td·class="prevCell"><a·accesskey="p"·href="commands.html">Prev</a></td><td·class="upCell"><a·accesskey="h"·href="index.html">Contents</a></td><td·class="nextCell"><a·accesskey="n"·href="controlling-execution.html">Next</a></td></tr><tr><td·class="prevCell">Commands </td><td·class="upCell">TurtleScript·Programming·Reference</td><td·class="nextCell"> Controlling·execution</td></tr></table></div><div·id="footer_text">Would·you·like·to·make·a·comment·or·contribute·an·update·to·this·page?<br>Send·feedback·to·the·<a·href="mailto:kde-doc-english@kde.org"·class="footer_email">KDE·Docs·Team</a></div>·✂ | 245 | Pretty·straight·forward.·Again·you·can·see·that·the·variable·<strong·class="userinput"><code>$name</code></strong>,·treated·just·like·a·string.</p><p>When·using·variables·the·<a·class="link"·href="the-inspector.html"·title="The·Inspector">inspector</a>·is·very·helpful.·It·shows·you·the·contents·of·all·variables·that·are·currently·in·use.</p></div></div><div·id="footer"><div·class="navCenter"><table·class="navigation"><tr><td·class="prevCell"><a·accesskey="p"·href="commands.html">Prev</a></td><td·class="upCell"><a·accesskey="h"·href="index.html">Contents</a></td><td·class="nextCell"><a·accesskey="n"·href="controlling-execution.html">Next</a></td></tr><tr><td·class="prevCell">Commands </td><td·class="upCell">TurtleScript·Programming·Reference</td><td·class="nextCell"> Controlling·execution</td></tr></table></div><div·id="footer_text">Would·you·like·to·make·a·comment·or·contribute·an·update·to·this·page?<br>Send·feedback·to·the·<a·href="mailto:kde-doc-english@kde.org"·class="footer_email">KDE·Docs·Team</a></div>·✂ |
246 | ······<strong·class="userinput"><code>wait</code></strong>·makes·the·turtle·wait·for·X·seconds. | 246 | ······<strong·class="userinput"><code>wait</code></strong>·makes·the·turtle·wait·for·X·seconds. |
247 | </p><pre·class="screen"> | 247 | </p><pre·class="screen"> |
248 | repeat·36·{ | 248 | repeat·36·{ |
249 | ··forward·5 | 249 | ··forward·5 |
250 | ··turnright·10 | 250 | ··turnright·10 |
251 | ··wait·0.5 | 251 | ··wait·0.5 |
252 | } | 252 | } |
253 | </pre><p> | 253 | </pre><p> |
254 | ······This·code·draws·a·circle,·but·the·turtle·will·wait·half·a·second | 254 | ······This·code·draws·a·circle,·but·the·turtle·will·wait·half·a·second |
255 | ······after·each·step.·This·gives·the·impression·of·a·slow-moving·turtle.</p></dd></dl></div></div><div·class="sect2"><div·class="titlepage"><div><div><h3·class="title"><a·name="if"></a>Execute·"if"</h3></div></div></div><div·class="variablelist"><dl><dt><span·class="term">if<a·class="indexterm"·name="idp149747512"></a></span></dt><dd><pre·class="screen">if·<a·class="link"·href="reference.html#boolean-value"·title="Boolean·(true/false)·values">boolean</a>·{·...·}</pre><p> | 255 | ······after·each·step.·This·gives·the·impression·of·a·slow-moving·turtle.</p></dd></dl></div></div><div·class="sect2"><div·class="titlepage"><div><div><h3·class="title"><a·name="if"></a>Execute·"if"</h3></div></div></div><div·class="variablelist"><dl><dt><span·class="term">if<a·class="indexterm"·name="idp149706552"></a></span></dt><dd><pre·class="screen">if·<a·class="link"·href="reference.html#boolean-value"·title="Boolean·(true/false)·values">boolean</a>·{·...·}</pre><p> |
256 | ······The·code·that·is·placed·between·the·brackets·will·only·be·executed·<strong·class="userinput"><code>if</code></strong>·the·<a·class="link"·href="reference.html#boolean-value"·title="Boolean·(true/false)·values">boolean·value</a>·evaluates·<span·class="quote">“<span·class="quote">true</span>”</span>. | 256 | ······The·code·that·is·placed·between·the·brackets·will·only·be·executed·<strong·class="userinput"><code>if</code></strong>·the·<a·class="link"·href="reference.html#boolean-value"·title="Boolean·(true/false)·values">boolean·value</a>·evaluates·<span·class="quote">“<span·class="quote">true</span>”</span>. |
257 | ······</p><pre·class="screen"> | 257 | ······</p><pre·class="screen"> |
258 | $x·=·6 | 258 | $x·=·6 |
259 | if·$x·>·5·{ | 259 | if·$x·>·5·{ |
260 | ··print·"$x·is·greater·than·five!" | 260 | ··print·"$x·is·greater·than·five!" |
261 | } | 261 | } |
262 | </pre><p> | 262 | </pre><p> |
263 | ······On·the·first·line·<strong·class="userinput"><code>$x</code></strong>·is·set·to·6.·On·the·second·line·a·<a·class="link"·href="operators.html#comparing-operators"·title="Comparing·operators">comparing·operator</a>·is·used·to·evaluate·<strong·class="userinput"><code>$x·>·5</code></strong>.·Since·this·evaluates·<span·class="quote">“<span·class="quote">true</span>”</span>,·6·is·larger·than·5,·the·execution·controller·<strong·class="userinput"><code>if</code></strong>·will·allow·the·code·between·the·brackets·to·be·executed.</p></dd></dl></div></div><div·class="sect2"><div·class="titlepage"><div><div><h3·class="title"><a·name="else"></a>If·not,·in·other·words:·"else"</h3></div></div></div><div·class="variablelist"><dl><dt><span·class="term">else<a·class="indexterm"·name="idp149754936"></a></span></dt><dd><pre·class="screen">if·<a·class="link"·href="reference.html#boolean-value"·title="Boolean·(true/false)·values">boolean</a>·{·...·}·else·{·...·}</pre><p> | 263 | ······On·the·first·line·<strong·class="userinput"><code>$x</code></strong>·is·set·to·6.·On·the·second·line·a·<a·class="link"·href="operators.html#comparing-operators"·title="Comparing·operators">comparing·operator</a>·is·used·to·evaluate·<strong·class="userinput"><code>$x·>·5</code></strong>.·Since·this·evaluates·<span·class="quote">“<span·class="quote">true</span>”</span>,·6·is·larger·than·5,·the·execution·controller·<strong·class="userinput"><code>if</code></strong>·will·allow·the·code·between·the·brackets·to·be·executed.</p></dd></dl></div></div><div·class="sect2"><div·class="titlepage"><div><div><h3·class="title"><a·name="else"></a>If·not,·in·other·words:·"else"</h3></div></div></div><div·class="variablelist"><dl><dt><span·class="term">else<a·class="indexterm"·name="idp149746744"></a></span></dt><dd><pre·class="screen">if·<a·class="link"·href="reference.html#boolean-value"·title="Boolean·(true/false)·values">boolean</a>·{·...·}·else·{·...·}</pre><p> |
264 | ······<strong·class="userinput"><code>else</code></strong>·can·be·used·in·addition·to·the·execution·controller·<a·class="link"·href="controlling-execution.html#if"·title='Execute·"if"'><strong·class="userinput"><code>if</code></strong></a>.·The·code·between·the·brackets·after·<strong·class="userinput"><code>else</code></strong>·is·only·executed·if·the·<a·class="link"·href="reference.html#boolean-value"·title="Boolean·(true/false)·values">boolean</a>·evaluates·<span·class="quote">“<span·class="quote">false</span>”</span>. | 264 | ······<strong·class="userinput"><code>else</code></strong>·can·be·used·in·addition·to·the·execution·controller·<a·class="link"·href="controlling-execution.html#if"·title='Execute·"if"'><strong·class="userinput"><code>if</code></strong></a>.·The·code·between·the·brackets·after·<strong·class="userinput"><code>else</code></strong>·is·only·executed·if·the·<a·class="link"·href="reference.html#boolean-value"·title="Boolean·(true/false)·values">boolean</a>·evaluates·<span·class="quote">“<span·class="quote">false</span>”</span>. |
265 | ······</p><pre·class="screen"> | 265 | ······</p><pre·class="screen"> |
266 | reset | 266 | reset |
267 | $x·=·4 | 267 | $x·=·4 |
268 | if·$x·>·5·{ | 268 | if·$x·>·5·{ |
269 | ··print·"$x·is·greater·than·five!" | 269 | ··print·"$x·is·greater·than·five!" |
270 | }·else·{ | 270 | }·else·{ |
271 | ··print·"$x·is·smaller·than·six!" | 271 | ··print·"$x·is·smaller·than·six!" |
272 | } | 272 | } |
273 | </pre><p> | 273 | </pre><p> |
274 | ······The·<a·class="link"·href="operators.html#comparing-operators"·title="Comparing·operators">comparing·operator</a>·evaluates·the·expression·<strong·class="userinput"><code>$x·>·5</code></strong>.·Since·4·is·not·greater·than·5·the·expression·evaluates·<span·class="quote">“<span·class="quote">false</span>”</span>.·This·means·the·code·between·the·brackets·after·<strong·class="userinput"><code>else</code></strong>·gets·executed.</p></dd></dl></div></div><div·class="sect2"><div·class="titlepage"><div><div><h3·class="title"><a·name="while"></a>The·"while"·loop</h3></div></div></div><div·class="variablelist"><dl><dt><span·class="term">while<a·class="indexterm"·name="idp149775288"></a></span></dt><dd><pre·class="screen">while·<a·class="link"·href="reference.html#boolean-value"·title="Boolean·(true/false)·values">boolean</a>·{·...·}</pre><p> | 274 | ······The·<a·class="link"·href="operators.html#comparing-operators"·title="Comparing·operators">comparing·operator</a>·evaluates·the·expression·<strong·class="userinput"><code>$x·>·5</code></strong>.·Since·4·is·not·greater·than·5·the·expression·evaluates·<span·class="quote">“<span·class="quote">false</span>”</span>.·This·means·the·code·between·the·brackets·after·<strong·class="userinput"><code>else</code></strong>·gets·executed.</p></dd></dl></div></div><div·class="sect2"><div·class="titlepage"><div><div><h3·class="title"><a·name="while"></a>The·"while"·loop</h3></div></div></div><div·class="variablelist"><dl><dt><span·class="term">while<a·class="indexterm"·name="idp149754808"></a></span></dt><dd><pre·class="screen">while·<a·class="link"·href="reference.html#boolean-value"·title="Boolean·(true/false)·values">boolean</a>·{·...·}</pre><p> |
275 | ······The·execution·controller·<strong·class="userinput"><code>while</code></strong>·is·a·lot·like·<a·class="link"·href="controlling-execution.html#if"·title='Execute·"if"'><strong·class="userinput"><code>if</code></strong></a>.·The·difference·is·that·<strong·class="userinput"><code>while</code></strong>·keeps·repeating·(looping)·the·code·between·the·brackets·until·the·<a·class="link"·href="reference.html#boolean-value"·title="Boolean·(true/false)·values">boolean</a>·evaluates·<span·class="quote">“<span·class="quote">false</span>”</span>. | 275 | ······The·execution·controller·<strong·class="userinput"><code>while</code></strong>·is·a·lot·like·<a·class="link"·href="controlling-execution.html#if"·title='Execute·"if"'><strong·class="userinput"><code>if</code></strong></a>.·The·difference·is·that·<strong·class="userinput"><code>while</code></strong>·keeps·repeating·(looping)·the·code·between·the·brackets·until·the·<a·class="link"·href="reference.html#boolean-value"·title="Boolean·(true/false)·values">boolean</a>·evaluates·<span·class="quote">“<span·class="quote">false</span>”</span>. |
276 | ······</p><pre·class="screen"> | 276 | ······</p><pre·class="screen"> |
277 | $x·=·1 | 277 | $x·=·1 |
278 | while·$x·<·5·{ | 278 | while·$x·<·5·{ |
279 | ··forward·10 | 279 | ··forward·10 |
280 | ··wait·1 | 280 | ··wait·1 |
281 | ··$x·=·$x·+·1 | 281 | ··$x·=·$x·+·1 |
282 | } | 282 | } |
283 | </pre><p> | 283 | </pre><p> |
284 | ······On·the·first·line·<strong·class="userinput"><code>$x</code></strong>·is·set·to·1.·On·the·second·line·<strong·class="userinput"><code>$x·<·5</code></strong>·is·evaluated.·Since·the·answer·to·this·question·is·<span·class="quote">“<span·class="quote">true</span>”</span>·the·execution·controller·<strong·class="userinput"><code>while</code></strong>·starts·executing·the·code·between·the·brackets·until·the·<strong·class="userinput"><code>$x·<·5</code></strong>·evaluates·<span·class="quote">“<span·class="quote">false</span>”</span>.·In·this·case·the·code·between·the·brackets·will·be·executed·4·times,·because·every·time·the·fifth·line·is·executed·<strong·class="userinput"><code>$x</code></strong>·increases·by·1.</p></dd></dl></div></div><div·class="sect2"><div·class="titlepage"><div><div><h3·class="title"><a·name="repeat"></a>The·"repeat"·loop</h3></div></div></div><div·class="variablelist"><dl><dt><span·class="term">repeat<a·class="indexterm"·name="idp149784504"></a></span></dt><dd><pre·class="screen">re·✂ | 284 | ······On·the·first·line·<strong·class="userinput"><code>$x</code></strong>·is·set·to·1.·On·the·second·line·<strong·class="userinput"><code>$x·<·5</code></strong>·is·evaluated.·Since·the·answer·to·this·question·is·<span·class="quote">“<span·class="quote">true</span>”</span>·the·execution·controller·<strong·class="userinput"><code>while</code></strong>·starts·executing·the·code·between·the·brackets·until·the·<strong·class="userinput"><code>$x·<·5</code></strong>·evaluates·<span·class="quote">“<span·class="quote">false</span>”</span>.·In·this·case·the·code·between·the·brackets·will·be·executed·4·times,·because·every·time·the·fifth·line·is·executed·<strong·class="userinput"><code>$x</code></strong>·increases·by·1.</p></dd></dl></div></div><div·class="sect2"><div·class="titlepage"><div><div><h3·class="title"><a·name="repeat"></a>The·"repeat"·loop</h3></div></div></div><div·class="variablelist"><dl><dt><span·class="term">repeat<a·class="indexterm"·name="idp149764024"></a></span></dt><dd><pre·class="screen">re·✂ |
285 | ······The·execution·controller·<strong·class="userinput"><code>repeat</code></strong>·is·a·lot·like·<a·class="link"·href="controlling-execution.html#while"·title='The·"while"·loop'><strong·class="userinput"><code>while</code></strong></a>.·The·difference·is·that·<strong·class="userinput"><code>repeat</code></strong>·keeps·repeating·(looping)·the·code·between·the·brackets·for·as·many·times·as·the·given·number.</p></dd></dl></div></div><div·class="sect2"><div·class="titlepage"><div><div><h3·class="title"><a·name="for"></a>The·"for"·loop,·a·counting·loop</h3></div></div></div><div·class="variablelist"><dl><dt><span·class="term">for<a·class="indexterm"·name="idp143092664"></a><a·class="indexterm"·name="idp143093048"></a></span></dt><dd><pre·class="screen">for·<a·class="link"·href="assignment-of-variables.html"·title="Assignment·of·variables">variable</a>·=·<a·class="link"·href="reference.html#number"·title="Numbers">number</a>·to·<a·class="link"·href="reference.html#number"·title="Numbers">number</a>·{·...·}</pre·✂ | 285 | ······The·execution·controller·<strong·class="userinput"><code>repeat</code></strong>·is·a·lot·like·<a·class="link"·href="controlling-execution.html#while"·title='The·"while"·loop'><strong·class="userinput"><code>while</code></strong></a>.·The·difference·is·that·<strong·class="userinput"><code>repeat</code></strong>·keeps·repeating·(looping)·the·code·between·the·brackets·for·as·many·times·as·the·given·number.</p></dd></dl></div></div><div·class="sect2"><div·class="titlepage"><div><div><h3·class="title"><a·name="for"></a>The·"for"·loop,·a·counting·loop</h3></div></div></div><div·class="variablelist"><dl><dt><span·class="term">for<a·class="indexterm"·name="idp149769144"></a><a·class="indexterm"·name="idp149769528"></a></span></dt><dd><pre·class="screen">for·<a·class="link"·href="assignment-of-variables.html"·title="Assignment·of·variables">variable</a>·=·<a·class="link"·href="reference.html#number"·title="Numbers">number</a>·to·<a·class="link"·href="reference.html#number"·title="Numbers">number</a>·{·...·}</pre·✂ |
286 | ······The·<strong·class="userinput"><code>for</code></strong>·loop·is·a·<span·class="quote">“<span·class="quote">counting·loop</span>”</span>,·<abbr·class="abbrev">i.e.</abbr>·it·keeps·count·for·you.·The·first·number·sets·the·variable·to·the·value·in·the·first·loop.·Every·loop·the·number·is·increased·until·the·second·number·is·reached. | 286 | ······The·<strong·class="userinput"><code>for</code></strong>·loop·is·a·<span·class="quote">“<span·class="quote">counting·loop</span>”</span>,·<abbr·class="abbrev">i.e.</abbr>·it·keeps·count·for·you.·The·first·number·sets·the·variable·to·the·value·in·the·first·loop.·Every·loop·the·number·is·increased·until·the·second·number·is·reached. |
287 | ······</p><pre·class="screen"> | 287 | ······</p><pre·class="screen"> |
288 | for·$x·=·1·to·10·{ | 288 | for·$x·=·1·to·10·{ |
289 | ··print·$x·*·7 | 289 | ··print·$x·*·7 |
290 | ··forward·15 | 290 | ··forward·15 |
291 | } | 291 | } |
292 | </pre><p> | 292 | </pre><p> |
293 | ·····Every·time·the·code·between·the·brackets·is·executed·the·<strong·class="userinput"><code>$x</code></strong>·is·increased·by·1,·until·<strong·class="userinput"><code>$x</code></strong>·reaches·the·value·of·10.·The·code·between·the·brackets·prints·the·<strong·class="userinput"><code>$x</code></strong>·multiplied·by·7.·After·this·program·finishes·its·execution·you·will·see·the·times·table·of·7·on·the·canvas. | 293 | ·····Every·time·the·code·between·the·brackets·is·executed·the·<strong·class="userinput"><code>$x</code></strong>·is·increased·by·1,·until·<strong·class="userinput"><code>$x</code></strong>·reaches·the·value·of·10.·The·code·between·the·brackets·prints·the·<strong·class="userinput"><code>$x</code></strong>·multiplied·by·7.·After·this·program·finishes·its·execution·you·will·see·the·times·table·of·7·on·the·canvas. |
294 | ·····</p><p> | 294 | ·····</p><p> |
295 | ·····The·default·step·size·of·a·loop·is·1,·you·can·use·an·other·value·with | 295 | ·····The·default·step·size·of·a·loop·is·1,·you·can·use·an·other·value·with |
296 | ·····</p><pre·class="screen">for·<a·class="link"·href="assignment-of-variables.html"·title="Assignment·of·variables">variable</a>·=·<a·class="link"·href="reference.html#number"·title="Numbers">number</a>·to·<a·class="link"·href="reference.html#number"·title="Numbers">number</a>·step·<a·class="link"·href="reference.html#number"·title="Numbers">number</a>·{·...·}</pre></dd></dl></div></div><div·class="sect2"><div·class="titlepage"><div><div><h3·class="title"><a·name="break"></a>Leave·a·loop</h3></div></div></div><div·class="variablelist"><dl><dt><span·class="term">break<a·class="indexterm"·name="idp149808696"></a></span></dt><dd><pre·class="screen">break</pre><p> | 296 | ·····</p><pre·class="screen">for·<a·class="link"·href="assignment-of-variables.html"·title="Assignment·of·variables">variable</a>·=·<a·class="link"·href="reference.html#number"·title="Numbers">number</a>·to·<a·class="link"·href="reference.html#number"·title="Numbers">number</a>·step·<a·class="link"·href="reference.html#number"·title="Numbers">number</a>·{·...·}</pre></dd></dl></div></div><div·class="sect2"><div·class="titlepage"><div><div><h3·class="title"><a·name="break"></a>Leave·a·loop</h3></div></div></div><div·class="variablelist"><dl><dt><span·class="term">break<a·class="indexterm"·name="idp149792312"></a></span></dt><dd><pre·class="screen">break</pre><p> |
297 | ······Terminates·the·current·loop·immediately·and·transfers·control·to·the·statement·immediately·following·that·loop.</p></dd></dl></div></div><div·class="sect2"><div·class="titlepage"><div><div><h3·class="title"><a·name="exit"></a>Stop·executing·your·program</h3></div></div></div><div·class="variablelist"><dl><dt><span·class="term">exit<a·class="indexterm"·name="idp149812024"></a></span></dt><dd><pre·class="screen">exit</pre><p> | 297 | ······Terminates·the·current·loop·immediately·and·transfers·control·to·the·statement·immediately·following·that·loop.</p></dd></dl></div></div><div·class="sect2"><div·class="titlepage"><div><div><h3·class="title"><a·name="exit"></a>Stop·executing·your·program</h3></div></div></div><div·class="variablelist"><dl><dt><span·class="term">exit<a·class="indexterm"·name="idp149795640"></a></span></dt><dd><pre·class="screen">exit</pre><p> |
298 | ······Finishes·the·execution·of·your·program.</p></dd></dl></div></div><div·class="sect2"><div·class="titlepage"><div><div><h3·class="title"><a·name="assert"></a>Checking·assertions·at·runtime</h3></div></div></div><div·class="variablelist"><dl><dt><span·class="term">assert<a·class="indexterm"·name="idp149815224"></a></span></dt><dd><pre·class="screen">assert·<a·class="link"·href="reference.html#boolean-value"·title="Boolean·(true/false)·values">boolean</a></pre><p> | 298 | ······Finishes·the·execution·of·your·program.</p></dd></dl></div></div><div·class="sect2"><div·class="titlepage"><div><div><h3·class="title"><a·name="assert"></a>Checking·assertions·at·runtime</h3></div></div></div><div·class="variablelist"><dl><dt><span·class="term">assert<a·class="indexterm"·name="idp149798840"></a></span></dt><dd><pre·class="screen">assert·<a·class="link"·href="reference.html#boolean-value"·title="Boolean·(true/false)·values">boolean</a></pre><p> |
299 | ······Can·be·used·to·reason·about·program·or·input·correctness. | 299 | ······Can·be·used·to·reason·about·program·or·input·correctness. |
300 | ······</p><pre·class="screen"> | 300 | ······</p><pre·class="screen"> |
301 | $in·=·ask·"What·is·your·year·of·birth?" | 301 | $in·=·ask·"What·is·your·year·of·birth?" |
302 | #·the·year·must·be·positive | 302 | #·the·year·must·be·positive |
303 | assert·$in·>·0 | 303 | assert·$in·>·0 |
304 | </pre></dd></dl></div></div></div></div><div·id="footer"><div·class="navCenter"><table·class="navigation"><tr><td·class="prevCell"><a·accesskey="p"·href="assignment-of-variables.html">Prev</a></td><td·class="upCell"><a·accesskey="h"·href="index.html">Contents</a></td><td·class="nextCell"><a·accesskey="n"·href="learn.html">Next</a></td></tr><tr><td·class="prevCell">Assignment·of·variables </td><td·class="upCell">TurtleScript·Programming·Reference</td><td·class="nextCell"> Create·your·own·commands·with·<span·class="quote">“<span·class="quote">learn</span>”</span></td></tr></table></div><div·id="footer_text">Would·you·like·to·make·a·comment·or·contribute·an·update·to·this·page?<br>Send·feedback·to·the·<a·href="mailto:kde-doc-english@kde.org"·class="footer_email">KDE·Docs·Team</a></div></div></div></body></html></FILENAME><FILENAME·filename="learn.html"><html><head><title>Create·your·own·commands·with·“learn”</title><link·rel="stylesheet"·type="text/css"·href="help:/common/kde-default.css"><link·rel="stylesheet"··✂ | 304 | </pre></dd></dl></div></div></div></div><div·id="footer"><div·class="navCenter"><table·class="navigation"><tr><td·class="prevCell"><a·accesskey="p"·href="assignment-of-variables.html">Prev</a></td><td·class="upCell"><a·accesskey="h"·href="index.html">Contents</a></td><td·class="nextCell"><a·accesskey="n"·href="learn.html">Next</a></td></tr><tr><td·class="prevCell">Assignment·of·variables </td><td·class="upCell">TurtleScript·Programming·Reference</td><td·class="nextCell"> Create·your·own·commands·with·<span·class="quote">“<span·class="quote">learn</span>”</span></td></tr></table></div><div·id="footer_text">Would·you·like·to·make·a·comment·or·contribute·an·update·to·this·page?<br>Send·feedback·to·the·<a·href="mailto:kde-doc-english@kde.org"·class="footer_email">KDE·Docs·Team</a></div></div></div></body></html></FILENAME><FILENAME·filename="learn.html"><html><head><title>Create·your·own·commands·with·“learn”</title><link·rel="stylesheet"·type="text/css"·href="help:/common/kde-default.css"><link·rel="stylesheet"··✂ |
305 | </p><pre·class="screen"> | 305 | </p><pre·class="screen"> |
Offset 371, 17 lines modified | Offset 371, 17 lines modified |
371 | </pre><p> | 371 | </pre><p> |
372 | The·<strong·class="userinput"><code>ask</code></strong>·command·takes·a·string·as·input,·and·outputs·the·number·or·string·that·is·entered.·As·you·can·see,·the·output·of·<strong·class="userinput"><code>ask</code></strong>·is·stored·in·the·container·<strong·class="userinput"><code>x</code></strong>.·The·<strong·class="userinput"><code>random</code></strong>·command·also·gives·output.·In·this·case·it·outputs·a·number·between·1·and·100.·The·output·of·the·random·is·again·stored·in·a·container,·named·<strong·class="userinput"><code>r</code></strong>.·Note·that·the·containers·<strong·class="userinput"><code>x</code></strong>·and·<strong·class="userinput"><code>r</code></strong>·are·not·used·in·the·example·code·above.</p><p>There·are·also·commands·that·neither·need·input·nor·give·output.·Here·are·some·examples: | 372 | The·<strong·class="userinput"><code>ask</code></strong>·command·takes·a·string·as·input,·and·outputs·the·number·or·string·that·is·entered.·As·you·can·see,·the·output·of·<strong·class="userinput"><code>ask</code></strong>·is·stored·in·the·container·<strong·class="userinput"><code>x</code></strong>.·The·<strong·class="userinput"><code>random</code></strong>·command·also·gives·output.·In·this·case·it·outputs·a·number·between·1·and·100.·The·output·of·the·random·is·again·stored·in·a·container,·named·<strong·class="userinput"><code>r</code></strong>.·Note·that·the·containers·<strong·class="userinput"><code>x</code></strong>·and·<strong·class="userinput"><code>r</code></strong>·are·not·used·in·the·example·code·above.</p><p>There·are·also·commands·that·neither·need·input·nor·give·output.·Here·are·some·examples: |
373 | </p><pre·class="screen"> | 373 | </p><pre·class="screen"> |
374 | clear | 374 | clear |
375 | penup | 375 | penup |
376 | </pre><p> | 376 | </pre><p> |
377 | </p></dd><dt><a·name="intuitive-highlighting"></a>intuitive·highlighting</dt><dd><p>This·is·a·feature·of·<span·class="application">KTurtle</span>·that·makes·coding·even·easier.·With·intuitive·highlighting·the·code·that·you·write·gets·a·color·that·indicates·what·type·of·code·it·is.·In·the·next·list·you·will·find·the·different·types·of·code·and·the·color·they·get·in·<a·class="link"·href="using-kturtle.html#the-editor"·title="The·Editor">the·editor</a>. | 377 | </p></dd><dt><a·name="intuitive-highlighting"></a>intuitive·highlighting</dt><dd><p>This·is·a·feature·of·<span·class="application">KTurtle</span>·that·makes·coding·even·easier.·With·intuitive·highlighting·the·code·that·you·write·gets·a·color·that·indicates·what·type·of·code·it·is.·In·the·next·list·you·will·find·the·different·types·of·code·and·the·color·they·get·in·<a·class="link"·href="using-kturtle.html#the-editor"·title="The·Editor">the·editor</a>. |
378 | </p><div·class="table"><a·name="idp150174008"></a><p·class="title"><b>Table 5.1. Different·types·of·code·and·their·highlight·color</b></p><div·class="table-contents"><table·summary="Different·types·of·code·and·their·highlight·color"·border="1"><colgroup><col><col><col></colgroup><tbody><tr><td>regular·commands</td><td>dark·blue</td><td>The·regular·commands·are·described·<a·class="link"·href="commands.html"·title="Commands">here</a>.</td></tr><tr><td>execution·controlling·commands</td><td>black·(bold)</td><td>These·special·commands·control·execution,·read·more·on·them·<a·class="link"·href="controlling-execution.html"·title="Controlling·execution">here</a>.</td></tr><tr><td>comments</td><td>gray</td><td>Lines·that·are·commented·start·with·a·comment·characters·(#).·These·lines·are·ignored·when·the·code·is·executed.·Comments·allow·the·programmer·to·explain·a·bit·about·his·code·or·can·be·used·to·temporarily·prevent·a·certain·piece·of·code·from·executing.</td></tr><tr><td>brackets·{,·}</td><td>dark·green·(bold)</td·✂ | 378 | </p><div·class="table"><a·name="idp150169912"></a><p·class="title"><b>Table 5.1. Different·types·of·code·and·their·highlight·color</b></p><div·class="table-contents"><table·summary="Different·types·of·code·and·their·highlight·color"·border="1"><colgroup><col><col><col></colgroup><tbody><tr><td>regular·commands</td><td>dark·blue</td><td>The·regular·commands·are·described·<a·class="link"·href="commands.html"·title="Commands">here</a>.</td></tr><tr><td>execution·controlling·commands</td><td>black·(bold)</td><td>These·special·commands·control·execution,·read·more·on·them·<a·class="link"·href="controlling-execution.html"·title="Controlling·execution">here</a>.</td></tr><tr><td>comments</td><td>gray</td><td>Lines·that·are·commented·start·with·a·comment·characters·(#).·These·lines·are·ignored·when·the·code·is·executed.·Comments·allow·the·programmer·to·explain·a·bit·about·his·code·or·can·be·used·to·temporarily·prevent·a·certain·piece·of·code·from·executing.</td></tr><tr><td>brackets·{,·}</td><td>dark·green·(bold)</td·✂ |
379 | </p></dd><dt><a·name="pixels"></a>pixels</dt><dd><p>A·pixel·is·a·dot·on·the·screen.·If·you·look·very·close·you·will·see·that·the·screen·of·your·monitor·uses·pixels.·All·images·on·the·screen·are·built·with·these·pixels.·A·pixel·is·the·smallest·thing·that·can·be·drawn·on·the·screen.</p><p>A·lot·of·commands·need·a·number·of·pixels·as·input.·These·commands·are:·<strong·class="userinput"><code>forward</code></strong>,·<strong·class="userinput"><code>backward</code></strong>,·<strong·class="userinput"><code>go</code></strong>,·<strong·class="userinput"><code>gox</code></strong>,·<strong·class="userinput"><code>goy</code></strong>,·<strong·class="userinput"><code>canvassize</code></strong>·and·<strong·class="userinput"><code>penwidth</code></strong>.</p><p>In·early·versions·of·<span·class="application">KTurtle</span>·the·canvas·was·essentially·a·raster·image,·yet·for·recent·versions·the·canvas·is·a·vector·drawing.·This·means·that·the·canvas·can·be·zoomed·in·and·out,·therefore·a·pixel·does·not·necessarily·have·to·tra·✂ | 379 | </p></dd><dt><a·name="pixels"></a>pixels</dt><dd><p>A·pixel·is·a·dot·on·the·screen.·If·you·look·very·close·you·will·see·that·the·screen·of·your·monitor·uses·pixels.·All·images·on·the·screen·are·built·with·these·pixels.·A·pixel·is·the·smallest·thing·that·can·be·drawn·on·the·screen.</p><p>A·lot·of·commands·need·a·number·of·pixels·as·input.·These·commands·are:·<strong·class="userinput"><code>forward</code></strong>,·<strong·class="userinput"><code>backward</code></strong>,·<strong·class="userinput"><code>go</code></strong>,·<strong·class="userinput"><code>gox</code></strong>,·<strong·class="userinput"><code>goy</code></strong>,·<strong·class="userinput"><code>canvassize</code></strong>·and·<strong·class="userinput"><code>penwidth</code></strong>.</p><p>In·early·versions·of·<span·class="application">KTurtle</span>·the·canvas·was·essentially·a·raster·image,·yet·for·recent·versions·the·canvas·is·a·vector·drawing.·This·means·that·the·canvas·can·be·zoomed·in·and·out,·therefore·a·pixel·does·not·necessarily·have·to·tra·✂ |
380 | </p><div·class="table"><a·name="idp150217400"></a><p·class="title"><b>Table 5.2. Often·used·RGB·combinations</b></p><div·class="table-contents"><table·summary="Often·used·RGB·combinations"·border="0"><colgroup><col·class="c1"><col></colgroup><tbody><tr><td><strong·class="userinput"><code>0,0,0</code></strong></td><td>black</td></tr><tr><td><strong·class="userinput"><code>255,255,255</code></strong></td><td>white</td></tr><tr><td><strong·class="userinput"><code>255,0,0</code></strong></td><td>red</td></tr><tr><td><strong·class="userinput"><code>150,0,0</code></strong></td><td>dark·red</td></tr><tr><td><strong·class="userinput"><code>0,255,0</code></strong></td><td>green</td></tr><tr><td><strong·class="userinput"><code>0,0,255</code></strong></td><td>blue</td></tr><tr><td><strong·class="userinput"><code>0,255,255</code></strong></td><td>light·blue</td></tr><tr><td><strong·class="userinput"><code>255,0,255</code></strong></td><td>pink</td></tr><tr><td><strong·class="userinput"><code>255,255,0</code></strong></td·✂ | 380 | </p><div·class="table"><a·name="idp150225592"></a><p·class="title"><b>Table 5.2. Often·used·RGB·combinations</b></p><div·class="table-contents"><table·summary="Often·used·RGB·combinations"·border="0"><colgroup><col·class="c1"><col></colgroup><tbody><tr><td><strong·class="userinput"><code>0,0,0</code></strong></td><td>black</td></tr><tr><td><strong·class="userinput"><code>255,255,255</code></strong></td><td>white</td></tr><tr><td><strong·class="userinput"><code>255,0,0</code></strong></td><td>red</td></tr><tr><td><strong·class="userinput"><code>150,0,0</code></strong></td><td>dark·red</td></tr><tr><td><strong·class="userinput"><code>0,255,0</code></strong></td><td>green</td></tr><tr><td><strong·class="userinput"><code>0,0,255</code></strong></td><td>blue</td></tr><tr><td><strong·class="userinput"><code>0,255,255</code></strong></td><td>light·blue</td></tr><tr><td><strong·class="userinput"><code>255,0,255</code></strong></td><td>pink</td></tr><tr><td><strong·class="userinput"><code>255,255,0</code></strong></td·✂ |
381 | </p><p>Two·commands·need·an·RGB·combination·as·input:·these·commands·are·<strong·class="userinput"><code>canvascolor</code></strong>·and·<strong·class="userinput"><code>pencolor</code></strong>.</p></dd><dt><a·name="sprite"></a>sprite</dt><dd><p>A·sprite·is·a·small·picture·that·can·be·moved·around·the·screen.·Our·beloved·turtle,·for·instance,·is·a·sprite.</p><p>Note:·with·this·version·of·<span·class="application">KTurtle</span>·the·sprite·cannot·be·changed·from·a·turtle·into·something·else.·Future·versions·of·<span·class="application">KTurtle</span>·will·be·able·to·do·this.</p></dd></dl></div></div></div><div·id="footer"><div·class="navCenter"><table·class="navigation"><tr><td·class="prevCell"><a·accesskey="p"·href="learn.html">Prev</a></td><td·class="upCell"><a·accesskey="h"·href="index.html">Contents</a></td><td·class="nextCell"><a·accesskey="n"·href="translators.html">Next</a></td></tr><tr><td·class="prevCell">Create·your·own·commands·with·<span·class="quote">“<span·class="quote">learn</span>”</span> </td>·✂ | 381 | </p><p>Two·commands·need·an·RGB·combination·as·input:·these·commands·are·<strong·class="userinput"><code>canvascolor</code></strong>·and·<strong·class="userinput"><code>pencolor</code></strong>.</p></dd><dt><a·name="sprite"></a>sprite</dt><dd><p>A·sprite·is·a·small·picture·that·can·be·moved·around·the·screen.·Our·beloved·turtle,·for·instance,·is·a·sprite.</p><p>Note:·with·this·version·of·<span·class="application">KTurtle</span>·the·sprite·cannot·be·changed·from·a·turtle·into·something·else.·Future·versions·of·<span·class="application">KTurtle</span>·will·be·able·to·do·this.</p></dd></dl></div></div></div><div·id="footer"><div·class="navCenter"><table·class="navigation"><tr><td·class="prevCell"><a·accesskey="p"·href="learn.html">Prev</a></td><td·class="upCell"><a·accesskey="h"·href="index.html">Contents</a></td><td·class="nextCell"><a·accesskey="n"·href="translators.html">Next</a></td></tr><tr><td·class="prevCell">Create·your·own·commands·with·<span·class="quote">“<span·class="quote">learn</span>”</span> </td>·✂ |
382 | <span·class="application">KTurtle</span> | 382 | <span·class="application">KTurtle</span> |
383 | </p><p>Software·copyright·2003-2007·Cies·Breijs·<code·class="email">(cies·AT·kde·DOT·nl)</code></p><p>Documentation·copyright·2004,·2007,·2009 | 383 | </p><p>Software·copyright·2003-2007·Cies·Breijs·<code·class="email">(cies·AT·kde·DOT·nl)</code></p><p>Documentation·copyright·2004,·2007,·2009 |
384 | </p><div·class="itemizedlist"><ul·class="itemizedlist"·type="disc"><li·class="listitem"><p> | 384 | </p><div·class="itemizedlist"><ul·class="itemizedlist"·type="disc"><li·class="listitem"><p> |
385 | Cies·Breijs·<code·class="email">(cies·AT·kde·DOT·nl)</code> | 385 | Cies·Breijs·<code·class="email">(cies·AT·kde·DOT·nl)</code> |
386 | </p></li><li·class="listitem"><p> | 386 | </p></li><li·class="listitem"><p> |
387 | <span·class="firstname">Anne-Marie</span>·<span·class="surname">Mahfouf</span>·<code·class="email">(annma·AT·kde·DOT·org)</code> | 387 | <span·class="firstname">Anne-Marie</span>·<span·class="surname">Mahfouf</span>·<code·class="email">(annma·AT·kde·DOT·org)</code> |