<?xml version="1.0"?>
<?xml-stylesheet type="text/css" href="http://wiki.mcselec.com/bavr/skins/common/feed.css?303"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
		<id>http://wiki.mcselec.com/bavr/index.php?action=history&amp;feed=atom&amp;title=LOCAL</id>
		<title>LOCAL - Revision history</title>
		<link rel="self" type="application/atom+xml" href="http://wiki.mcselec.com/bavr/index.php?action=history&amp;feed=atom&amp;title=LOCAL"/>
		<link rel="alternate" type="text/html" href="http://wiki.mcselec.com/bavr/index.php?title=LOCAL&amp;action=history"/>
		<updated>2026-04-26T02:54:59Z</updated>
		<subtitle>Revision history for this page on the wiki</subtitle>
		<generator>MediaWiki 1.18.6</generator>

	<entry>
		<id>http://wiki.mcselec.com/bavr/index.php?title=LOCAL&amp;diff=5123&amp;oldid=prev</id>
		<title>Admin at 17:28, 15 June 2015</title>
		<link rel="alternate" type="text/html" href="http://wiki.mcselec.com/bavr/index.php?title=LOCAL&amp;diff=5123&amp;oldid=prev"/>
				<updated>2015-06-15T17:28:19Z</updated>
		
		<summary type="html">&lt;p&gt;&lt;/p&gt;
