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/Reference/Directives.htm

128 lines
8.0 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="PBASIC Language Reference" 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>Compiler Directives</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>
<div class="MCBreadcrumbsBox_0"><span class="MCBreadcrumbsPrefix">You are here: </span><a class="MCBreadcrumbsLink" href="AlphaRef.htm">PBASIC Language Reference</a><span class="MCBreadcrumbsDivider"> &gt; </span><span class="MCBreadcrumbs">Compiler Directives</span>
</div>
<h1>Compiler Directives</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;">&#160;</p>
<p>&#160;</p>
</div>
<p class="clear">&#160;</p>
<p>&#160;</p>
<p>(Also see <a href="ConditionalCompile.htm" target="" title="" alt="" class="MCXref_0"> Conditional Compilation</a>)</p>
<h2>$STAMP</h2>
<p class="PlainText">The $STAMP directive is a special command that is included (usually
at the top) in a program to indicate the model of BASIC Stamp targeted. Buttons on the editor
tool bar simplify adding or modifying the $STAMP directive: </p>
<p class="PlainText">
<img src="../../Resources/Images/STAMPButtons.png" />
</p>
<p class="PlainText">The
line below is an example of the $STAMP directive (in this case, it indicates that
the program is intended for a BASIC Stamp 2):</p><pre>
' {$STAMP BS2}
</pre>
<p class="PlainText">This line should be entered into your code, usually near the top, on a line
by itself. Note that the directive appears on a comment line (the apostrophe (')
indicates this) for compatibility with the DOS versions of the editor.</p>
<p class="PlainText">The 'BS2' in the example above should be changed to indicate the appropriate
model of the BASIC Stamp you are using. For example, to use other BASIC Stamp
module, enter one (just one) of the following lines into your code:</p><pre>
' {$STAMP BS1}
' {$STAMP BS2}
' {$STAMP BS2e}
' {$STAMP BS2sx}
' {$STAMP BS2p}
' {$STAMP BS2pe}
' {$STAMP BS2px}
</pre>
<p class="PlainText">The directive itself must be enclosed in brackets, {...}. There should not be
any spaces between the dollar sign, $, and the word STAMP, however, the directive
may contain additional spaces in certain other areas. </p>
<p class="PlainText">The $STAMP directive is read and acted upon by the BASIC Stamp Windows Editor
any time a source code file is loaded, tokenized, downloaded (run) or viewed in
the Memory Map.</p>
<h3><a name="Defining"></a>Defining Multi-File Projects</h3>
<p class="PlainText">The BS2e, BS2sx, BS2p and BS2pe modules support multi-file projects, which require a modified syntax for the $STAMP directive. A project is a set of up to eight files that
should all be downloaded to the BASIC Stamp for a single application. See <a href="MultiFileProjects.htm" target="" title="" alt="" class="MCXref_0">Multi-File Projects</a> for details.</p>
<h3>Conditional Compilation</h3>
<p class="PlainText">To create source code that is usable on multiple BS2 models, but requires changing as set of constants, symbols, or conditions depending on that model, see <a href="ConditionalCompile.htm" target="" title="" alt="" class="MCXref_0"> Conditional Compilation</a>.</p>
<h2>$PBASIC</h2>
<p class="PlainText">The $PBASIC directive allows the programmer to specify the syntax level for
the compiler to use. Buttons on the editor tool bar simplify adding or
modifying the $PBASIC directive:</p>
<p class="PlainText">
<img src="../../Resources/Images/PBASICButtons.png" />
</p>
<p class="PlainText">Examples:</p><pre>
' {$PBASIC 1.0} ' use version 1.0 syntax (BS1 only)
' {$PBASIC 2.0} ' use version 2.0 syntax
' {$PBASIC 2.5} ' use version 2.5 syntax
</pre>
<p class="PlainText">Note that if the $PBASIC directive is omitted, the compiler will assume
version 2.0 syntax, unless a $STAMP BS1 directive is present. </p>
<h2>$PORT</h2>
<p class="PlainText">The purpose of the $PORT directive is to direct a PBASIC program towards a
specific serial port. The syntax is as follows:</p><pre>
' {$PORT COM#}
</pre>
<p class="PlainText">...where # is a valid port number. When any PBASIC program containing this
directive is downloaded, all other ports will be ignored. This directive is
especially important if using two of the same BASIC Stamp models (such as two BS2s)
on two COM ports and you have two different PBASIC programs to download (one to
each BS2). Without this directive, developing and downloading in this case would
be a tedious task of always answering the "which Stamp?" prompt. The Port directive
can be automatically inserted or modified by selecting the appropriate port from
the Directive -&gt; Port menu. The COM ports listed in the Directive -&gt; Port menu
are automatically updated any time a change is made to the exiting computer hardware
or to the available ports list (in preferences).</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>