pbi-ide/help/BasicStampHelp/Content/StartTopics/IntroAscii.htm

86 lines
7.8 KiB
HTML
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns:MadCap="http://www.madcapsoftware.com/Schemas/MadCap.xsd" MadCap:lastBlockDepth="6" MadCap:lastHeight="94" MadCap:lastWidth="853" MadCap:disableMasterStylesheet="true" MadCap:tocPath="Getting Started" MadCap:InPreviewMode="false" MadCap:PreloadImages="false" MadCap:RuntimeFileType="Topic" MadCap:TargetType="WebHelp" lang="en-us" xml:lang="en-us" MadCap:PathToHelpSystem="../../" MadCap:HelpSystemFileName="Default.xml" MadCap:SearchType="Stem">
<head><title>Introducing ASCII Code</title>
<link href="../SkinSupport/MadCap.css" rel="stylesheet" />
<link href="../Resources/Stylesheets/BSE_Help.css" rel="stylesheet" />
<script src="../SkinSupport/MadCapAll.js">
</script>
</head>
<body>
<div class="MCBreadcrumbsBox_0"><span class="MCBreadcrumbsPrefix">You are here: </span><a class="MCBreadcrumbsLink" href="Start.htm">Getting Started</a><span class="MCBreadcrumbsDivider"> &gt; </span><span class="MCBreadcrumbs">Introducing ASCII Code</span>
</div>
<p><a href="LookUpAnswers.htm" title="Go back to &quot;Looking Up Answers&quot;" alt="Go back to &quot;Looking Up Answers&quot;"><img src="../Resources/Images/Prev.png" /></a><a href="WhenDone.htm" title="Go on to &quot;When You're Done&quot;" alt="Go on to &quot;When You're Done&quot;"><img src="../Resources/Images/Next.png" /></a>
</p>
<h1>Introducing ASCII Code</h1>
<p class="PlainText">In the First Program activity, you used the DEC formatter with the <span class="keyword_in_text">DEBUG </span>command to display a decimal number in the Debug Terminal.&#160; But what happens if you dont use the DEC formatter with a number?&#160; If you use the <span class="keyword_in_text">DEBUG </span>command followed by a number with no formatter, the BASIC Stamp will read that number as an ASCII code.</p>
<h2>Programming with ASCII Code</h2>
<p class="PlainText">ASCII is short for American Standard Code for Information Interchange.&#160; Most microcontrollers and PC computers use this code to assign a number to each keyboard function.&#160; Some numbers correspond to keyboard actions, such as cursor up, cursor down, space, and delete.&#160; Other numbers correspond to printed characters and symbols.&#160; The numbers 32 through 126 correspond to those characters and symbols that the BASIC Stamp can display in the Debug Terminal. The following program will use ACSII code to display the words&#160; “BASIC Stamp 2” in the Debug Terminal.</p>
<h3>Example Program ASCIIName.bs2</h3>
<ul>
<li class="Checklist" value="1">Enter and run ASCIIName.bs2.</li>
</ul>
<p class="Tip" MadCap:autonum="Tip: &#160;"><span class="autonumber"><span class="TipSpan">Tip: &#160;</span></span>Remember to use the toolbar icons to place Compiler Directives into your programs!<br />'{$STAMP BS2} - Use the diagonal green electronic chip icon.<br />'{$PBASIC 2.5} - Use the gear icon labeled 2.5. </p><pre xml:space="preserve" class="SICcode">' Stamps in Class - ASCIIName.bs2
' Use ASCII code in a DEBUG command to display the words BASIC Stamp 2.
&#160;
'{$STAMP BS2}
'{$PBASIC 2.5}&#160;
PAUSE 1000
DEBUG 66,65,83,73,67,32,83,116,97,109,112,32,50
&#160;
END</pre>
<h3>How ASCIIName.bs2 Works
</h3>
<p class="PlainText">Each number in the <span class="keyword_in_text">DEBUG</span> command corresponds to one ASCII code symbol that appeared in the Debug Terminal.
</p><pre class="snippet">DEBUG 66,65,83,73,67,32,83,116,97,109,112,32,50</pre>
<p class="PlainText">66 is the ASCII code for capital “B”, 65 is the code for capital “A” and so on.&#160; 32 is the code for a space between characters. Notice that each code number was separated with a comma.&#160; The commas allow the one instance of <span class="keyword_in_text">DEBUG </span>to transmit each symbol as a separate value.&#160; This is much easier to type than 12 separate <span class="keyword_in_text">DEBUG </span>commands.&#160; </p>
<h3>Your Turn Exploring ASCII Code</h3>
<ul>
<li class="Checklist" value="1">Save ASCIIName.bs2 as ASCIIRandom.bs2</li>
<li class="Checklist" value="2">Pick 12 random numbers between 32 and 126.</li>
<li class="Checklist" value="3">Replace the ASCII code numbers in the program with the numbers you chose.</li>
<li class="Checklist" value="4">Run your modified program to see what you get!</li>
</ul>
<p>&#160;</p>
<p>This Help file has an <span class="MCPopup"><a href="javascript:void(0);" MadCap:src="AsciiPopup.htm" onclick="FMCPopup( event, this ); return false;" class="MCXref_0" alt="Open the ASCII Chart in a popup window" title="Open the ASCII Chart in a popup window">ASCII Chart</a></span> <![CDATA[ ]]><MadCap:conditionalText MadCap:conditions="BSEconditions.BSEWebHelp (Primary)-INCLUDE,BSEconditions.BSHweb-SIC-EXCLUDE">(located in PBASIC&#160;Language Reference &gt; ASCII&#160;Chart)</MadCap:conditionalText> with the numbers and their corresponding symbols. You can look up the corresponding code numbers to spell your own name.</p>
<ul>
<li class="Checklist" value="1">Save ASCIIRandom.bs2 as YourASCIIName.bs2</li>
<li class="Checklist" value="2">Open up the <span class="MCPopup"><a href="javascript:void(0);" MadCap:src="AsciiPopup.htm" onclick="FMCPopup( event, this ); return false;" class="MCXref_0" alt="Open the ASCII chart in a popup window" title="Open the ASCII chart in a popup window">ASCII Chart</a></span>.</li>
<li class="Checklist" value="3">Using the chart as a reference, modify the program to spell your own name.</li>
<li class="Checklist" value="4">Run the program to see if you spelled your name correctly.</li>
<li class="Checklist" value="5">If you did, good job, and save your program!</li>
</ul>
<p><a href="LookUpAnswers.htm" title="Go back to &quot;Looking Up Answers&quot;" alt="Go back to &quot;Looking Up Answers&quot;"><img src="../Resources/Images/Prev.png" /></a><a href="WhenDone.htm" title="Go on to &quot;When You're Done&quot;" alt="Go on to &quot;When You're Done&quot;"><img src="../Resources/Images/Next.png" /></a>
</p>
<div class="Col2">
<div class="MasterFoot">
<p MadCap:conditions="BSEconditions.BSEWebHelp (Primary)-INCLUDE"><a href="../HomeTopics/HomePage.htm">Go to Welcome page</a>
</p>
</div>
</div>
<div class="Col2">
<div class="MasterFoot">
<p style="text-align: right;"><span class="ContactInfoProjectName">BASIC Stamp Help</span> <![CDATA[ ]]><span class="ContactInfoVersion#">Version 2.5.4</span> <![CDATA[ ]]></p>
<p style="text-align: right;">Copyright ©&#160;<span class="ContactInfoCompanyName">Parallax Inc.</span></p>
<p style="text-align: right;"><span class="SystemShortDate">8/8/2012</span>
</p>
</div>
</div>
<script type="text/javascript">/* <![CDATA[ */
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-285614-1']);
_gaq.push(['_trackPageview']);
(function() {
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();
/* ]]> */</script>
<script type="text/javascript" src="../SkinSupport/MadCapBodyEnd.js">
</script>
</body>
</html>