&lt;table class='diff diff-contentalign-left'&gt;
			&lt;col class='diff-marker' /&gt;
			&lt;col class='diff-content' /&gt;
			&lt;col class='diff-marker' /&gt;
			&lt;col class='diff-content' /&gt;
		&lt;tr valign='top'&gt;
		&lt;td colspan='2' style=&quot;background-color: white; color:black;&quot;&gt;← Nächstältere Version&lt;/td&gt;
		&lt;td colspan='2' style=&quot;background-color: white; color:black;&quot;&gt;Version vom 15. Juni 2015, 17:28 Uhr&lt;/td&gt;
		&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Zeile 42:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Zeile 42:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;A LOCAL variable is a temporary variable that is stored on the frame.&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;A LOCAL variable is a temporary variable that is stored on the frame.&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;−&lt;/td&gt;&lt;td style=&quot;background: #ffa; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;When the SUB or FUNCTION is terminated, the memory will be released back to the &lt;del class=&quot;diffchange diffchange-inline&quot;&gt;frame&lt;/del&gt;.&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;background: #cfc; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;When the SUB or FUNCTION is terminated, the memory will be released back to the &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;system.&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt;&amp;#160;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;background: #cfc; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&amp;#160;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt;&amp;#160;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;background: #cfc; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;A Sub/Function is full reentrant which means that it can be called recursively. Because of this, local memory is dynamic and not static as global variables&lt;/ins&gt;.&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;BIT variables are not possible because they are GLOBAL to the system.&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;BIT variables are not possible because they are GLOBAL to the system.&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Zeile 54:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Zeile 56:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;Notice that a LOCAL variable is not initialized. It will contain a value that will depend on the value of the FRAME data. So you can not assume the variable is 0. If you like it to be 0, you need to assign it.&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;Notice that a LOCAL variable is not initialized. It will contain a value that will depend on the value of the FRAME data. So you can not assume the variable is 0. If you like it to be 0, you need to assign it.&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;−&lt;/td&gt;&lt;td style=&quot;background: #ffa; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;A normal DIM-med variable is also not initialized to 0. The reason all variables are 0 (and strings are &amp;quot;&amp;quot;), is that the RAM memory is cleared. With the&amp;amp;nbsp;[&lt;del class=&quot;diffchange diffchange-inline&quot;&gt;http://avrhelp.mcselec.com/_noramclear.htm &lt;/del&gt;$NORAMCLEAR]&amp;amp;nbsp;option you can turn this behaviour off.&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;background: #cfc; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;A normal DIM-med variable is also not initialized to 0. The reason all variables are 0 (and strings are &amp;quot;&amp;quot;), is that the RAM memory is cleared. With the&amp;amp;nbsp;[&lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;[&lt;/ins&gt;$NORAMCLEAR&lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;]&lt;/ins&gt;]&amp;amp;nbsp;option you can turn this behaviour off.&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;So to conclude, a LOCAL variable will behave the same as a normal variable with the $NORAMCLEAR option enabled.&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;So to conclude, a LOCAL variable will behave the same as a normal variable with the $NORAMCLEAR option enabled.&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;−&lt;/td&gt;&lt;td style=&quot;background: #ffa; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&lt;del class=&quot;diffchange diffchange-inline&quot;&gt;&amp;lt;span style=&amp;quot;font-family: Arial;&amp;quot;&amp;gt;&lt;/del&gt;&amp;amp;nbsp;&lt;del class=&quot;diffchange diffchange-inline&quot;&gt;&amp;lt;/span&amp;gt;&lt;/del&gt;&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;background: #cfc; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&amp;amp;nbsp;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;−&lt;/td&gt;&lt;td style=&quot;background: #ffa; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&amp;#160;&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;background: #cfc; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;−&lt;/td&gt;&lt;td style=&quot;background: #ffa; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&lt;del class=&quot;diffchange diffchange-inline&quot;&gt;&amp;lt;span style=&amp;quot;font-family: Arial;&amp;quot;&amp;gt;While it would be simple to initialize the LOCAL variables to 0, in most/all cases, you will assign a value to it anyway, so it would be a waste of code space.&amp;lt;/span&amp;gt;&lt;/del&gt;&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;background: #cfc; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&amp;lt;span style=&amp;quot;font-family: Arial;&amp;quot;&amp;gt;&amp;amp;nbsp;&amp;lt;/span&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&amp;lt;span style=&amp;quot;font-family: Arial;&amp;quot;&amp;gt;&amp;amp;nbsp;&amp;lt;/span&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt;&amp;#160;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;background: #cfc; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;color: red; font-weight: bold; text-decoration: none;&quot;&gt;&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt;&amp;#160;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;background: #cfc; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;color: red; font-weight: bold; text-decoration: none;&quot;&gt;While it would be simple to initialize the LOCAL variables to 0, in most/all cases, you will assign a value to it anyway, so it would be a waste of code space.&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&amp;lt;span style=&amp;quot;font-family: Arial;&amp;quot;&amp;gt;&amp;amp;nbsp;&amp;lt;/span&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&amp;lt;span style=&amp;quot;font-family: Arial;&amp;quot;&amp;gt;&amp;amp;nbsp;&amp;lt;/span&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;</summary>
		<author><name>Admin</name></author>	</entry>

	<entry>
		<id>http://wiki.mcselec.com/bavr/index.php?title=LOCAL&amp;diff=750&amp;oldid=prev</id>
		<title>Admin: Created page with &quot;= &lt;span class=&quot;f_Header&quot;&gt;Action&lt;/span&gt; =  Dimensions a variable LOCAL to the function or sub program.  &lt;span style=&quot;font-family: Arial;&quot;&gt;&amp;nbsp;&lt;/span&gt;  &lt;span style=&quot;font-famil...&quot;</title>
		<link rel="alternate" type="text/html" href="http://wiki.mcselec.com/bavr/index.php?title=LOCAL&amp;diff=750&amp;oldid=prev"/>
				<updated>2013-02-11T20:10:13Z</updated>
		
		<summary type="html">&lt;p&gt;Created page with &amp;quot;= &amp;lt;span class=&amp;quot;f_Header&amp;quot;&amp;gt;Action&amp;lt;/span&amp;gt; =  Dimensions a variable LOCAL to the function or sub program.  &amp;lt;span style=&amp;quot;font-family: Arial;&amp;quot;&amp;gt; &amp;lt;/span&amp;gt;  &amp;lt;span style=&amp;quot;font-famil...&amp;quot;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;Neue Seite&lt;/b&gt;&lt;/p&gt;&lt;div&gt;= &amp;lt;span class=&amp;quot;f_Header&amp;quot;&amp;gt;Action&amp;lt;/span&amp;gt; =&lt;br /&gt;
