This repository has been archived on 2024-09-22. You can view files and clone it, but cannot push or open issues or pull requests.
pbi-ide/help/BasicStampHelp/Content/LanguageTopics/Commands/DEBUGIN.htm

305 lines
15 KiB
HTML

<?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="" 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>DEBUGIN</title>
<link href="../../SkinSupport/MadCap.css" rel="stylesheet" />
<link href="../../Resources/Stylesheets/BSE_Help.css" rel="stylesheet" />
<script src="../../SkinSupport/MadCapAll.js" type="text/javascript">
</script>
</head>
<body>
<h1 class="code">DEBUGIN</h1>
<div class="ImagePlusCaption">
<div class="Col2">
<p>
<img src="../../graphics/pgm_icon2.gif" border="0" alt="BS2 icon" title="BS2 icon" />
<img src="../../graphics/pgm_icon2e.gif" border="0" alt="BS2e icon" title="BS2e icon" />
<img src="../../graphics/pgm_icon2sx.gif" border="0" alt="BS2sx icon" title="BS2sx icon" />
<img src="../../graphics/pgm_icon2p.gif" border="0" alt="BS2p icon" title="BS2p icon" />
<img src="../../graphics/pgm_icon2pe.gif" border="0" alt="BS2pe icon" title="BS2pe icon" />
<img src="../../graphics/pgm_icon2px.gif" border="0" alt="BS2px icon" title="BS2px icon" /><span class="code_in_text"> {PBASIC&#160;2.5}</span>
</p>
</div>
<p style="text-align: right;"><a href="../ExampleTopics/DebugDebuginEx.htm" target="" title="" alt="" class="MCXref_0" xrefformat="{paratext}">DEBUG / DEBUGIN Example</a>
</p>
<p>&#160;</p>
</div>
<p class="clear">&#160;</p>
<p>&#160;</p>
<p class="PlainText">Syntax: <span class="keyword_in_text">DEBUGIN</span> <![CDATA[ ]]><i>InputData</i></p>
<h2>Function</h2>
<p class="PlainText">Retrieve information from the user via the Debug Terminal window within the BASIC Stamp editor program.
</p>
<ul>
<li value="1"><b><i>InputData</i></b> is list of variables and formatters that tells
<span class="keyword_in_text">DEBUGIN</span> what to do with incoming data. <span class="keyword_in_text">DEBUGIN</span> can store data in
a variable or array, interpret numeric text (decimal, binary, or hex) and store
the corresponding value in a variable, wait for a fixed or variable sequence of
bytes, or ignore a specified number of bytes. These actions can be combined
in any order in the <i>InputData</i> list.</li>
</ul>
<h2>Quick Facts<br /></h2>
<table width="100%" cellpadding="4" cellspacing="0" border="1">
<tr bgcolor="#CFCFCF">
<td width="20%" align="center">&#160;</td>
<td width="40%" align="center">BS2, BS2e, BS2sx, BS2p, and BS2pe</td>
<td width="40%" align="center">BS2px</td>
</tr>
<tr>
<td align="center" bgcolor="#CFCFCF">Serial Protocol</td>
<td align="center">Asychronous 9600 baud, N, 8, 1<br></br>Inverted polarity,
Raw Data</td>
<td align="center">Asychronous 19.2 kBaud, N, 8, 1<br></br>Inverted polarity,
Raw Data</td>
</tr>
<tr>
<td align="center" bgcolor="#CFCFCF">Related Commands</td>
<td align="center" colspan="2">
<p colspan="2" align="center"><a href="DEBUG.htm" target="" title="" alt="" class="MCXref_0" xrefformat="{paratext}">DEBUG</a>, <a href="SERIN.htm" target="" title="" alt="" class="MCXref_0" xrefformat="{paratext}">SERIN</a></p>
</td>
</tr>
</table>
<h2>Explanation</h2>
<p class="PlainText"><span class="keyword_in_text">DEBUGIN</span> provides a convenient way for your BASIC Stamp accept input from
the use via the Debug Terminal. <span class="keyword_in_text">DEBUGIN</span> can wait for, filter and
convert incoming data in powerful ways, using the same techniques and modifiers
as <a href="SERIN.htm" target="" title="" alt="" class="MCXref_0" xrefformat="{paratext}">SERIN</a>.
</p>
<p class="PlainText">This simple example waits for a number from the user, then prints a message
the specified number of times: </p><pre class="BScode" xml:space="preserve">
lines VAR Nib
idx VAR Nib
Main:
DEBUG CLS, "How many lines to print (1 - 5)? --&gt; "
DEBUGIN DEC1 lines
IF ((lines &gt;= 1) AND (lines &lt;= 5)) THEN
DEBUG CR, CR
FOR idx = 1 TO lines ' print message specified times
DEBUG DEC1 idx, ". "
DEBUG "BASIC Stamp!", CR
NEXT
END ' end of program
ELSE
DEBUG CR, "Invalid entry!" ' warning message
PAUSE 2000 ' wait 2 seconds
GOTO Main ' get another entry
ENDIF
</pre>
<p class="PlainText">After you download this program, the BASIC Stamp Editor will open a Debug
Terminal on your PC screen and wait for an entry from the user. Since the DEC1
modifier is used with <span class="keyword_in_text">DEBUGIN</span>, the program will ignore all keys except
"0" - "9". If the value entered is between 1 and 5, the message will be printed,
otherwise the program will display an "Invalid entry" message, then loop back
and wait for another entry.</p>
<p class="PlainText"><span class="keyword_in_text">DEBUGIN</span> is actually a special case of the <span class="keyword_in_text">SERIN</span> instruction. It
is set for inverted (RS-232-compatible) serial output through the programming
connector (the SIN pin) at 9600 baud (BS2, BS2e, BS2sx, BS2p, and BS2pe) or
19.2 kBaud (BS2px), no parity, 8 data bits, and 1 stop bit.
For example,</p><pre class="BScode" xml:space="preserve">
DEBUGIN DEC1 lines
</pre>
<p class="PlainText">...is exactly like:</p><pre class="BScode" xml:space="preserve">
SERIN 16, $4054, [DEC1 lines]
</pre>
<p class="PlainText">...in terms of function (on a BS2). The <span class="keyword_in_text">DEBUGIN</span> line actually takes less
program space, and is obviously easier to type.</p>
<p class="PlainText">The tables below list all the available conversion formatters and special
formatters available to the <span class="keyword_in_text">DEBUGIN</span> command. See the
<a href="SERIN.htm" target="" title="" alt="" class="MCXref_0" xrefformat="{paratext}">SERIN</a> command for additional information and examples
of their use.</p>
<table width="100%" cellpadding="4" cellspacing="0" border="1">
<tr bgcolor="#CFCFCF" align="center" valign="top">
<td width="15%">Conversion Formatter</td>
<td width="45%">Type of Number</td>
<td width="30%">Numeric Characters Accepted</td>
<td width="10%">Notes</td>
</tr>
<tr align="center">
<td>DEC{1..5}</td>
<td>Decimal, optionally limited to 1 - 5 digits</td>
<td>0 through 9</td>
<td>1</td>
</tr>
<tr align="center">
<td>SDEC{1..5}</td>
<td>Signed decimal, optionally limited to 1 - 5 digits</td>
<td>-, 0 through 9</td>
<td>1,2</td>
</tr>
<tr align="center">
<td>HEX{1..4}</td>
<td>Hexadecimal, optionally limited to 1 - 4 digits</td>
<td>0 through 9, A through F</td>
<td>1,3</td>
</tr>
<tr align="center">
<td>SHEX{1..4}</td>
<td>Signed hexadecimal, optionally limited to 1 - 4 digits </td>
<td>-, 0 through 9, A through F</td>
<td>1,2,3</td>
</tr>
<tr align="center">
<td>IHEX{1..4}</td>
<td>Indicated hexadecimal, optionally limited to 1 - 4 digits</td>
<td>$, 0 through 9, A through F</td>
<td>1,3,4</td>
</tr>
<tr align="center">
<td>ISHEX{1..4}</td>
<td>Signed, indicated hexadecimal, optionally limited to 1 - 4 digits</td>
<td>-, $, 0 through 9, A through F</td>
<td>1,2,3,4</td>
</tr>
<tr align="center">
<td>BIN{1..16}</td>
<td>Binary, optionally limited to 1 - 16 digits</td>
<td>0, 1</td>
<td>1</td>
</tr>
<tr align="center">
<td>SBIN{1..16}</td>
<td>Signed binary, optionally limited to 1 - 16 digits</td>
<td>-, 0, 1</td>
<td>1,2</td>
</tr>
<tr align="center">
<td>IBIN{1..16}</td>
<td>Indicated binary, optionally limited to 1 - 16 digits</td>
<td>%, 0, 1</td>
<td>1,4</td>
</tr>
<tr align="center">
<td>ISBIN{1..16}</td>
<td>Signed, indicated binary, optionally limited to 1 - 16 digits</td>
<td>-, %, 0, 1</td>
<td>1,2,4</td>
</tr>
<tr align="center">
<td>NUM</td>
<td>Generic numeric input; hex or binary number must be indicated</td>
<td>$, %, 0 through 9, A through F</td>
<td>1,3,4</td>
</tr>
<tr align="center">
<td>SNUM</td>
<td>Similar to NUM with value treated as signed with range -32768 to +32767</td>
<td>-, $, %, 0 through 9, A through F</td>
<td>1,2,3,4</td>
</tr>
</table>
<ol>
<li value="1">All numeric conversions will continue to accept new data until receiving
either the specified number of digits (ex: three digits for DEC3) or a
non-numeric character.</li>
<li value="2">To be recognized as part of a number, the minus sign (-) must immediately
precede a numeric character. The minus sign character occurring in non-numeric
text is ignored and any character (including a space) between a minus and a
number causes the minus to be ignored.</li>
<li value="3">The hexadecimal formatters are not case-sensitive; "a" through "f" means
the same as "A" through "F".</li>
<li value="4">Indicated hexadecimal and binary formatters ignore all characters, even
valid numerics, until they receive the appropriate prefix ($ for hexadecimal,
% for binary). The indicated formatters can differentiate between text and
hexadecimal (ex: ABC would be interpreted by HEX as a number but IHEX would
ignore it unless expressed as $ABC). Likewise, the binary version can
distinguish the decimal number 10 from the binary number %10. A prefix
occurring in non-numeric text is ignored, and any character (including a
space) between a prefix and a number causes the prefix to be ignored. Indicated,
signed formatters require that the minus sign come before the prefix, as
in -$1B45.</li>
</ol>
<p>&#160;</p>
<table width="100%" cellpadding="4" cellspacing="0" border="1">
<tr bgcolor="#CFCFCF" align="center" valign="top">
<td width="150">Special Formatter</td>
<td>Action</td>
</tr>
<tr>
<td align="center">STR ByteArray \L {\E}</td>
<td>Input a character string of length L into an array. If specified, an end
character E causes the string input to end before reaching length L.
Remaining bytes are filled with 0s (zeros).</td>
</tr>
<tr>
<td align="center">WAITSTR ByteArray {\L}</td>
<td>Wait for a sequence of bytes matching a string stored in an array variable,
optionally limited to L characters. If the optional L argument is left off,
the end of the array-string must be marked by a byte containing a zero (0).</td>
</tr>
<tr>
<td align="center">SKIP Length</td>
<td>Ignore Length bytes of characters.</td>
</tr>
</table>
<p>&#160;</p>
<p>
<img src="../../graphics/bs2ppepx_inline.gif" border="0" />
<br />
</p>
<p>
<br />
</p>
<table width="100%" cellpadding="4" cellspacing="0" border="1">
<tr bgcolor="#CFCFCF" align="center" valign="top">
<td width="150">Special Formatter</td>
<td>Action</td>
</tr>
<tr>
<td align="center">SPSTR L</td>
<td>Buffer length L bytes (up to 126) of serial characters to Scratchpad RAM,
starting at location 0. Use <a href="GET.htm" target="" title="" alt="" class="MCXref_0" xrefformat="{paratext}">GET</a> to retrieve the
characters.</td>
</tr>
</table><pre class="BScode" xml:space="preserve">
idx VAR Nib
char VAR Byte
Setup:
DEBUG CLS, "Enter (4-character) passcode: "
Main:
DEBUGIN SPSTR 4
DEBUG CLS, "Checking: "
FOR idx = 0 TO 3
GET idx, char
DEBUG char
NEXT
END
</pre>
<p class="PlainText">The example above will redirect four characters from the Debug Terminal
input to Scratchpad locations 0 - 3.</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>