<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	>

<channel>
	<title>free-softwares.org</title>
	<atom:link href="http://free-softwares.org/feed/" rel="self" type="application/rss+xml" />
	<link>http://free-softwares.org</link>
	<description></description>
	<pubDate>Sat, 14 Jun 2008 07:03:57 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.5.1</generator>
	<language>en</language>
			<item>
		<title>How to Use Boolean operators?</title>
		<link>http://free-softwares.org/how-to-use-boolean-operators/605/</link>
		<comments>http://free-softwares.org/how-to-use-boolean-operators/605/#comments</comments>
		<pubDate>Sat, 14 Jun 2008 07:03:57 +0000</pubDate>
		<dc:creator>yudi</dc:creator>
		
		<category><![CDATA[Dealing with Branching Statements]]></category>

		<guid isPermaLink="false">http://free-softwares.org/how-to-use-boolean-operators/605/</guid>
		<description><![CDATA[
Rather than examine a single Boolean expression, your  program may need to examine two or more Boolean expressions. For example, the  following program checks the Boolean expression (Salary &#62;  500) and (Bribes &#62; 700). Only if both Boolean  expressions are true does the program print You don’t  need to pay [...]]]></description>
			<content:encoded><![CDATA[<h3 class="sect3-title"><a name="301"></a><a name="ch09lev"></a></h3>
<p class="first-para">Rather than examine a single Boolean expression, your  program may need to examine two or more Boolean expressions. For example, the  following program checks the Boolean expression <span class="fixed">(Salary &gt;  500)</span> and <span class="fixed">(Bribes &gt; 700)</span>. Only if both Boolean  expressions are true does the program print <span class="fixed">You don’t  need</span> <span class="fixed">to pay any taxes.</span>, as the following Liberty  BASIC program shows: <a name="302"></a><a name="IDX-124"></a></p>
<p class="INFORMALEXAMPLE">
<pre class="PROGRAMLISTING"><span style="background-color: #c0c0c0"><font color="#000000">
PROMPT &#8220;How much money did you make&#8221;; Salary
PROMPT &#8220;How much money did you donate to political
           candidates&#8221;; Bribes
IF (Salary &gt; 500) THEN
 IF (Bribes &gt; 700) THEN
   PRINT &#8220;You don&#8217;t need to pay any taxes.&#8221;
 END IF
END IF
END</font></span></pre>
<p class="para">Rather than force the computer to evaluate Boolean expressions one  at a time, you can get the computer to evaluate multiple Boolean expressions by  using <em class="emphasis">Boolean operators.</em> A Boolean operator does nothing  more than connect two or more Boolean expressions to represent a <span class="FIXED">True</span> or a <span class="fixed">False</span> value.</p>
<p class="PARA">The two most common Boolean operators are</p>
<ul class="SIMPLE-LIST">
<li class="first-listitem">
<p class="FIRST-PARA"><span class="inlinemediaobject"><img src="http://free-softwares.org/wp-admin/images/pt1.jpg" id="IMG_3" alt="Image from book" border="0" height="11" width="16" /></span>  <span class="fixed">AND</span></p>
</li>
<li class="LISTITEM">
<p class="first-para"><span class="inlinemediaobject"><img src="http://free-softwares.org/wp-admin/images/pt1.jpg" id="IMG_3" alt="Image from book" border="0" height="11" width="16" /></span>  <span class="fixed">OR</span></p>
</li>
</ul>
<p class="SECTION">
<h4 class="sect4-title"><a name="303"></a><a name="CH09LEV"></a>The AND operator</h4>
<p class="FIRST-PARA">The <span class="FIXED">AND</span> operator links two Boolean  expressions. By rewriting the previous program using the <span class="fixed">AND</span> operator, you can simplify the program as follows:</p>
<p class="informalexample">
<pre class="programlisting"><span style="background-color: #c0c0c0"><font color="#000000">
PROMPT &#8220;How much money did you make?&#8221;; Salary
PROMPT &#8220;How much did you donate to politicians?&#8221;; Bribes
IF (Salary &gt; 500) AND (Bribes &gt; 700) THEN
 PRINT &#8220;You don&#8217;t need to pay any taxes.&#8221;
END IF
END</font></span></pre>
<p class="PARA">In this case, the program prints the message <span class="fixed">You  don’t need to pay</span> <span class="FIXED">any taxes</span> only if both <span class="fixed">(Salary &gt; 500)</span> and <span class="fixed">(Bribes &gt;  700)</span> are true. If either Boolean expression is false, this program  doesn’t print anything.</p>
<p class="PARA">Run the preceding program and use the values in <a href="#ch09t" class="internaljump">Table 9-2</a> to see what happens.</p>
<p><a name="304"></a><a name="CH09T"></a></p>
<table class="TABLE" id="ch09table02" linktabletoexcel="yes" border="1">
<thead>
<th class="TH" scope="col" align="left" valign="top">
<p class="TABLE-PARA"><em class="emphasis"><strong class="bold">Value of Salary</strong></em></p>
</th>
<th class="th" scope="col" align="left" valign="top">
<p class="table-para"><em class="emphasis"><strong class="BOLD">Value of Bribes</strong></em></p>
</th>
<th class="th" scope="col" align="left" valign="top">
<p class="TABLE-PARA"><em class="emphasis"><strong class="bold">What the Program  Does</strong></em></p>
</th>
</tr>
</table>
<p class="PARA"><font color="#ffffff"><strong class="bold"><span style="background-color: #000080">Remember</span></strong></font> The <span class="fixed">AND</span> operator can represent a <span class="FIXED">True</span>  value only if both Boolean expressions that it connects also are true. <a name="305"></a><a name="IDX-"></a></p>
<p class="PARA"><font color="#ffffff"><strong class="bold"><span style="background-color: #000080">Technical Stuff</span></strong></font> To show how  the <span class="FIXED">AND</span> operator works, programmers like to draw  something known as a <em class="emphasis">truth table,</em> which tells you whether  two Boolean expressions that the <span class="FIXED">AND</span> operator connects  represent a <span class="fixed">True</span> or a <span class="FIXED">False</span>  value. <a href="#ch09t" class="INTERNALJUMP">Table 9-3</a> is a truth table  listing the values for the following two Boolean expressions:</p>
<p class="INFORMALEXAMPLE">
<pre class="programlisting"><span style="background-color: #c0c0c0"><font color="#000000">
(Boolean expression 1) AND (Boolean expression 2)</font></span></pre>
<p><a name="306"></a><a name="ch09t"></a></p>
<table class="TABLE" id="ch09table03" linktabletoexcel="yes" border="1">
<thead>
<th class="th" scope="col" align="left" valign="top">
<p class="table-para"><em class="EMPHASIS"><strong class="BOLD">Value of (Boolean Expression  1)</strong></em></p>
</th>
<th class="TH" scope="col" align="left" valign="top">
<p class="table-para"><em class="EMPHASIS"><strong class="bold">Value of (Boolean Expression  2)</strong></em></p>
</th>
<th class="th" scope="col" align="left" valign="top">
<p class="table-para"><em class="EMPHASIS"><strong class="bold">Value of the Entire (Boolean  Expression 1) AND (Boolean Expression 2)</strong></em></p>
</th>
</tr>
</table>
<p class="PARA">The equivalent Revolution program looks similar to the Liberty  BASIC version. The only main differences are the commands used to ask the user  to type data. In the following Revolution program, the <span class="fixed">ask</span> command asks the user to type an answer, which gets  stored temporarily in the <span class="FIXED">it</span> variable, which you must  then store in a more descriptive variable:</p>
<p class="INFORMALEXAMPLE">
<pre class="programlisting"><span style="background-color: #c0c0c0"><font color="#000000">
ask &#8220;How much money did you make?&#8221;
put it into Salary
ask &#8220;How much did you donate to politicians?&#8221;
put it into Bribes
if (Salary &gt; 500) and (Bribes &gt; 700) then
  put &#8220;You don&#8217;t need to pay any taxes.&#8221; into message
end if</font></span></pre>
<p class="PARA"><font color="#ffffff"><strong class="bold"><span style="background-color: #000080">Technical Stuff</span></strong></font> In C++, the  <span class="fixed">AND</span> operator consists of a double ampersand symbol  (<span class="fixed">&amp;&amp;</span>), as in this example:</p>
<p class="informalexample">
<pre class="programlisting"><span style="background-color: #c0c0c0"><font color="#000000">
(Boolean expression 1) &amp;&amp; (Boolean expression 2)</font></span></pre>
<p class="para"><font color="#ffffff"><strong class="bold"><span style="background-color: #8b0000">Warning!</span></strong></font> Notice that C++  uses the double ampersand to represent the Boolean <span class="FIXED">AND</span>  operator, but Revolution uses the double ampersand to concatenate strings. When  using different programming languages, watch out for ways that different  languages use identical symbols or commands that mean entirely different  things.</p>
<p><a name="307"></a><a name="IDX-126"></a></p>
<p class="PARA">The following code shows the equivalent C++ program:</p>
<p class="informalexample">
<pre class="programlisting"><span style="background-color: #c0c0c0"><font color="#000000">
#include &lt;iostream.h&gt;
#include &lt;stdio.h&gt;
int main()
{
   int Salary;
   int Bribes;
   cout &lt;&lt; &#8220;How much money did you make? &#8220;;
   cin &gt;&gt; Salary;
   cout &lt;&lt; &#8220;How much did you donate to politicians? &#8220;;
   cin &gt;&gt; Bribes;
   if ((Salary &gt; 500) &amp;&amp; (Bribes &gt; 700))
   {
   cout &lt;&lt; &#8220;You don&#8217;t need to pay any taxes.&#8221;;
   }
   cout &lt;&lt; &#8220;\nPress ENTER to continue&#8230;&#8221; &lt;&lt; endl;
   getchar();
   return 0;
}</font></span></pre>
<p class="SECTION">
<h4 class="sect4-title"><a name="308"></a><a name="CH09LEV"></a>The OR operator</h4>
<p class="first-para">The <span class="fixed">OR</span> operator links two Boolean  expressions but produces a <span class="FIXED">True</span> value if either Boolean  expression represents a <span class="fixed">True</span> value. For an example of  how this operator works, run the following program:</p>
<p class="informalexample">
<pre class="programlisting"><span style="background-color: #c0c0c0"><font color="#000000">
PROMPT &#8220;How far can you throw a football&#8221;; Football
PROMPT &#8220;What is your IQ&#8221;; IQ
IF (Football &gt; 50) OR (IQ &lt;= 45) THEN
 PRINT &#8220;You have what it takes to become a professional!&#8221;
END IF
END</font></span></pre>
<p class="PARA">In this case, the program prints the message <span class="fixed">You  have what it takes</span> <span class="FIXED">to become a professional!</span> if  either <span class="FIXED">(Football &gt; 50)</span> is true or <span class="FIXED">(IQ</span> <span class="fixed">&lt;= 45)</span> is true. Only if both  Boolean expressions are false does the program refuse to print anything.</p>
<p class="para">Run the preceding program and use the values in <a href="#ch09t" class="internaljump">Table 9-4</a> to see what happens. <a name="309"></a><a name="IDX-127"></a></p>
<p><a name="310"></a><a name="ch09table04"></a></p>
<table class="TABLE" id="ch09table04" linktabletoexcel="yes" border="1">
<thead>
<th class="TH" scope="col" align="left" valign="top">
<p class="TABLE-PARA"><em class="emphasis"><strong class="bold">Value of Football</strong></em></p>
</th>
<th class="TH" scope="col" align="left" valign="top">
<p class="table-para"><em class="EMPHASIS"><strong class="BOLD">Value of IQ</strong></em></p>
</th>
<th class="th" scope="col" align="left" valign="top">
<p class="table-para"><em class="emphasis"><strong class="bold">What the Program  Does</strong></em></p>
</th>
</tr>
</table>
<p class="PARA"><font color="#ffffff"><strong class="bold"><span style="background-color: #000080">Remember</span></strong></font> The <span class="fixed">OR</span> operator can represent a <span class="fixed">False</span>  value only if both Boolean expressions that it connects are false.</p>
<p class="para"><a href="#ch09t" class="INTERNALJUMP">Table 9-5</a> is a truth table  to show how the <span class="FIXED">OR</span> operator works for Boolean  expressions in the following example:</p>
<p class="informalexample">
<pre class="programlisting"><span style="background-color: #c0c0c0"><font color="#000000">
(Boolean expression 1) OR (Boolean expression 2)</font></span></pre>
<p><a name="311"></a><a name="CH09T"></a></p>
<table class="TABLE" id="ch09table05" linktabletoexcel="yes" border="1">
<thead>
<th class="TH" scope="col" align="left" valign="top">
<p class="table-para"><em class="EMPHASIS"><strong class="BOLD">Value of (Boolean Expression  1)</strong></em></p>
</th>
<th class="TH" scope="col" align="left" valign="top">
<p class="table-para"><em class="emphasis"><strong class="BOLD">Value of (Boolean Expression  2)</strong></em></p>
</th>
<th class="th" scope="col" align="left" valign="top">
<p class="TABLE-PARA"><em class="EMPHASIS"><strong class="bold">Value of the Entire (Boolean  Expression 1) OR (Boolean Expression 2)</strong></em></p>
</th>
</tr>
</table>
<p class="para"><font color="#ffffff"><strong class="BOLD"><span style="background-color: #000080">Technical Stuff</span></strong></font> In C++, the  <span class="fixed">OR</span> operator consists of a double vertical line symbol  (<span class="FIXED">||</span>), as shown here:</p>
<p class="informalexample">
<pre class="programlisting"><span style="background-color: #c0c0c0"><font color="#000000">
(Boolean expression 1) || (Boolean expression 2)</font></span></pre>
<p class="para">Here’s the equivalent C++ program: <a name="312"></a><a name="IDX-"></a></p>
<p class="INFORMALEXAMPLE">
<pre class="PROGRAMLISTING"><span style="background-color: #c0c0c0"><font color="#000000">
#include &lt;iostream.h&gt;
#include &lt;stdio.h&gt;
int main()
{
   int Football;
   int IQ;
   cout &lt;&lt; &#8220;How far can you throw a football? &#8220;;
   cin &gt;&gt; Football;
   cout &lt;&lt; &#8220;What is your IQ? &#8220;;
   cin &gt;&gt; IQ;
   if ((Football &gt; 50) || (IQ &lt;= 45))
   {
   cout &lt;&lt; &#8220;You have what it takes to become a
           professional!&#8221;;
   }
   cout &lt;&lt; &#8220;\nPress ENTER to continue&#8230;&#8221; &lt;&lt; endl;
   getchar();
   return 0;
   }</font></span></pre>
<script type="text/javascript">
  addthis_url    = 'http%3A%2F%2Ffree-softwares.org%2Fhow-to-use-boolean-operators%2F605%2F';
  addthis_title  = 'How+to+Use+Boolean+operators%3F';
  addthis_pub    = '';
</script><script type="text/javascript" src="http://s7.addthis.com/js/addthis_widget.php?v=12" ></script>
]]></content:encoded>
			<wfw:commentRss>http://free-softwares.org/how-to-use-boolean-operators/605/feed/</wfw:commentRss>
		</item>
		<item>
		<title>How to use variables in Boolean expressions?</title>
		<link>http://free-softwares.org/how-to-use-variables-in-boolean-expressions/604/</link>
		<comments>http://free-softwares.org/how-to-use-variables-in-boolean-expressions/604/#comments</comments>
		<pubDate>Sat, 14 Jun 2008 07:02:54 +0000</pubDate>
		<dc:creator>yudi</dc:creator>
		
		<category><![CDATA[Dealing with Branching Statements]]></category>

		<guid isPermaLink="false">http://free-softwares.org/how-to-use-variables-in-boolean-expressions/604/</guid>
		<description><![CDATA[

The sample program in the preceding section uses a Boolean  expression (4 &#60; 54) that’s fairly useless because  it’s always true. Every time that you run the program, it just prints the  message Slap him on the wrist and let  him go.
For greater flexibility, Boolean expressions usually compare two  variables [...]]]></description>
			<content:encoded><![CDATA[<p class="SECTION">
<h3 class="sect3-title"><a name="299"></a><a name="CH09LEV2SEC80"></a></h3>
<p class="FIRST-PARA">The sample program in the preceding section uses a Boolean  expression <span class="FIXED">(4 &lt; 54)</span> that’s fairly useless because  it’s always true. Every time that you run the program, it just prints the  message <span class="FIXED">Slap him on the wrist and</span> <span class="fixed">let  him go.</span></p>
<p class="para">For greater flexibility, Boolean expressions usually compare two  variables or one variable to a fixed value, as in the following examples: <a name="300"></a><a name="idx-123"></a></p>
<p class="INFORMALEXAMPLE">
<pre class="programlisting"><span style="background-color: #c0c0c0"><font color="#000000">
(MyIQ &gt;= AnotherIQ)
(Taxes &lt; 100000)</font></span></pre>
<p class="PARA">The value of the first Boolean expression <span class="fixed">(MyIQ  &lt; AnotherIQ)</span> depends on the value of the two variables <span class="fixed">MyIQ</span> and <span class="fixed">AnotherIQ</span>. Run the  following Liberty BASIC program to see how it follows a different set of  instructions, depending on the value of the <span class="FIXED">MyIQ</span> and  <span class="fixed">AnotherIQ</span> variables:</p>
<p class="INFORMALEXAMPLE">
<pre class="programlisting"><span style="background-color: #c0c0c0"><font color="#000000">
PROMPT &#8220;What is your IQ&#8221;; MyIQ
PROMPT &#8220;What is the IQ of another person&#8221;; AnotherIQ
IF (MyIQ &gt;= AnotherIQ) THEN
 PRINT &#8220;I&#8217;m smarter than you are.&#8221;
END IF
IF (MyIQ &lt; AnotherIQ) THEN
 PRINT &#8220;You have a higher IQ to make up for your lack of
           common sense.&#8221;
END IF
END</font></span></pre>
<p class="PARA">If you run this program and type different values for <span class="FIXED">MyIQ</span> and <span class="FIXED">AnotherIQ</span>, the program  behaves in two possible ways: printing on-screen either <span class="fixed">I’m</span> <span class="FIXED">smarter than you are.</span> or <span class="fixed">You have a higher IQ to make up for</span> <span class="FIXED">your  lack of common sense.</span></p>
<p class="LAST-PARA"><font color="#ffffff"><strong class="bold"><span style="background-color: #000080">Remember</span></strong></font> By using variables  in Boolean expressions, you give your program the flexibility it needs to handle  different data.</p>
<script type="text/javascript">
  addthis_url    = 'http%3A%2F%2Ffree-softwares.org%2Fhow-to-use-variables-in-boolean-expressions%2F604%2F';
  addthis_title  = 'How+to+use+variables+in+Boolean+expressions%3F';
  addthis_pub    = '';
</script><script type="text/javascript" src="http://s7.addthis.com/js/addthis_widget.php?v=12" ></script>
]]></content:encoded>
			<wfw:commentRss>http://free-softwares.org/how-to-use-variables-in-boolean-expressions/604/feed/</wfw:commentRss>
		</item>
		<item>
		<title>How to store Boolean expressions in variables?</title>
		<link>http://free-softwares.org/how-to-store-boolean-expressions-in-variables/603/</link>
		<comments>http://free-softwares.org/how-to-store-boolean-expressions-in-variables/603/#comments</comments>
		<pubDate>Sat, 14 Jun 2008 07:02:18 +0000</pubDate>
		<dc:creator>yudi</dc:creator>
		
		<category><![CDATA[Dealing with Branching Statements]]></category>

		<guid isPermaLink="false">http://free-softwares.org/how-to-store-boolean-expressions-in-variables/603/</guid>
		<description><![CDATA[

Many programming languages let you define a variable as a  Boolean data type.
In REALbasic, you can define a variable as a Boolean data type  like this: 


Dim Guilty As Boolean
In C++, you can define a variable as a Boolean data type like  this:


bool Guilty;
Remember You can just stuff  a Boolean expression [...]]]></description>
			<content:encoded><![CDATA[<p class="SECTION">
<h3 class="SECT3-TITLE"><a name="297"></a><a name="ch09lev2sec79"></a></h3>
<p class="first-para">Many programming languages let you define a variable as a  Boolean data type.</p>
<p class="PARA">In REALbasic, you can define a variable as a Boolean data type  like this: <a name="298"></a><a name="IDX-"></a></p>
<p class="INFORMALEXAMPLE">
<pre class="programlisting"><span style="background-color: #c0c0c0"><font color="#000000">
Dim Guilty As Boolean</font></span></pre>
<p class="PARA">In C++, you can define a variable as a Boolean data type like  this:</p>
<p class="informalexample">
<pre class="PROGRAMLISTING"><span style="background-color: #c0c0c0"><font color="#000000">
bool Guilty;</font></span></pre>
<p class="para"><font color="#ffffff"><strong class="BOLD"><span style="background-color: #000080">Remember</span></strong></font> You can just stuff  a Boolean expression into a variable in Liberty BASIC and Revolution because  neither of these languages forces you to declare your variables ahead of time  like C++ or REALbasic.</p>
<p class="PARA">You can then assign a Boolean expression to a variable in the  following way:</p>
<p class="INFORMALEXAMPLE">
<pre class="programlisting"><span style="background-color: #c0c0c0"><font color="#000000">
Guilty = (4 &lt; 54)</font></span></pre>
<p class="para">This example assigns the value of <span class="FIXED">True</span> to  the variable <span class="fixed">Guilty</span><em class="EMPHASIS">.</em> The  preceding statement tells the computer, “The Boolean expression of <span class="FIXED">(4 &lt; 54)</span> is true. Thus the value of the <span class="fixed">Guilty</span> variable is <span class="fixed">True</span>.”</p>
<p class="para">To see how a variable can hold a Boolean value, try the following  Liberty BASIC program:</p>
<p class="INFORMALEXAMPLE">
<pre class="PROGRAMLISTING"><span style="background-color: #c0c0c0"><font color="#000000">
Guilty = (4 &lt; 54)
IF Guilty THEN
 PRINT &#8220;Slap him on the wrist and let him go.&#8221;
END IF
END</font></span></pre>
<p class="PARA">Each time that you run the preceding program, it prints the  message <span class="fixed">Slap</span> <span class="FIXED">him on the wrist and let  him go.</span></p>
<p class="para">Here’s what the equivalent program looks like in Revolution:</p>
<p class="informalexample">
<pre class="programlisting"><span style="background-color: #c0c0c0"><font color="#000000">
put 4 &lt; 54 into Guilty
if Guilty then
  put &#8220;Slap him on the wrist and let him go.&#8221; into message
end if</font></span></pre>
<script type="text/javascript">
  addthis_url    = 'http%3A%2F%2Ffree-softwares.org%2Fhow-to-store-boolean-expressions-in-variables%2F603%2F';
  addthis_title  = 'How+to+store+Boolean+expressions+in+variables%3F';
  addthis_pub    = '';
</script><script type="text/javascript" src="http://s7.addthis.com/js/addthis_widget.php?v=12" ></script>
]]></content:encoded>
			<wfw:commentRss>http://free-softwares.org/how-to-store-boolean-expressions-in-variables/603/feed/</wfw:commentRss>
		</item>
		<item>
		<title>How to Use Boolean Expressions</title>
		<link>http://free-softwares.org/how-to-use-boolean-expressions/602/</link>
		<comments>http://free-softwares.org/how-to-use-boolean-expressions/602/#comments</comments>
		<pubDate>Sat, 14 Jun 2008 06:32:46 +0000</pubDate>
		<dc:creator>yudi</dc:creator>
		
		<category><![CDATA[Dealing with Branching Statements]]></category>

		<guid isPermaLink="false">http://free-softwares.org/how-to-use-boolean-expressions/602/</guid>
		<description><![CDATA[
To make any decision, you first need to ask a question such  as, “Do I feel like eating a hamburger?” If the answer is yes, you go to a  restaurant that serves hamburgers. If the answer is no, you eat something else.  
Computers work in a similar way. Although people can ask [...]]]></description>
			<content:encoded><![CDATA[<h2 class="first-section-title"><a name="293"></a><a name="ch09lev"></a></h2>
<p class="first-para">To make any decision, you first need to ask a question such  as, “Do I feel like eating a hamburger?” If the answer is yes, you go to a  restaurant that serves hamburgers. If the answer is no, you eat something else.  <a name="294"></a><a name="IDX-"></a></p>
<p class="PARA">Computers work in a similar way. Although people can ask  questions, computers check something called a <em class="emphasis">Boolean  expression.</em> A Boolean expression is a computer’s way of asking a Yes or No  question.</p>
<p class="para"><font color="#ffffff"><strong class="BOLD"><span style="background-color: #000080">Technical Stuff</span></strong></font> Boolean  expressions are part of Boolean algebra, which was named after a man by the name  of George Boole. (If you study hard and create your own branch of mathematics,  someone may name it after you, too.)</p>
<p class="PARA">Boolean expressions compare two values. An expression can be  either true or false, as shown in <a href="#ch09table01" class="INTERNALJUMP">Table 9-1</a>.</p>
<p><a name="295"></a><a name="ch09table01"></a></p>
<table class="TABLE" id="ch09table01" linktabletoexcel="yes" border="1">
<thead>
<th class="TH" scope="col" align="left" valign="top">
<p class="TABLE-PARA"><em class="emphasis"><strong class="bold">Boolean Expression</strong></em></p>
</th>
<th class="TH" scope="col" align="left" valign="top">
<p class="table-para"><em class="EMPHASIS"><strong class="BOLD">What It Means</strong></em></p>
</th>
<th class="th" scope="col" align="left" valign="top">
<p class="table-para"><em class="emphasis"><strong class="BOLD">Boolean Value</strong></em></p>
</th>
</tr>
</table>
<p class="PARA"><font color="#ffffff"><strong class="bold"><span style="background-color: #000080">Technical Suff</span></strong></font> Symbols such  as <span class="FIXED">&lt;</span>, <span class="fixed">&gt;</span>, <span class="fixed">=</span>, <span class="FIXED">&lt;=</span>, <span class="fixed">&gt;=</span>, and <span class="fixed">&lt;&gt;</span> are known as <em class="emphasis">relational operators.</em></p>
<p class="PARA"><font color="#ffffff"><strong class="bold"><span style="background-color: #8b0000">Warning!</span></strong></font> In most programming  languages, you can use the equal sign to test a Boolean expression such as <span class="FIXED">(MyIQ = 120)</span>. However in C++ (and other C-derivative  languages like Perl), you must use the double equal sign symbol (<span class="FIXED">==</span>) to test for equality such as <span class="FIXED">(MyIQ ==  120)</span>. If you use a single equal sign, your C++ program won’t work  right.</p>
<p class="para">A Boolean expression isn’t very useful by itself, so programmers  often use it in branching statements to determine which set (or branch) of  instructions the computers should follow at any given time.</p>
<p class="para">The simplest type of a branching statement is called an <span class="fixed">IF-THEN</span> statement, which offers one alternative set of  instructions to follow if a certain Boolean expression is true. An <span class="FIXED">IF-THEN</span> statement typically looks like this: <a name="296"></a><a name="idx-"></a></p>
<p class="INFORMALEXAMPLE">
<pre class="programlisting"><span style="background-color: #c0c0c0"><font color="#000000">
IF (Boolean expression is True) THEN
<em class="emphasis">   One or more instructions</em>
END IF</font></span></pre>
<p class="PARA"><font color="#ffffff"><strong class="bold"><span style="background-color: #000080">Technical Stuff</span></strong></font> In C++, an  <span class="FIXED">IF-THEN</span> statement looks slightly different:</p>
<p class="INFORMALEXAMPLE">
<pre class="programlisting"><span style="background-color: #c0c0c0"><font color="#000000">
if (Boolean expression is True)
   {
<em class="emphasis">           One or more instructions</em>
   }</font></span></pre>
<p class="PARA">In C++, the two big differences are that the word <span class="fixed">THEN</span> is not used and that you must enclose any instructions  to follow within curly brackets.</p>
<p class="PARA">To see how <span class="FIXED">IF-THEN</span> statements work, look  at the following Liberty BASIC program:</p>
<p class="informalexample">
<pre class="programlisting"><span style="background-color: #c0c0c0"><font color="#000000">
IF (4 &lt; 54) THEN                                  <span class="unicode">?</span><strong class="bold">1</strong>
 PRINT &#8220;This prints on-screen.&#8221;                   <span class="unicode">?</span><strong class="BOLD">2</strong>
END IF                                            <span class="unicode">?</span><strong class="BOLD">3</strong>
END                                               <span class="unicode">?</span><strong class="bold">4</strong></font></span></pre>
<p class="para">This Liberty BASIC program tells the computer to do the  following:</p>
<ul class="simple-list">
<li class="first-listitem">
<p class="first-para"><span class="unicode">?</span><span class="fixed"><strong class="bold">1</strong></span> Tells the computer to evaluate the Boolean expression  <span class="fixed">(4 &lt; 54)</span>. Because this is true (<span class="fixed">4</span> is less than <span class="fixed">54</span>), the computer can  proceed to the second line.</p>
</li>
<li class="listitem">
<p class="first-para"><span class="unicode">?</span><span class="fixed"><strong class="bold">2</strong></span> Tells the computer to print the message <span class="fixed">This prints on-screen.</span></p>
</li>
<li class="listitem">
<p class="first-para"><span class="unicode">?</span><span class="fixed"><strong class="bold">3</strong></span> Identifies the end of the <span class="fixed">IF-THEN</span> statement.</p>
</li>
<li class="listitem">
<p class="first-para"><span class="unicode">?</span><span class="FIXED"><strong class="BOLD">4</strong></span> Tells the computer that the program is at an  end.</p>
</li>
</ul>
<p class="para">To see how <span class="fixed">IF-THEN</span> statements work in  C++, look over the following equivalent program:</p>
<p class="informalexample">
<pre class="programlisting"><span style="background-color: #c0c0c0"><font color="#000000">
if (4 &lt; 54)
   {
   cout &lt;&lt; &#8220;This prints out on-screen.&#8221;;
   }</font></span></pre>
<script type="text/javascript">
  addthis_url    = 'http%3A%2F%2Ffree-softwares.org%2Fhow-to-use-boolean-expressions%2F602%2F';
  addthis_title  = 'How+to+Use+Boolean+Expressions';
  addthis_pub    = '';
</script><script type="text/javascript" src="http://s7.addthis.com/js/addthis_widget.php?v=12" ></script>
]]></content:encoded>
			<wfw:commentRss>http://free-softwares.org/how-to-use-boolean-expressions/602/feed/</wfw:commentRss>
		</item>
		<item>
		<title>How to Convert Strings into Numbers (And Vice Versa)</title>
		<link>http://free-softwares.org/how-to-convert-strings-into-numbers-and-vice-versa/601/</link>
		<comments>http://free-softwares.org/how-to-convert-strings-into-numbers-and-vice-versa/601/#comments</comments>
		<pubDate>Sat, 14 Jun 2008 06:31:36 +0000</pubDate>
		<dc:creator>yudi</dc:creator>
		
		<category><![CDATA[Number and Strings]]></category>

		<guid isPermaLink="false">http://free-softwares.org/how-to-convert-strings-into-numbers-and-vice-versa/601/</guid>
		<description><![CDATA[

A string can consist of letters, symbols, and numbers. The  most common use for storing numbers as a string is when the numbers represent  something special, such as a telephone number or address. If you want the  computer to print a telephone number, you must store that number as a string, as [...]]]></description>
			<content:encoded><![CDATA[<p class="section">
<h2 class="first-section-title"><a name="282"></a><a name="ch08lev"></a></h2>
<p class="first-para">A string can consist of letters, symbols, and numbers. The  most common use for storing numbers as a string is when the numbers represent  something special, such as a telephone number or address. If you want the  computer to print a telephone number, you must store that number as a string, as  shown here:</p>
<p class="informalexample">
<pre class="programlisting"><span style="background-color: #c0c0c0"><font color="#000000">
PRINT &#8220;555-1212&#8243;</font></span></pre>
<p class="para">This command prints the string <span class="fixed">555</span>-<span class="fixed">1212</span> on-screen. The quotation marks tell the computer,  “Anything inside the quotation marks is a string.” What happens if you try the  following command? <a name="283"></a><a name="IDX-"></a></p>
<p class="informalexample">
<pre class="programlisting"><span style="background-color: #c0c0c0"><font color="#000000">
PRINT 555-1212</font></span></pre>
<p class="para">Liberty BASIC interprets this command to mean, “Subtract the  number 1,212 from the number 555 and print the result (which is –657)  on-screen.”</p>
<p class="para">Although the number <span class="fixed">53</span> and the string  <span class="fixed">“53”</span> may look identical to a human, computers treat  numbers as entirely different from strings. To a computer, the number <span class="fixed">53</span> is as completely different from the string <span class="fixed">“53”</span> as a painting of a cat is different from a real cat.</p>
<p class="section">
<h3 class="sect3-title"><a name="284"></a><a name="ch08lev"></a>Converting strings  into numbers</h3>
<p class="first-para">The problem with strings is that when users enter numbers,  the computer may treat those numbers as strings, but your program may need to  use those numbers as data. If a program stores a number as a string but needs to  use that number as data, the program needs to convert that number (as a string)  into data.</p>
<p class="para">To convert a string into data, most programming languages come  with special string-to-data and data-to-string conversion commands. In Liberty  BASIC, you can convert a string into a number by using the <span class="fixed">VAL</span> function, which works like this:</p>
<p class="informalexample">
<pre class="programlisting"><span style="background-color: #c0c0c0"><font color="#000000">
VAL(&#8221;String&#8221;)</font></span></pre>
<p class="para">The <span class="fixed">VAL</span> function tells Liberty BASIC,  “Take a string (such as <span class="fixed">“45”</span>) and turn it into a  number.” If you have a string <span class="fixed">“45”</span> and use the <span class="fixed">VAL</span> function, Liberty BASIC converts that string <span class="fixed">“45”</span> into the number <span class="fixed">45</span>.</p>
<p class="para"><font color="#ffffff"><strong class="bold"><span style="background-color: #000080">Remember</span></strong></font> If you use the  <span class="fixed">VAL</span> function on a string that doesn’t represent a  number, such as the string <span class="fixed">“Hello!”</span>, the <span class="fixed">VAL</span> function returns a zero value.</p>
<p class="para">To see how the <span class="fixed">VAL</span> function works, run  the following Liberty BASIC program:</p>
<p class="informalexample">
<pre class="programlisting"><span style="background-color: #c0c0c0"><font color="#000000">
YearBorn$ = &#8220;1964&#8243;                                <span class="unicode">?</span><strong class="bold">1</strong>
PRINT &#8220;You were born in &#8221; + YearBorn$             <span class="unicode">?</span><strong class="bold">2</strong>
Age = 2007 - VAL(YearBorn$)                       <span class="unicode">?</span><strong class="bold">3</strong>
PRINT &#8220;In 2007, you were this old = &#8220;; Age        <span class="unicode">?</span><strong class="bold">4</strong>
END <span class="unicode">?</span><strong class="bold">5</strong></font></span></pre>
<p class="para">This Liberty BASIC program tells the computer to do the  following:</p>
<ul class="simple-list">
<li class="first-listitem">
<p class="first-para"><span class="unicode">?</span><span class="fixed"><strong class="bold">1</strong></span> Creates a string variable called <span class="fixed">YearBorn$</span> and stuffs it with the string <span class="fixed">“1964”</span>.</p>
</li>
<li class="listitem">
<p class="first-para"><span class="unicode">?</span><span class="fixed"><strong class="bold">2</strong></span> Prints the string <span class="fixed">“You were born in  ”</span> followed by the string stored in the <span class="fixed">YearBorn$</span>  variable, so the entire line prints <span class="fixed">You</span> <a name="285"></a><a name="IDX-"></a><span class="fixed">were born in 1964</span>. In  this line, the computer treats <span class="fixed">“1964”</span> as a string.</p>
</li>
<li class="listitem">
<p class="first-para"><span class="unicode">?</span><span class="fixed"><strong class="bold">3</strong></span> The <span class="fixed">VAL</span> function converts the  string <span class="fixed">“1964”</span> to the number <span class="fixed">1964</span>. Then it subtracts <span class="fixed">1964</span> from  <span class="fixed">2007</span> and stores the calculated result in the <span class="fixed">Age</span> variable.</p>
</li>
<li class="listitem">
<p class="first-para"><span class="unicode">?</span><span class="fixed"><strong class="bold">4</strong></span> Prints the string <span class="fixed">In 2007, you were  this old =</span> and then prints the number stored in the <span class="fixed">Age</span> variable, which is <span class="fixed">2007</span> – <span class="fixed">1964</span> (<span class="fixed">43</span>).</p>
</li>
<li class="listitem">
<p class="first-para"><span class="unicode">?</span><span class="fixed"><strong class="bold">5</strong></span> This line marks the end of the program.</p>
</li>
</ul>
<p class="para">REALbasic uses the same <span class="fixed">Val</span> function to  convert a string into data, as shown here:</p>
<p class="informalexample">
<pre class="programlisting"><span style="background-color: #c0c0c0"><font color="#000000">
Dim YearBorn as string                            <span class="unicode">?</span><strong class="bold">1</strong>
Dim Age as integer                                <span class="unicode">?</span><strong class="bold">2</strong>
YearBorn = &#8220;1964&#8243;                                 <span class="unicode">?</span><strong class="bold">3</strong>
MsgBox &#8220;You were born in &#8221; + YearBorn             <span class="unicode">?</span><strong class="bold">4</strong>
Age = 2007 - Val(YearBorn)                        <span class="unicode">?</span><strong class="bold">5</strong>
MsgBox &#8220;In 2007, you were this old = &#8221; + Str(Age) <span class="unicode">?</span><strong class="bold">6</strong></font></span></pre>
<p class="para">This REALbasic program tells the computer to do the following:</p>
<ul class="simple-list">
<li class="first-listitem">
<p class="first-para"><span class="unicode">?</span><span class="fixed"><strong class="bold">1</strong></span> Creates a string variable called <span class="fixed">YearBorn</span>.</p>
</li>
<li class="listitem">
<p class="first-para"><span class="unicode">?</span><span class="fixed"><strong class="bold">2</strong></span> Creates an integer variable called <span class="fixed">Age</span>.</p>
</li>
<li class="listitem">
<p class="first-para"><span class="unicode">?</span><span class="fixed"><strong class="bold">3</strong></span> Stores the string <span class="fixed">“1964”</span> into  the <span class="fixed">YearBorn</span> string variable.</p>
</li>
<li class="listitem">
<p class="first-para"><span class="unicode">?</span><span class="fixed"><strong class="bold">4</strong></span> Uses the <span class="fixed">MsgBox</span> command to  display a box on-screen that shows the string <span class="fixed">“You were born  in “</span> followed by the string stored in the <span class="fixed">YearBorn</span> variable, so the entire line prints <span class="fixed">You were born</span> <span class="fixed">in 1964</span>. In this line,  the computer treats <span class="fixed">“1964”</span> as a string.</p>
</li>
<li class="listitem">
<p class="first-para"><span class="unicode">?</span><span class="fixed"><strong class="bold">5</strong></span> The <span class="fixed">Val</span> function converts the  string <span class="fixed">“1964”</span> to the number <span class="fixed">1964</span>. Then it subtracts <span class="fixed">1964</span> from  <span class="fixed">2007</span> and stores the calculated result (<span class="fixed">43</span>) in the <span class="fixed">Age</span> variable.</p>
</li>
<li class="listitem">
<p class="first-para"><span class="unicode">?</span><span class="fixed"><strong class="bold">6</strong></span> Uses the <span class="fixed">MsgBox</span> command to  display a box on-screen that shows the string <span class="fixed">In 2007, you  were this old =</span> and then uses the <span class="fixed">Str</span> function  to convert the <span class="fixed">Age</span> variable (<span class="fixed">43</span>) to the string <span class="fixed">“43”</span>. So the  entire line prints out <span class="fixed">In 2007, you were this old =  43</span>.</p>
</li>
</ul>
<p class="para">One problem with type-safe languages like REALbasic is that they  restrict what type of data can go into variables (to prevent errors in your  program), but they can also make programming more cumbersome when you want to  treat a number as both a string and data. <a name="286"></a><a name="IDX-"></a></p>
<p class="para">The following Revolution program automatically detects when a  number should be treated as a string and when it should be treated as data.  Although this has the potential for causing errors, it also gives you the  freedom to concentrate on the logic of your program and not worry about trivial  details like converting strings into data (and vice versa).</p>
<p class="informalexample">
<pre class="programlisting"><span style="background-color: #c0c0c0"><font color="#000000">
put &#8220;1964&#8243; into YearBorn                                 <span class="unicode">?</span><strong class="bold">1</strong>
put &#8220;You were born in &#8221; &amp;&amp; YearBorn into message         <span class="unicode">?</span><strong class="bold">2</strong>
wait for 5 seconds                                       <span class="unicode">?</span><strong class="bold">3</strong>
put 2007 - YearBorn into Age                             <span class="unicode">?</span><strong class="bold">4</strong>
put &#8220;In 2007, you were this old = &#8221; &amp;&amp; Age into message  <span class="unicode">?</span><strong class="bold">5</strong></font></span></pre>
<p class="para">This Revolution program tells the computer to do the  following:</p>
<ul class="simple-list">
<li class="first-listitem">
<p class="first-para"><span class="unicode">?</span><span class="fixed"><strong class="bold">1</strong></span> Stores the string <span class="fixed">“1964”</span> in a  variable called <span class="fixed">YearBorn</span>.</p>
</li>
<li class="listitem">
<p class="first-para"><span class="unicode">?</span><span class="fixed"><strong class="bold">2</strong></span> The two ampersand symbols (<span class="fixed">&amp;&amp;</span>) tack the string <span class="fixed">“1964”</span>  onto the other string <span class="fixed">“You were born in ”. Then this  line</span> display <span class="fixed">You were born in 1964</span> in a message  box on-screen.</p>
</li>
<li class="listitem">
<p class="first-para"><span class="unicode">?</span><span class="fixed"><strong class="bold">3</strong></span> Tells the computer to wait for five seconds. Without  this command, Revolution would rush into the rest of the program and the message  box displayed in line 2 would appear and disappear in the blink of an eye.</p>
</li>
<li class="listitem">
<p class="first-para"><span class="unicode">?</span><span class="fixed"><strong class="bold">4</strong></span> Automatically converts the string <span class="fixed">“1964”</span> into the number <span class="fixed">1964</span>. Then  subtracts the number <span class="fixed">1964</span> from <span class="fixed">2007</span> and stores the result (<span class="fixed">43</span>) in a  variable called <span class="fixed">Age</span>.</p>
</li>
<li class="listitem">
<p class="first-para"><span class="unicode">?</span><span class="fixed"><strong class="bold">5</strong></span> Converts the <span class="fixed">Age</span> variable  number (<span class="fixed">43</span>) into the string <span class="fixed">“43”</span> and then the two ampersand symbols (<span class="fixed">&amp;&amp;</span>) tack the <span class="fixed">“43”</span> string  onto the end of the <span class="fixed">“In 2007, you were this old = ”</span>  string. Then this line displays <span class="fixed">In 2007, you were this old =  43</span> in a message box that appears on-screen.</p>
</li>
</ul>
<p class="para">The main difference between Revolution and the previous two BASIC  examples is that Revolution is smart enough to figure out when to treat a number  as data and when to treat a number as a string without having to define any data  conversion yourself.</p>
<p class="last-para"><font color="#ffffff"><strong class="bold"><span style="background-color: #000080">Technical Stuff</span></strong></font> The C++  language doesn’t recognize strings as valid data types, although you can define  a string data type by using the <span class="fixed">using namespace std;</span>  command at the top of your programs. However, C++ doesn’t provide any built-in  commands for converting strings into numbers (and vice versa), so many  programmers simply write their own conversion programs and store them in library  files that they can reuse later. <a name="287"></a><a name="IDX-"></a></p>
<p class="section">
<h3 class="sect3-title"><a name="288"></a><a name="ch08lev"></a>Converting a number  into a string</h3>
<p class="first-para">Rather than convert a string into a number, you might want  to go the other way and convert a number into a string.</p>
<p class="para">In Liberty BASIC, you can convert a number into a string by using  the <span class="fixed">STR$</span> function, which works like this:</p>
<p class="informalexample">
<pre class="programlisting"><span style="background-color: #c0c0c0"><font color="#000000">
STR$ (<em class="emphasis">Number</em>)</font></span></pre>
<p class="para">The following Liberty BASIC program shows how to use the <span class="fixed">STR$</span> function to convert the <span class="fixed">BossIQ</span>  variable into a string:</p>
<p class="informalexample">
<pre class="programlisting"><span style="background-color: #c0c0c0"><font color="#000000">
BossIQ = 34                                      <span class="unicode">?</span><strong class="bold">1</strong>
NewString$ = &#8220;This is the IQ of your boss = &#8221; +
           STR$(BossIQ)                          <span class="unicode">?</span><strong class="bold">2</strong>
PRINT NewString$                                 <span class="unicode">?</span><strong class="bold">3</strong>
END                                              <span class="unicode">?</span><strong class="bold">4</strong></font></span></pre>
<p class="para">This Liberty BASIC program tells the computer to do the  following:</p>
<ul class="simple-list">
<li class="first-listitem">
<p class="first-para"><span class="unicode">?</span><span class="fixed"><strong class="bold">1</strong></span> Stores the number <span class="fixed">34</span> in a  variable called <span class="fixed">BossIQ</span>.</p>
</li>
<li class="listitem">
<p class="first-para"><span class="unicode">?</span><span class="fixed"><strong class="bold">2</strong></span> Uses the <span class="fixed">STR$</span> function to  convert the number stored in the <span class="fixed">BossIQ</span> variable (<span class="fixed">34</span>) into a string (<span class="fixed">“34”</span>). Then it  pastes the two strings together to store <span class="fixed">This is the IQ of  your boss =</span> <span class="fixed">34</span> in a string variable called <span class="fixed">NewString$</span>.</p>
</li>
<li class="listitem">
<p class="first-para"><span class="unicode">?</span><span class="fixed"><strong class="bold">3</strong></span> Prints the string <span class="fixed">This is the IQ of  your boss = 34</span> on-screen.</p>
</li>
<li class="listitem">
<p class="first-para"><span class="unicode">?</span><span class="fixed"><strong class="bold">4</strong></span> Defines the end of the program.</p>
</li>
</ul>
<p class="para">In this example, Liberty BASIC lets you declare a number variable  and convert that number into a string. Here’s the equivalent REALbasic program  that converts a number into a string by using the <span class="fixed">Str</span>  function:</p>
<p class="informalexample">
<pre class="programlisting"><span style="background-color: #c0c0c0"><font color="#000000">
Dim BossIQ as Integer
Dim NewString as String
BossIQ = 34
NewString = &#8220;This is the IQ of your boss = &#8221; + Str(BossIQ)
MsgBox NewString</font></span></pre>
<p class="para">In Revolution, you don’t need to give an explicit command to  convert a number into a string; the computer does this conversion for you  automatically, as the following program demonstrates: <a name="289"></a><a name="IDX-"></a><a name="290"></a><a name="IDX-"></a></p>
<p class="informalexample">
<pre class="programlisting"><span style="background-color: #c0c0c0"><font color="#000000">
put 34 into BossIQ
put &#8220;This is the IQ of your boss = &#8221; &amp;&amp; BossIQ into
           message</font></span></pre>
<script type="text/javascript">
  addthis_url    = 'http%3A%2F%2Ffree-softwares.org%2Fhow-to-convert-strings-into-numbers-and-vice-versa%2F601%2F';
  addthis_title  = 'How+to+Convert+Strings+into+Numbers+%28And+Vice+Versa%29';
  addthis_pub    = '';
</script><script type="text/javascript" src="http://s7.addthis.com/js/addthis_widget.php?v=12" ></script>
]]></content:encoded>
			<wfw:commentRss>http://free-softwares.org/how-to-convert-strings-into-numbers-and-vice-versa/601/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Declaring variables as strings</title>
		<link>http://free-softwares.org/declaring-variables-as-strings-2/600/</link>
		<comments>http://free-softwares.org/declaring-variables-as-strings-2/600/#comments</comments>
		<pubDate>Mon, 21 Apr 2008 10:41:58 +0000</pubDate>
		<dc:creator>yudi</dc:creator>
		
		<category><![CDATA[Number and Strings]]></category>

		<guid isPermaLink="false">http://free-softwares.org/declaring-variables-as-strings-2/600/</guid>
		<description><![CDATA[
&#160;



As with numbers, you can use strings directly in your  program, as follows:


PRINT &#8220;Print me.&#8221;
PRINT 54
END
Just as with numbers, you may want to store strings in variables  so you can reuse that particular string over and over again by typing just the  variable rather than the entire string.
Unfortunately, every programming language tends [...]]]></description>
			<content:encoded><![CDATA[<p><img src="http://www.ala.org/img/ALOnline/computer%20guy.jpg" style="margin: 0px auto 10px; display: block; width: 250px; text-align: center" border="0" /></p>
<p class="section">&nbsp;</p>
<h3 class="sect3-title"><a title="278" name="278"></a><a title="ch08lev" name="ch08lev"></a></h3>
<p class="section">
<h3 class="sect3-title"><a name="278"></a><a name="ch08lev"></a></h3>
<p class="first-para">As with numbers, you can use strings directly in your  program, as follows:</p>
<p class="informalexample">
<pre class="programlisting"><span style="background-color: #c0c0c0"><font color="#000000">
PRINT &#8220;Print me.&#8221;
PRINT 54
END</font></span></pre>
<p class="para">Just as with numbers, you may want to store strings in variables  so you can reuse that particular string over and over again by typing just the  variable rather than the entire string.</p>
<p class="para">Unfortunately, every programming language tends to use different  ways to declare a variable to hold a string data type. In Liberty BASIC, you  never declare variables until you actually assign data to them. When assigning a  string to a variable, the variable name must include the dollar sign (<span class="fixed">$</span>) at the end of the variable name, as follows: <a name="279"></a><a name="IDX-"></a></p>
<p class="informalexample">
<pre class="programlisting"><span style="background-color: #c0c0c0"><font color="#000000">
MyName$ = &#8220;Bo the Cat&#8221;</font></span></pre>
<p class="para">In Revolution, you can assign a string to a variable (just like  you can assign a number to a variable) by using the <span class="fixed">into</span> command like so:</p>
<p class="informalexample">
<pre class="programlisting"><span style="background-color: #c0c0c0"><font color="#000000">
put &#8220;Bo the Cat&#8221; into MyName</font></span></pre>
<p class="para">In REALbasic, you can declare a variable to hold string data  types, as follows:</p>
<p class="informalexample">
<pre class="programlisting"><span style="background-color: #c0c0c0"><font color="#000000">
Dim MyName As String</font></span></pre>
<p class="para">The C++ language won’t recognize string data types, so you must  use a library file called <span class="fixed">std</span>, which you can include in  your program by adding the following:</p>
<p class="informalexample">
<pre class="programlisting"><span style="background-color: #c0c0c0"><font color="#000000">
using namespace std;</font></span></pre>
<p class="para">This command tells your C++ program to use a library file called  <span class="fixed">std</span>, which defines a string data type. After you  include the <span class="fixed">std</span> library file, you can declare a string  variable such as:</p>
<p class="informalexample">
<pre class="programlisting"><span style="background-color: #c0c0c0"><font color="#000000">
string myName;</font></span></pre>
<p class="para">So an entire C++ program that declares a string variable might  look like this:</p>
<p class="informalexample">
<pre class="programlisting"><span style="background-color: #c0c0c0"><font color="#000000">
#include &lt;iostream.h&gt;
#include &lt;stdio.h&gt;
<strong class="bold">using namespace std;</strong>
int main()
{
<strong class="bold">   string myName;</strong>
   myName = &#8220;Bo the Cat&#8221;;
   cout &lt;&lt; myName;
   cout &lt;&lt; &#8220;\nPress ENTER to continue&#8230;&#8221; &lt;&lt; endl;
   getchar();
   return 0;
}</font></span></pre>
<script type="text/javascript">
  addthis_url    = 'http%3A%2F%2Ffree-softwares.org%2Fdeclaring-variables-as-strings-2%2F600%2F';
  addthis_title  = 'Declaring+variables+as+strings';
  addthis_pub    = '';
</script><script type="text/javascript" src="http://s7.addthis.com/js/addthis_widget.php?v=12" ></script>
]]></content:encoded>
			<wfw:commentRss>http://free-softwares.org/declaring-variables-as-strings-2/600/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Smashing strings together</title>
		<link>http://free-softwares.org/smashing-strings-together-2/599/</link>
		<comments>http://free-softwares.org/smashing-strings-together-2/599/#comments</comments>
		<pubDate>Mon, 21 Apr 2008 10:34:34 +0000</pubDate>
		<dc:creator>yudi</dc:creator>
		
		<category><![CDATA[Number and Strings]]></category>

		<guid isPermaLink="false">http://free-softwares.org/smashing-strings-together-2/599/</guid>
		<description><![CDATA[

Unlike with numbers, you can’t subtract, divide, or multiply  strings. But you can add strings (which is technically known as concatenating strings). To concatenate two strings, you use  the plus sign (+) to essentially smash two strings into  a single string, as the following Liberty BASIC example shows: 


MyName$ = &#8220;Joe Smith&#8221; [...]]]></description>
			<content:encoded><![CDATA[<p><img src="http://2lmao.com/data/soccer-face-smash.jpg" style="margin: 0px auto 10px; display: block; width: 250px; text-align: center" border="0" /></p>
<h3 class="sect3-title"><a name="280"></a><a name="ch08lev"></a></h3>
<p class="first-para">Unlike with numbers, you can’t subtract, divide, or multiply  strings. But you can add strings (which is technically known as <em class="emphasis">concatenating strings</em>). To concatenate two strings, you use  the plus sign (<span class="fixed">+</span>) to essentially smash two strings into  a single string, as the following Liberty BASIC example shows: <a name="281"></a><a name="IDX-"></a></p>
<p class="informalexample">
<pre class="programlisting"><span style="background-color: #c0c0c0"><font color="#000000">
MyName$ = &#8220;Joe Smith&#8221;                             <span class="unicode">?</span><strong class="bold">1</strong>
PRINT &#8220;Hello, &#8221; + MyName$                         <span class="unicode">?</span><strong class="bold">2</strong>
END                                               <span class="unicode">?</span><strong class="bold">3</strong></font></span></pre>
<p class="para">This Liberty BASIC program tells the computer to do the  following:</p>
<ul class="simple-list">
<li class="first-listitem">
<p class="first-para"><span class="unicode">?</span><span class="fixed"><strong class="bold">1</strong></span> Creates a string variable called <span class="fixed">MyName$</span> and stuffs it with the string <span class="fixed">“Joe  Smith”</span>.</p>
</li>
<li class="listitem">
<p class="first-para"><span class="unicode">?</span><span class="fixed"><strong class="bold">2</strong></span> Prints the string <span class="fixed">“Hello, “</span>  followed by the string stored in the <span class="fixed">MyName$</span> variable,  so the entire line prints out <span class="fixed">Hello, Joe</span> <span class="fixed">Smith</span>.</p>
</li>
<li class="listitem">
<p class="first-para"><span class="unicode">?</span><span class="fixed"><strong class="bold">3</strong></span> Tells the computer that the program is at an  end.</p>
</li>
</ul>
<p class="para"><font color="#ffffff"><strong class="bold"><span style="background-color: #000080">Remember</span></strong></font> If you concatenate  strings, make sure that you leave a space between the two strings so that they  don’t appear smashed together (<span class="fixed">likethis</span>). In the  previous example, notice the space in the second line following the word <span class="fixed">Hello</span> and the comma.</p>
<p class="para">Both REALbasic and C++ also let you use the plus sign (<span class="fixed">+</span>) to concatenate strings. However, Revolution uses the dual  ampersand symbols (<span class="fixed">&amp;&amp;</span>) to concatenate strings  like so:</p>
<p class="informalexample">
<pre class="programlisting"><span style="background-color: #c0c0c0"><font color="#000000">
put &#8220;Joe Smith&#8221; into MyName
put &#8220;Hello, &#8221; &amp;&amp; MyName into message</font></span></pre>
<pre class="programlisting"><span style="background-color: #c0c0c0"> </span></pre>
<script type="text/javascript">
  addthis_url    = 'http%3A%2F%2Ffree-softwares.org%2Fsmashing-strings-together-2%2F599%2F';
  addthis_title  = 'Smashing+strings+together';
  addthis_pub    = '';
</script><script type="text/javascript" src="http://s7.addthis.com/js/addthis_widget.php?v=12" ></script>
]]></content:encoded>
			<wfw:commentRss>http://free-softwares.org/smashing-strings-together-2/599/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Using Built-In Math Functions</title>
		<link>http://free-softwares.org/using-built-in-math-functions-2/598/</link>
		<comments>http://free-softwares.org/using-built-in-math-functions-2/598/#comments</comments>
		<pubDate>Mon, 21 Apr 2008 10:28:34 +0000</pubDate>
		<dc:creator>yudi</dc:creator>
		
		<category><![CDATA[Number and Strings]]></category>

		<guid isPermaLink="false">http://free-softwares.org/using-built-in-math-functions-2/598/</guid>
		<description><![CDATA[

By combining mathematical operators, you can create  practically any type of mathematical formula. But creating some mathematical  formulas may prove too cumbersome, so as a shortcut, many programming languages  provide built-in mathematical functions that you can use. 







Technical Stuff If you don’t  understand terms like arcsine or logarithm, you probably don’t need [...]]]></description>
			<content:encoded><![CDATA[<p><img src="http://www.sharpusa.com/images/cal_EL501WBBK_pic1.jpg" style="margin: 0px auto 10px; display: block; width: 250px; text-align: center" border="0" /></p>
<h2 class="first-section-title"><a title="272" name="272"></a><a title="ch08lev" name="ch08lev"></a></h2>
<p>By combining mathematical operators, you can create  practically any type of mathematical formula. But creating some mathematical  formulas may prove too cumbersome, so as a shortcut, many programming languages  provide built-in mathematical functions that you can use. <span class="internaljump"></span><br />
<a title="273" name="273"></a><a title="ch08t" name="ch08t"></a></p>
<table class="table" id="ch08table02" linktabletoexcel="yes" border="1" height="28" width="1">
<thead>
<th class="th" scope="col" align="left" valign="top"></th>
<th class="th" scope="col" align="left" valign="top"></th>
</thead>
</table>
<p class="para"><font color="#ffffff"><strong class="bold"><span style="background-color: #000080">Technical Stuff</span></strong></font> If you don’t  understand terms like arcsine or logarithm, you probably don’t need to use them  anyway. The important point to remember is that all programming languages  include built-in mathematical functions that you can use if you need them. <a title="274" name="274"></a><a title="IDX-" name="IDX-"></a></p>
<p class="para">To see how the Liberty BASIC mathematical functions work, run the  following program and type different numbers (negative, positive, decimal, and  so on) between 0 and 1.0 to see how the program works:</p>
<p class="informalexample">&nbsp;</p>
<pre class="programlisting"><span style="background-color: #c0c0c0"><font color="#000000">

PROMPT &#8220;Type in a number&#8221;; <em class="emphasis">AnyNumber</em>

PRINT &#8220;The ABS value = &#8220;; ABS(<em class="emphasis">AnyNumber</em>)

PRINT &#8220;The ACS value = &#8220;; ACS(<em class="emphasis">AnyNumber</em>)

PRINT &#8220;The ASN value = &#8220;; ASN(<em class="emphasis">AnyNumber</em>)

PRINT &#8220;The ATN value = &#8220;; ATN(<em class="emphasis">AnyNumber</em>)

PRINT &#8220;The COS value = &#8220;; COS(<em class="emphasis">AnyNumber</em>)

PRINT &#8220;The EXP value = &#8220;; EXP(<em class="emphasis">AnyNumber</em>)

PRINT &#8220;The LOG value = &#8220;; LOG(ABS(<em class="emphasis">AnyNumber</em>))

PRINT &#8220;The SIN value = &#8220;; SIN(<em class="emphasis">AnyNumber</em>)

PRINT &#8220;The SQR value = &#8220;; SQR(<em class="emphasis">AnyNumber</em>)

PRINT &#8220;The TAN value = &#8220;; TAN(<em class="emphasis">AnyNumber</em>)

PRINT

END</font></span></pre>
<p class="para">You can use only positive numbers with the <span class="fixed">LOG</span> function or in calculating a square root.</p>
<p class="para"><font color="#ffffff"><strong class="bold"><span style="background-color: #000080">Technical Stuff</span></strong></font> Unlike many  programming languages, C++ doesn’t have built-in math functions. Instead, C++  compilers come with a library of math functions written in C++. You don’t have  to worry about how these math functions work; you can just use them by adding  the #include &lt;math.h&gt; command at the top of your program, as shown here:  <a title="275" name="275"></a><a title="IDX-" name="IDX-"></a></p>
<p class="informalexample">&nbsp;</p>
<pre class="programlisting"><span style="background-color: #c0c0c0"><font color="#000000">

#include &lt;iostream.h&gt;

#include &lt;stdio.h&gt;

#include &lt;math.h&gt;

int main()

{

  double anyNumber;

  cout &lt;&lt; &#8220;Enter a number: &#8220;;

  cin &gt;&gt; anyNumber;

  cout &lt;&lt; &#8220;The ABS value = &#8220;; cout &lt;&lt; abs(anyNumber);

  cout &lt;&lt; &#8220;nThe ACOS value = &#8220;; cout &lt;&lt; acos(anyNumber);

  cout &lt;&lt; &#8220;nThe ASIN value = &#8220;; cout &lt;&lt; asin(anyNumber);

  cout &lt;&lt; &#8220;nThe ATAN value = &#8220;; cout &lt;&lt; atan(anyNumber);

  cout &lt;&lt; &#8220;nThe COS value = &#8220;; cout &lt;&lt; cos(anyNumber);

  cout &lt;&lt; &#8220;nThe EXP value = &#8220;; cout &lt;&lt; exp(anyNumber);

  cout &lt;&lt; &#8220;nThe LOG value = &#8220;; cout &lt;&lt; log(anyNumber);

  cout &lt;&lt; &#8220;nThe SIN value = &#8220;; cout &lt;&lt; sin(anyNumber);

  cout &lt;&lt; &#8220;nThe SQRT value = &#8220;; cout &lt;&lt; sqrt(anyNumber);

  cout &lt;&lt; &#8220;nThe TAN value = &#8220;; cout &lt;&lt; tan(anyNumber);

  cout &lt;&lt; &#8220;nThe ACOS value = &#8220;; cout &lt;&lt; acos(anyNumber);

  cout &lt;&lt; &#8220;nPress ENTER to continue&#8230;&#8221; &lt;&lt; endl;

  getchar();

  return 0;

}</font></span></pre>
<p class="para">A mathematical function accepts a value and uses that value to  calculate a result. So you can assign a mathematical function to a variable, as  the following REALbasic program demonstrates:</p>
<p class="informalexample">&nbsp;</p>
<pre class="programlisting"><span style="background-color: #c0c0c0"><font color="#000000">

Dim x, y as Single                                  <span class="unicode">?</span><strong class="bold">1</strong>

x = 0.52                                            <span class="unicode">?</span><strong class="bold">2</strong>

y = cos(x)                                          <span class="unicode">?</span><strong class="bold">3</strong>

MsgBox str(y)                                       <span class="unicode">?</span><strong class="bold">4</strong></font></span></pre>
<p class="para">This REALbasic program tells the computer to do the following:</p>
<ul class="simple-list">
<li class="first-listitem">
<p class="first-para"><span class="unicode">?</span><span class="fixed"><strong class="bold">1</strong></span> Declares two variables <span class="fixed">x</span> and  <span class="fixed">y</span> that can hold only a single-precision (decimal)  number.</p>
</li>
<li class="listitem">
<p class="first-para"><span class="unicode">?</span><span class="fixed"><strong class="bold">2</strong></span> Stores the value <span class="fixed">0.52</span> into the  <span class="fixed">x</span> variable.</p>
</li>
<li class="listitem">
<p class="first-para"><span class="unicode">?</span><span class="fixed"><strong class="bold">3</strong></span> Gives the value <span class="fixed">0.52</span> to the  cosine (<span class="fixed">cos</span>) mathematical function. The cosine  mathematical function calculates the cosine of <span class="fixed">0.52</span>,  which is <span class="fixed">0.8678191</span>. This value gets stored in the <span class="fixed">y</span> variable.</p>
</li>
<li class="listitem">
<p class="first-para"><span class="unicode">?</span><span class="fixed"><strong class="bold">4</strong></span> The <span class="fixed">str</span> command converts the  number <span class="fixed">0.8678191</span> into the string <span class="fixed">“0.8678191”</span>, which it then displays in a message box created  by the <span class="fixed">MsgBox</span> command.</p>
</li>
</ul>
<p class="para">Mathematical functions work the same way in Revolution, as the  following program shows:</p>
<p class="informalexample">&nbsp;</p>
<pre class="programlisting"><span style="background-color: #c0c0c0"><font color="#000000">

put 0.52 into x                                   <span class="unicode">?</span><strong class="bold">1</strong>

put cos(x) into y                                 <span class="unicode">?</span><strong class="bold">2</strong>

put y into message                                <span class="unicode">?</span><strong class="bold">3</strong></font></span></pre>
<p class="para">This Revolution program tells the computer to do the  following:</p>
<ul class="simple-list">
<li class="first-listitem">
<p class="first-para"><span class="unicode">?</span><span class="fixed"><strong class="bold">1</strong></span> Stores the value <span class="fixed">0.52</span> into a  variable called <span class="fixed">x</span>.</p>
</li>
<li class="listitem">
<p class="first-para"><span class="unicode">?</span><span class="fixed"><strong class="bold">2</strong></span> Gives the value of <span class="fixed">x</span> (<span class="fixed">0.52</span>) to the cosine mathematical function, which returns the  value <span class="fixed">0.876819</span> and stores this value in a variable  named <span class="fixed">y</span>.</p>
</li>
<li class="listitem">
<p class="first-para"><span class="unicode">?</span><span class="fixed"><strong class="bold">3</strong></span> Displays the value of the <span class="fixed">y</span>  variable on-screen in a message box defined by the <span class="fixed">message</span> command.</p>
</li>
</ul>
<p><a title="276" name="276"></a><a title="IDX-" name="IDX-"></a></p>
<p class="last-para"><font color="#ffffff"><strong class="bold"><span style="background-color: #000080"></span></strong></font></p>
<script type="text/javascript">
  addthis_url    = 'http%3A%2F%2Ffree-softwares.org%2Fusing-built-in-math-functions-2%2F598%2F';
  addthis_title  = 'Using+Built-In+Math+Functions';
  addthis_pub    = '';
</script><script type="text/javascript" src="http://s7.addthis.com/js/addthis_widget.php?v=12" ></script>
]]></content:encoded>
			<wfw:commentRss>http://free-softwares.org/using-built-in-math-functions-2/598/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Everex Cloudbook UMPC</title>
		<link>http://free-softwares.org/everex-cloudbook-umpc/597/</link>
		<comments>http://free-softwares.org/everex-cloudbook-umpc/597/#comments</comments>
		<pubDate>Wed, 26 Mar 2008 15:36:57 +0000</pubDate>
		<dc:creator>yudi</dc:creator>
		
		<category><![CDATA[About]]></category>

		<guid isPermaLink="false">http://free-softwares.org/everex-cloudbook-umpc/597/</guid>
		<description><![CDATA[
Yerp&#8230;..the UMPC frenzy is coming up. More and more really tiny yet weak-performance laptops are released. The dimension is 230 x 171 x 29mm and weighs at just 970 grams, this UMPC run by a weak 1.2GHz VIA C7-M ULV processor, a 30GB of hard drive, a 512B of main memory (expandable up to 1GB), [...]]]></description>
			<content:encoded><![CDATA[<p><img src="http://imagecows.net/out.php/i364_everexcloudbookumpc.jpg" style="margin: 0px auto 10px; display: block; width: 450px; text-align: center" border="0" /><br />
Yerp&#8230;..the UMPC frenzy is coming up. More and more really tiny yet weak-performance laptops are released. The dimension is 230 x 171 x 29mm and weighs at just 970 grams, this UMPC run by a weak 1.2GHz VIA C7-M ULV processor, a 30GB of hard drive, a 512B of main memory (expandable up to 1GB), an integrated 0.3 megapixel webcam module, and a WVGA touchscreen display. For connectivity, it provides both WiFI and Bluetooth options.</p>
<p><strong>Precaution:</strong><br />
UMPC is only good for you who need a second laptop, for traveling purposes and light computer use. Any attempt to use it for daily office needs may drastically increase your depression and stress level.</p>
<script type="text/javascript">
  addthis_url    = 'http%3A%2F%2Ffree-softwares.org%2Feverex-cloudbook-umpc%2F597%2F';
  addthis_title  = 'Everex+Cloudbook+UMPC';
  addthis_pub    = '';
</script><script type="text/javascript" src="http://s7.addthis.com/js/addthis_widget.php?v=12" ></script>
]]></content:encoded>
			<wfw:commentRss>http://free-softwares.org/everex-cloudbook-umpc/597/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Gigabyte GSmart MS808 Cell Phone</title>
		<link>http://free-softwares.org/gigabyte-gsmart-ms808-cell-phone/596/</link>
		<comments>http://free-softwares.org/gigabyte-gsmart-ms808-cell-phone/596/#comments</comments>
		<pubDate>Wed, 26 Mar 2008 15:29:39 +0000</pubDate>
		<dc:creator>yudi</dc:creator>
		
		<category><![CDATA[Gadget News]]></category>

		<guid isPermaLink="false">http://free-softwares.org/gigabyte-gsmart-ms808-cell-phone/596/</guid>
		<description><![CDATA[
Gigabyte has release a feture-rich cell phone called GSmart MS808, it is run buy Windows Mobile 6.1 with a bright 2.8-inch VGA touchscreen display, also integrated GPS navigation module, digital TV / radio support, built-in DVB-T/DVB-H/T-DMB/ISDB-T/DMB receiver, and 3 megapixel camera module with auto-focus. It has 624Mhz Marvell PXA310 processor and support quad-band GSM/GPRS (850/900/1800/1900) [...]]]></description>
			<content:encoded><![CDATA[<p><img src="http://imagecows.net/out.php/i252_gigabytegsmartms808cellphone.jpg" style="margin: 0px auto 10px; display: block; width: 450px; text-align: center" border="0" /><br />
Gigabyte has release a feture-rich cell phone called GSmart MS808, it is run buy Windows Mobile 6.1 with a bright 2.8-inch VGA touchscreen display, also integrated GPS navigation module, digital TV / radio support, built-in DVB-T/DVB-H/T-DMB/ISDB-T/DMB receiver, and 3 megapixel camera module with auto-focus. It has 624Mhz Marvell PXA310 processor and support quad-band GSM/GPRS (850/900/1800/1900) network with support for HSDPA/EDGE/WCDMA 2100. Last but not the least, the WiFi connectivity.<br />
To be honest, I&#8217;m quite impressed, the OS will allow you to add more features from 3rd party vendors, yet the existing features is already more than enough for casual users.</p>
<script type="text/javascript">
  addthis_url    = 'http%3A%2F%2Ffree-softwares.org%2Fgigabyte-gsmart-ms808-cell-phone%2F596%2F';
  addthis_title  = 'Gigabyte+GSmart+MS808+Cell+Phone';
  addthis_pub    = '';
</script><script type="text/javascript" src="http://s7.addthis.com/js/addthis_widget.php?v=12" ></script>
]]></content:encoded>
			<wfw:commentRss>http://free-softwares.org/gigabyte-gsmart-ms808-cell-phone/596/feed/</wfw:commentRss>
		</item>
	</channel>
</rss>