&lt;br /&gt;
Dimensions a variable LOCAL to the function or sub program.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;span style=&amp;quot;font-family: Arial;&amp;quot;&amp;gt;&amp;amp;nbsp;&amp;lt;/span&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;span style=&amp;quot;font-family: Arial;&amp;quot;&amp;gt;&amp;amp;nbsp;&amp;lt;/span&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= &amp;lt;span class=&amp;quot;f_Header&amp;quot;&amp;gt;Syntax&amp;lt;/span&amp;gt; =&lt;br /&gt;
&lt;br /&gt;
&amp;lt;span class=&amp;quot;f_Syntax&amp;quot;&amp;gt;LOCAL&amp;lt;/span&amp;gt;&amp;amp;nbsp;var As Type&lt;br /&gt;
&lt;br /&gt;
&amp;lt;span style=&amp;quot;font-family: Arial;&amp;quot;&amp;gt;&amp;amp;nbsp;&amp;lt;/span&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;span style=&amp;quot;font-family: Arial;&amp;quot;&amp;gt;&amp;amp;nbsp;&amp;lt;/span&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= &amp;lt;span class=&amp;quot;f_Header&amp;quot;&amp;gt;Remarks&amp;lt;/span&amp;gt; =&lt;br /&gt;
&amp;lt;div style=&amp;quot;padding: 0px; margin: 0px 0px 0px 4px;&amp;quot;&amp;gt;&lt;br /&gt;
{| width=&amp;quot;488&amp;quot; cellspacing=&amp;quot;0&amp;quot; cellpadding=&amp;quot;1&amp;quot; border=&amp;quot;1&amp;quot; style=&amp;quot;border: 2px solid rgb(0, 0, 0); border-spacing: 0px; border-collapse: collapse;&amp;quot;&lt;br /&gt;
|- style=&amp;quot;vertical-align: top;&amp;quot;&lt;br /&gt;
| valign=&amp;quot;top&amp;quot; width=&amp;quot;17%&amp;quot; style=&amp;quot;width: 79px; border: 1px solid rgb(0, 0, 0);&amp;quot; | &lt;br /&gt;
Var&lt;br /&gt;
&lt;br /&gt;
| valign=&amp;quot;top&amp;quot; width=&amp;quot;100%&amp;quot; style=&amp;quot;width: 400px; border: 1px solid rgb(0, 0, 0);&amp;quot; | &lt;br /&gt;
The name of the variable&lt;br /&gt;
&lt;br /&gt;
|- style=&amp;quot;vertical-align: top;&amp;quot;&lt;br /&gt;
| valign=&amp;quot;top&amp;quot; width=&amp;quot;17%&amp;quot; style=&amp;quot;width: 79px; border: 1px solid rgb(0, 0, 0);&amp;quot; | &lt;br /&gt;
Type&lt;br /&gt;
&lt;br /&gt;
| valign=&amp;quot;top&amp;quot; width=&amp;quot;100%&amp;quot; style=&amp;quot;width: 400px; border: 1px solid rgb(0, 0, 0);&amp;quot; | &lt;br /&gt;
The data type of the variable.&lt;br /&gt;
&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;span style=&amp;quot;font-family: Arial;&amp;quot;&amp;gt;&amp;amp;nbsp;&amp;lt;/span&amp;gt;&lt;br /&gt;
&lt;br /&gt;
There can be only LOCAL variables of the type BYTE, INTEGER, WORD, DWORD, LONG, SINGLE, DOUBLE or STRING.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;span style=&amp;quot;font-family: Arial;&amp;quot;&amp;gt;&amp;amp;nbsp;&amp;lt;/span&amp;gt;&lt;br /&gt;
&lt;br /&gt;
A LOCAL variable is a temporary variable that is stored on the frame.&lt;br /&gt;
&lt;br /&gt;
When the SUB or FUNCTION is terminated, the memory will be released back to the frame.&lt;br /&gt;
&lt;br /&gt;
BIT variables are not possible because they are GLOBAL to the system.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;span style=&amp;quot;font-family: Arial;&amp;quot;&amp;gt;&amp;amp;nbsp;&amp;lt;/span&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The AT , ERAM, SRAM, XRAM directives can not be used with a local DIM statement. Also local arrays are not possible.&lt;br /&gt;
&lt;br /&gt;
&amp;amp;nbsp;&lt;br /&gt;
&lt;br /&gt;
Notice that a LOCAL variable is not initialized. It will contain a value that will depend on the value of the FRAME data. So you can not assume the variable is 0. If you like it to be 0, you need to assign it.&lt;br /&gt;
&lt;br /&gt;
A normal DIM-med variable is also not initialized to 0. The reason all variables are 0 (and strings are &amp;quot;&amp;quot;), is that the RAM memory is cleared. With the&amp;amp;nbsp;[http://avrhelp.mcselec.com/_noramclear.htm $NORAMCLEAR]&amp;amp;nbsp;option you can turn this behaviour off.&lt;br /&gt;
&lt;br /&gt;
So to conclude, a LOCAL variable will behave the same as a normal variable with the $NORAMCLEAR option enabled.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;span style=&amp;quot;font-family: Arial;&amp;quot;&amp;gt;&amp;amp;nbsp;&amp;lt;/span&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;span style=&amp;quot;font-family: Arial;&amp;quot;&amp;gt;While it would be simple to initialize the LOCAL variables to 0, in most/all cases, you will assign a value to it anyway, so it would be a waste of code space.&amp;lt;/span&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;span style=&amp;quot;font-family: Arial;&amp;quot;&amp;gt;&amp;amp;nbsp;&amp;lt;/span&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;span style=&amp;quot;font-family: Arial;&amp;quot;&amp;gt;&amp;amp;nbsp;&amp;lt;/span&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= &amp;lt;span class=&amp;quot;f_Header&amp;quot;&amp;gt;See also&amp;lt;/span&amp;gt; =&lt;br /&gt;
&lt;br /&gt;
[[DIM]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;span style=&amp;quot;font-family: Arial;&amp;quot;&amp;gt;&amp;amp;nbsp;&amp;lt;/span&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;span style=&amp;quot;font-family: Arial;&amp;quot;&amp;gt;&amp;amp;nbsp;&amp;lt;/span&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= &amp;lt;span class=&amp;quot;f_Header&amp;quot;&amp;gt;ASM&amp;lt;/span&amp;gt; =&lt;br /&gt;
&lt;br /&gt;
NONE&lt;br /&gt;
&lt;br /&gt;
&amp;lt;span style=&amp;quot;font-family: Arial;&amp;quot;&amp;gt;&amp;amp;nbsp;&amp;lt;/span&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;span style=&amp;quot;font-family: Arial;&amp;quot;&amp;gt;&amp;amp;nbsp;&amp;lt;/span&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= &amp;lt;span class=&amp;quot;f_Header&amp;quot;&amp;gt;Example&amp;lt;/span&amp;gt; =&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br/&amp;gt;&amp;lt;source lang=&amp;quot;bascomavr&amp;quot;&amp;gt;&lt;br /&gt;
'-----------------------------------------------------------------------------------------&lt;br /&gt;
'name : declare.bas&lt;br /&gt;
'copyright : (c) 1995-2005, MCS Electronics&lt;br /&gt;
'purpose : demonstrate using declare&lt;br /&gt;
'micro : Mega48&lt;br /&gt;
'suited for demo : yes&lt;br /&gt;
'commercial add on needed : no&lt;br /&gt;
' Note that the usage of SUBS works different in BASCOM-8051&lt;br /&gt;
'-----------------------------------------------------------------------------------------&lt;br /&gt;
 &lt;br /&gt;
$regfile = &amp;quot;m48def.dat&amp;quot; ' specify the used micro&lt;br /&gt;
$crystal = 4000000 ' used crystal frequency&lt;br /&gt;
$baud = 19200 ' use baud rate&lt;br /&gt;
$hwstack = 32 ' default use 32 for the hardware stack&lt;br /&gt;
$swstack = 10 ' default use 10 for the SW stack&lt;br /&gt;
$framesize = 40 ' default use 40 for the frame space&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
' First the SUB programs must be declared&lt;br /&gt;
 &lt;br /&gt;
'Try a SUB without parameters&lt;br /&gt;
Declare Sub Test2&lt;br /&gt;
 &lt;br /&gt;
'SUB with variable that can not be changed(A) and&lt;br /&gt;
'a variable that can be changed(B1), by the sub program&lt;br /&gt;
'When BYVAL is specified, the value is passed to the subprogram&lt;br /&gt;
'When BYREF is specified or nothing is specified, the address is passed to&lt;br /&gt;
'the subprogram&lt;br /&gt;
 &lt;br /&gt;
Declare Sub Test(byval A As Byte , B1 As Byte)&lt;br /&gt;
Declare Sub Testarray(byval A As Byte , B1 As Byte)&lt;br /&gt;
'All variable types that can be passed&lt;br /&gt;
'Notice that BIT variables can not be passed.&lt;br /&gt;
'BIT variables are GLOBAL to the application&lt;br /&gt;
Declare Sub Testvar(b As Byte , I As Integer , W As Word , L As Long , S As String)&lt;br /&gt;
 &lt;br /&gt;
'passing string arrays needs a different syntax because the length of the strings must be passed by the compiler&lt;br /&gt;
'the empty () indicated that an array will be passed&lt;br /&gt;
Declare Sub Teststr(b As Byte , Dl() As String)&lt;br /&gt;
 &lt;br /&gt;
Dim Bb As Byte , I As Integer , W As Word , L As Long , S As String * 10 'dim used variables&lt;br /&gt;
Dim Ar(10) As Byte&lt;br /&gt;
Dim Sar(10) As String * 8 'strng array&lt;br /&gt;
 &lt;br /&gt;
For Bb = 1 To 10&lt;br /&gt;
Sar(bb) = Str(bb) 'fill the array&lt;br /&gt;
Next&lt;br /&gt;
Bb = 1&lt;br /&gt;
'now call the sub and notice that we always must pass the first address with index 1&lt;br /&gt;
Call Teststr(bb , Sar(1))&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
Call Test2 'call sub&lt;br /&gt;
Test2 'or use without CALL&lt;br /&gt;
'Note that when calling a sub without the statement CALL, the enclosing parentheses must be left out&lt;br /&gt;
Bb = 1&lt;br /&gt;
Call Test(1 , Bb) 'call sub with parameters&lt;br /&gt;
Print Bb 'print value that is changed&lt;br /&gt;
 &lt;br /&gt;
'now test all the variable types&lt;br /&gt;
Call Testvar(bb , I , W , L , S )&lt;br /&gt;
Print Bb ; I ; W ; L ; S&lt;br /&gt;
 &lt;br /&gt;
'now pass an array&lt;br /&gt;
'note that it must be passed by reference&lt;br /&gt;
Testarray 2 , Ar(1)&lt;br /&gt;
Print &amp;quot;ar(1) = &amp;quot; ; Ar(1)&lt;br /&gt;
Print &amp;quot;ar(3) = &amp;quot; ; Ar(3)&lt;br /&gt;
 &lt;br /&gt;
$notypecheck ' turn off type checking&lt;br /&gt;
Testvar Bb , I , I , I , S&lt;br /&gt;
'you can turn off type checking when you want to pass a block of memory&lt;br /&gt;
$typecheck 'turn it back on&lt;br /&gt;
End&lt;br /&gt;
 &lt;br /&gt;
'End your code with the subprograms&lt;br /&gt;
'Note that the same variables and names must be used as the declared ones&lt;br /&gt;
 &lt;br /&gt;
Sub Test(byval A As Byte , B1 As Byte) 'start sub&lt;br /&gt;
 Print A ; &amp;quot; &amp;quot; ; B1 'print passed variables&lt;br /&gt;
 B1 = 3 'change value&lt;br /&gt;
 'You can change A, but since a copy is passed to the SUB,&lt;br /&gt;
 'the change will not reflect to the calling variable&lt;br /&gt;
End Sub&lt;br /&gt;
 &lt;br /&gt;
Sub Test2 'sub without parameters&lt;br /&gt;
 Print &amp;quot;No parameters&amp;quot;&lt;br /&gt;
End Sub&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
Sub Testvar(b As Byte , I As Integer , W As Word , L As Long , S As String)&lt;br /&gt;
 Local X As Byte&lt;br /&gt;
 X = 5 'assign local&lt;br /&gt;
 B = X&lt;br /&gt;
 I = -1&lt;br /&gt;
 W = 40000&lt;br /&gt;
 L = 20000&lt;br /&gt;
 S = &amp;quot;test&amp;quot;&lt;br /&gt;
End Sub&lt;br /&gt;
 &lt;br /&gt;
Sub Testarray(byval A As Byte , B1 As Byte) 'start sub&lt;br /&gt;
 Print A ; &amp;quot; &amp;quot; ; B1 'print passed variables&lt;br /&gt;
 B1 = 3 'change value of element with index 1&lt;br /&gt;
 B1(1) = 3 'specify the index which does the same as the line above&lt;br /&gt;
 B1(3) = 3 'modify other element of array&lt;br /&gt;
 'You can change A, but since a copy is passed to the SUB,&lt;br /&gt;
 'the change will not reflect to the calling variable&lt;br /&gt;
End Sub&lt;br /&gt;
 &lt;br /&gt;
'notice the empty() to indicate that a string array is passed&lt;br /&gt;
Sub Teststr(b As Byte , Dl() As String)&lt;br /&gt;
Dl(b) = Dl(b) + &amp;quot;add&amp;quot;&lt;br /&gt;
End Sub&lt;br /&gt;
&amp;lt;/source&amp;gt;&amp;lt;br/&amp;gt;{{Languages}}&lt;br /&gt;
&lt;br /&gt;
[[Category:BASCOM Language Reference]]&lt;/div&gt;</summary>
		<author><name>Admin</name></author>	</entry>

	</feed>