112 lines
5.4 KiB
HTML
112 lines
5.4 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>LOOKDOWN Examples</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>LOOKDOWN Examples</h1>
|
|||
|
<div class="ImagePlusCaption">
|
|||
|
<div class="Col2">
|
|||
|
<p>
|
|||
|
<img src="../../graphics/pgm_icon1.gif" border="0" alt="BS1 icon" title="BS1 icon" />
|
|||
|
<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" />
|
|||
|
</p>
|
|||
|
</div>
|
|||
|
<p style="text-align: right;">Syntax: <a href="../Commands/LOOKDOWN.htm" target="" title="" alt="" class="MCXref_0" xrefformat="{paratext}">LOOKDOWN</a></p>
|
|||
|
<p> </p>
|
|||
|
</div>
|
|||
|
<p class="clear"> </p>
|
|||
|
<p class="PlainText"> </p><pre class="BScode" xml:space="preserve">' LOOKDOWN.BS1
|
|||
|
' This program uses LOOKDOWN followed by LOOKUP to map the numbers:
|
|||
|
' 0, 10, 50, 64, 71 and 98 to 35, 40, 58, 62, 79, and 83, respectively.
|
|||
|
' All other numbers are mapped to 255.
|
|||
|
|
|||
|
' {$STAMP BS1}
|
|||
|
' {$PBASIC 1.0}
|
|||
|
|
|||
|
SYMBOL num = W0 ' holds current number
|
|||
|
SYMBOL result = W1 ' holds mapped result
|
|||
|
|
|||
|
|
|||
|
Main:
|
|||
|
FOR num = 0 TO 100
|
|||
|
result = 255 ' default value for no match
|
|||
|
LOOKDOWN num, (0, 10, 50, 64, 71, 98), result
|
|||
|
LOOKUP result, (35, 40, 58, 62, 79, 83), result
|
|||
|
DEBUG "Num = ", #num, "Result = ", #result, CR
|
|||
|
PAUSE 100
|
|||
|
NEXT
|
|||
|
END
|
|||
|
|
|||
|
</pre>
|
|||
|
<p class="PlainText"> </p>
|
|||
|
<p>NOTE: The example below is written for the BS2 and will run on any of the BS2-family modules. Modify the $STAMP directive (as required) before downloading to the BS2e, BS2sx, BS2p, BS2pe, or BS2px.</p><pre class="BScode" xml:space="preserve">' LOOKDOWN.BS2
|
|||
|
' This program uses LOOKDOWN to determine the number of decimal digits in
|
|||
|
' a number. Since LOOKDOWN uses a zero-indexed table, the output will be
|
|||
|
' the number of digits minus one, so this gets corrected in the following
|
|||
|
' line. Note that zero is considered a valid number and has one digit.
|
|||
|
|
|||
|
' {$STAMP BS2}
|
|||
|
' {$PBASIC 2.5}
|
|||
|
|
|||
|
aNum VAR Word ' random number
|
|||
|
stpSz VAR Word ' FOR-NEXT step size
|
|||
|
numDig VAR Nib ' digits in aNum
|
|||
|
|
|||
|
|
|||
|
Setup:
|
|||
|
stpSz = 2
|
|||
|
|
|||
|
Main:
|
|||
|
FOR aNum = 0 TO 15000 STEP stpSz
|
|||
|
LOOKDOWN aNum, <[0, 10, 100, 1000, 10000, 65535], numDig
|
|||
|
' right-justify output
|
|||
|
DEBUG "aNum = ", REP " "\(5-numDig), DEC aNum, TAB,
|
|||
|
"Digits = ", DEC numDig, CR
|
|||
|
PAUSE 250
|
|||
|
LOOKDOWN aNum, <[0, 10, 100, 1000, 10000, 65535], stpSz
|
|||
|
LOOKUP stpSz, [2, 2, 5, 25, 250, 500, 1000], stpSz
|
|||
|
NEXT
|
|||
|
END
|
|||
|
|
|||
|
</pre>
|
|||
|
<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 © <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>
|