<?xml version='1.0' encoding='utf-8'?>
<rss version='2.0'>
   <channel>
      <title>Programming and Web Development Tutorials</title>
      <link>http://tutorials.dreamincode.net</link>
      <description>Web Development, Programming, and Coding Community. Browse forums, snippets, and tutorials to get you on the right track. Experts in C++, PHP, VisualBasic, HTML, JavaScript, ColdFusion, and more!</description>
         <item>
            <link>http://forums.dreamincode.net/showtopic136884.htm</link>
            <title>Remove System Beep in Linux Tutorials</title>
            <description>Some people (including myself) hate that nasty beep, when it starts to sound, I start to get a headache. Is there a way to remove it? Yes and it&amp;#39;s quite easy. Just to the following:&lt;br /&gt;&lt;br /&gt;&lt;i&gt;(you can use gedit or any editor of your choice instead of vim)&lt;/i&gt;&lt;br /&gt;&lt;b&gt;1. if you want to disable the beep temporarily&lt;/b&gt; (until the next startup)&lt;br /&gt;&lt;!--c1--&gt;&lt;div class='codetop'&gt;CODE&lt;/div&gt;&lt;div class='codemain'&gt;&lt;!--ec1--&gt;sudo rmmod pcspkr&lt;!--c2--&gt;&lt;/div&gt;&lt;!--ec2--&gt;Go and check, it is gone&amp;#33;&amp;#33;&amp;#33;  &lt;img src=&quot;style_emoticons/&lt;#EMO_DIR#&gt;/biggrin.gif&quot; style=&quot;vertical-align:middle&quot; emoid=&quot;:D&quot; border=&quot;0&quot; alt=&quot;biggrin.gif&quot; /&gt; &lt;br /&gt;&lt;br /&gt;&lt;b&gt;2. if you want to disable it forever&lt;/b&gt; (until you enable it again)&lt;br /&gt;&lt;!--c1--&gt;&lt;div class='codetop'&gt;CODE&lt;/div&gt;&lt;div class='codemain'&gt;&lt;!--ec1--&gt;sudo vim /etc/modprobe.d/blacklist&lt;!--c2--&gt;&lt;/div&gt;&lt;!--ec2--&gt;then add this line in the file:&lt;br /&gt;&lt;!--c1--&gt;&lt;div class='codetop'&gt;CODE&lt;/div&gt;&lt;div class='codemain'&gt;&lt;!--ec1--&gt;blacklist pcspkr&lt;!--c2--&gt;&lt;/div&gt;&lt;!--ec2--&gt;now save the file and from the next reboot, you won&amp;#39;t hear it again.&lt;br /&gt;&lt;br /&gt;&lt;b&gt;3. another way to disable it forever&lt;/b&gt; (until enabling it again)&lt;br /&gt;&lt;!--c1--&gt;&lt;div class='codetop'&gt;CODE&lt;/div&gt;&lt;div class='codemain'&gt;&lt;!--ec1--&gt;sudo vim /etc/inputrc&lt;!--c2--&gt;&lt;/div&gt;&lt;!--ec2--&gt;now, look for the line where it says &amp;quot;set bell-style audible&amp;quot;, change it to one of these:&lt;br /&gt;&lt;!--c1--&gt;&lt;div class='codetop'&gt;CODE&lt;/div&gt;&lt;div class='codemain'&gt;&lt;!--ec1--&gt;set bell-style visible&lt;br /&gt;#or&lt;br /&gt;set bell-style none&lt;!--c2--&gt;&lt;/div&gt;&lt;!--ec2--&gt;save and reboot and &lt;img src=&quot;style_emoticons/&lt;#EMO_DIR#&gt;/biggrin.gif&quot; style=&quot;vertical-align:middle&quot; emoid=&quot;:D&quot; border=&quot;0&quot; alt=&quot;biggrin.gif&quot; /&gt; it is gone.&lt;br /&gt;&lt;br /&gt;Hope this tutorial helped you get free of the annoying beep when you work with system.  &lt;img src=&quot;style_emoticons/&lt;#EMO_DIR#&gt;/wink2.gif&quot; style=&quot;vertical-align:middle&quot; emoid=&quot;;)&quot; border=&quot;0&quot; alt=&quot;wink2.gif&quot; /&gt;</description>
			<pubDate>Thu, 05 Nov 2009 16:34:37 -0600</pubDate>
			<category>Linux Tutorials</category>
			<author>Anarion</author>
         </item>
         <item>
            <link>http://forums.dreamincode.net/showtopic135692.htm</link>
            <title>wxWidgets: Threading and using the Clipboard in C++ Tutorials</title>
            <description>&lt;!--sizeo:3--&gt;&lt;span style=&quot;font-size:12pt;line-height:100%&quot;&gt;&lt;!--/sizeo--&gt;wxWidgets: Threading, and using the Clipboard&lt;!--sizec--&gt;&lt;/span&gt;&lt;!--/sizec--&gt;&lt;br /&gt;&lt;br /&gt;Two for one in this tutorial. We&amp;#39;re going to create a thread using wxWidgets, and make it monitor the clipboard for text. Then, if we detect a change, we&amp;#39;re going to add the new contents to a list.&lt;br /&gt;&lt;br /&gt;It&amp;#39;s a relatively simple process, but unfortunately wxWidgets isn&amp;#39;t the most documented GUI toolkit out there.&lt;br /&gt;&lt;br /&gt;So, let&amp;#39;s get started. I&amp;#39;m gonna pile all the code into a single file instead of breaking my classes up into seperate files, just for ease of navigation in this tutorial. The code is relatively short anyway, with only 62 lines.&lt;br /&gt;&lt;br /&gt;First off, as with any other program, we&amp;#39;re going to want to get our includes done. We&amp;#39;ll be needing three: The standard wx header, the clipboard header, and the thread header. &lt;!--c1--&gt;&lt;div class='codetop'&gt;CODE&lt;/div&gt;&lt;div class='codemain'&gt;&lt;!--ec1--&gt;#include &amp;#60;wx/wx.h&amp;#62; // standard wx header&lt;br /&gt;#include &amp;#60;wx/clipbrd.h&amp;#62; // clipboard - we&amp;#39;ll monitor the clipboard for text&lt;br /&gt;#include &amp;#60;wx/thread.h&amp;#62; // include threads&amp;#33;&lt;!--c2--&gt;&lt;/div&gt;&lt;!--ec2--&gt;&lt;br /&gt;The next thing we need to do is declare our [il]ClipLogger[/il] class - this will inherit wxThread, and have two variables: One to hold the most recent text that we got from the clipboard, and one which is a pointer to a [il]wxListBox[/il] object -- the object on the main window which we&amp;#39;ll be updating. &lt;!--c1--&gt;&lt;div class='codetop'&gt;CODE&lt;/div&gt;&lt;div class='codemain'&gt;&lt;!--ec1--&gt;class ClipLogger &amp;#58; public wxThread {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;public&amp;#58;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;ClipLogger&amp;#40;wxListBox*&amp;#41;;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;private&amp;#58;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;void* Entry&amp;#40;&amp;#41;; // the entry point to the thread&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;wxString LatestText; // store the last text so we can check for changes&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;wxListBox* list; // the list to update on a text change&lt;br /&gt;};&lt;!--c2--&gt;&lt;/div&gt;&lt;!--ec2--&gt;&lt;br /&gt;The constructor is &lt;i&gt;very&lt;/i&gt; simple. All it does is take a wxListBox*, and assign it to a variable stored by the class - this is the list that we want to update on clipboard text changes. &lt;!--c1--&gt;&lt;div class='codetop'&gt;CODE&lt;/div&gt;&lt;div class='codemain'&gt;&lt;!--ec1--&gt;ClipLogger&amp;#58;&amp;#58;ClipLogger&amp;#40;wxListBox* l&amp;#41; {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;this-&amp;#62;list = l;&lt;br /&gt;}&lt;!--c2--&gt;&lt;/div&gt;&lt;!--ec2--&gt;&lt;br /&gt;Next up is the main part of this tutorial. When we create a thread, we need to override the [il]Entry()[/il] method of the class, like so: &lt;!--c1--&gt;&lt;div class='codetop'&gt;CODE&lt;/div&gt;&lt;div class='codemain'&gt;&lt;!--ec1--&gt;void* ClipLogger&amp;#58;&amp;#58;Entry&amp;#40;&amp;#41; {&lt;!--c2--&gt;&lt;/div&gt;&lt;!--ec2--&gt;&lt;br /&gt;To save time and memory, rather than creating a variable every time we loop, we&amp;#39;ll create it before and simply overwrite it inside the loop. &lt;!--c1--&gt;&lt;div class='codetop'&gt;CODE&lt;/div&gt;&lt;div class='codemain'&gt;&lt;!--ec1--&gt;wxTextDataObject temp;&lt;!--c2--&gt;&lt;/div&gt;&lt;!--ec2--&gt;&lt;br /&gt;wxTextDataObject is the type of object that the clipboard will store.&lt;br /&gt;Next, since our thread is a constant &amp;quot;monitor&amp;quot; for the clipboard, we want it to loop. &lt;!--c1--&gt;&lt;div class='codetop'&gt;CODE&lt;/div&gt;&lt;div class='codemain'&gt;&lt;!--ec1--&gt;while &amp;#40;true&amp;#41; {&lt;!--c2--&gt;&lt;/div&gt;&lt;!--ec2--&gt;&lt;br /&gt;Then, we need to think about how we can help our application not be CPU-hungry. The simple solution is to make the thread sleep each time it loops. We can do this with [il]wxSleep(int time)[/il], where time is the length of time to sleep in &lt;b&gt;seconds&lt;/b&gt;. &lt;!--c1--&gt;&lt;div class='codetop'&gt;CODE&lt;/div&gt;&lt;div class='codemain'&gt;&lt;!--ec1--&gt;wxSleep&amp;#40;1&amp;#41;;&lt;!--c2--&gt;&lt;/div&gt;&lt;!--ec2--&gt;&lt;br /&gt;The rest of the loop is the clipboard. It&amp;#39;s very simple, so rather than break it up line-by-line, I&amp;#39;ve added comments along the way. We basically need to do the following:&lt;br /&gt; - Open the clipboard&lt;br /&gt; - If the clipboard is text, get it into our [il]temp[/il] variable&lt;br /&gt; - Update the list and remember this is the most recent (so as not to constantly add the same data to the list)&lt;br /&gt; - Close the clipboard&lt;br /&gt;&lt;!--c1--&gt;&lt;div class='codetop'&gt;CODE&lt;/div&gt;&lt;div class='codemain'&gt;&lt;!--ec1--&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;if &amp;#40;wxTheClipboard-&amp;#62;Open&amp;#40;&amp;#41;&amp;#41; { // try to open the clipboard&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;if &amp;#40;wxTheClipboard-&amp;#62;IsSupported&amp;#40;wxDF_TEXT&amp;#41;&amp;#41; { // if the clipboard contains text&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;wxTheClipboard-&amp;#62;GetData&amp;#40;temp&amp;#41;; // get the data from the clipboard&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;if &amp;#40;this-&amp;#62;LatestText &amp;#33;= temp.GetText&amp;#40;&amp;#41;&amp;#41; { // if it&amp;#39;s changed, we want to update&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;if &amp;#40;temp.GetText&amp;#40;&amp;#41; &amp;#33;= wxT&amp;#40;&amp;#34;&amp;#34;&amp;#41;&amp;#41; { // if it&amp;#39;s not an empty string&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;this-&amp;#62;LatestText = temp.GetText&amp;#40;&amp;#41;;&amp;nbsp;&amp;nbsp;// update the &amp;#34;LatestText&amp;#34;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;this-&amp;#62;list-&amp;#62;Append&amp;#40;temp.GetText&amp;#40;&amp;#41;&amp;#41;; // append to the list&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;wxTheClipboard-&amp;#62;Close&amp;#40;&amp;#41;; // close the clipboard&lt;!--c2--&gt;&lt;/div&gt;&lt;!--ec2--&gt;&lt;br /&gt;The last thing left to do in the thread is simply close it off, and close off the loop. &lt;!--c1--&gt;&lt;div class='codetop'&gt;CODE&lt;/div&gt;&lt;div class='codemain'&gt;&lt;!--ec1--&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;br /&gt;}&lt;!--c2--&gt;&lt;/div&gt;&lt;!--ec2--&gt;&lt;br /&gt;Simple, huh? &lt;img src=&quot;style_emoticons/&lt;#EMO_DIR#&gt;/smile.gif&quot; style=&quot;vertical-align:middle&quot; emoid=&quot;:)&quot; border=&quot;0&quot; alt=&quot;smile.gif&quot; /&gt;&lt;br /&gt;&lt;br /&gt;And that&amp;#39;s our thread defined. Now all we need to do is create the app itself, which is a simple process. I hope that you already know how to do it, so we can blitz through the majority of it. If not, you may want to review &lt;a href=&quot;http://www.dreamincode.net/forums/showtopic66948.htm&quot; target=&quot;_blank&quot;&gt;this tutorial&lt;/a&gt;.&lt;br /&gt;&lt;br /&gt;Create the app: &lt;!--c1--&gt;&lt;div class='codetop'&gt;CODE&lt;/div&gt;&lt;div class='codemain'&gt;&lt;!--ec1--&gt;class threaded_app &amp;#58; public wxApp {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;public&amp;#58;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;bool OnInit&amp;#40;void&amp;#41;;&lt;br /&gt;};&lt;!--c2--&gt;&lt;/div&gt;&lt;!--ec2--&gt;&lt;br /&gt;The beginning of the [il]OnInit()[/il] should be nothing new at this point either. &lt;!--c1--&gt;&lt;div class='codetop'&gt;CODE&lt;/div&gt;&lt;div class='codemain'&gt;&lt;!--ec1--&gt;bool threaded_app&amp;#58;&amp;#58;OnInit&amp;#40;void&amp;#41; {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;// quickly create a wxFrame to display a window&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;wxFrame* f = new wxFrame&amp;#40;NULL, wxID_ANY, wxT&amp;#40;&amp;#34;Threaded App&amp;#33;&amp;#34;&amp;#41;&amp;#41;;&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;// add a list to the frame we created&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;wxListBox* list = new wxListBox&amp;#40;f, wxID_ANY&amp;#41;;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;// display the frame&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;f-&amp;#62;Show&amp;#40;true&amp;#41;;&lt;!--c2--&gt;&lt;/div&gt;&lt;!--ec2--&gt;&lt;br /&gt;The last part of [il]OnInit()[/il] that we need to do is actually create an instance of our thread and run it, like so: &lt;!--c1--&gt;&lt;div class='codetop'&gt;CODE&lt;/div&gt;&lt;div class='codemain'&gt;&lt;!--ec1--&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;// pass the list to the clipboard monitor so it knows what to update&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;ClipLogger* cl = new ClipLogger&amp;#40;list&amp;#41;; // construct our thread&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;cl-&amp;#62;Create&amp;#40;&amp;#41;; // we have to create a thread before we can run it&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;cl-&amp;#62;Run&amp;#40;&amp;#41;; // run our thread&lt;!--c2--&gt;&lt;/div&gt;&lt;!--ec2--&gt;&lt;br /&gt;And we can simply finish off the [il]OnInit()[/il] and IMPLEMENT_APP: &lt;!--c1--&gt;&lt;div class='codetop'&gt;CODE&lt;/div&gt;&lt;div class='codemain'&gt;&lt;!--ec1--&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;return true;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;IMPLEMENT_APP&amp;#40;threaded_app&amp;#41;&lt;br /&gt;&lt;!--c2--&gt;&lt;/div&gt;&lt;!--ec2--&gt;&lt;br /&gt;&lt;br /&gt;And that&amp;#39;s all there is to threading and using the clipboard in wxWidgets&amp;#33;&lt;br /&gt;&lt;br /&gt;Here&amp;#39;s the complete code: &lt;!--c1--&gt;&lt;div class='codetop'&gt;CODE&lt;/div&gt;&lt;div class='codemain'&gt;&lt;!--ec1--&gt;#include &amp;#60;wx/wx.h&amp;#62; // standard wx header&lt;br /&gt;#include &amp;#60;wx/clipbrd.h&amp;#62; // clipboard - we&amp;#39;ll monitor the clipboard for text&lt;br /&gt;#include &amp;#60;wx/thread.h&amp;#62; // include threads&amp;#33;&lt;br /&gt;&lt;br /&gt;class ClipLogger &amp;#58; public wxThread {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;public&amp;#58;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;ClipLogger&amp;#40;wxListBox*&amp;#41;;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;private&amp;#58;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;void* Entry&amp;#40;&amp;#41;; // the entry point to the thread&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;wxString LatestText; // store the last text so we can check for changes&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;wxListBox* list; // the list to update on a text change&lt;br /&gt;};&lt;br /&gt;&lt;br /&gt;ClipLogger&amp;#58;&amp;#58;ClipLogger&amp;#40;wxListBox* l&amp;#41; {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;this-&amp;#62;list = l;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;void* ClipLogger&amp;#58;&amp;#58;Entry&amp;#40;&amp;#41; {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;wxTextDataObject temp; // create a &amp;#34;wxTextDataObject&amp;#34; to get the info from the clipboard&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;while &amp;#40;true&amp;#41; { // our thread will loop&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;wxSleep&amp;#40;1&amp;#41;; // sleep for 1 second, make the thread less cpu-hungry&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;if &amp;#40;wxTheClipboard-&amp;#62;Open&amp;#40;&amp;#41;&amp;#41; { // try to open the clipboard&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;if &amp;#40;wxTheClipboard-&amp;#62;IsSupported&amp;#40;wxDF_TEXT&amp;#41;&amp;#41; { // if the clipboard contains text&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;wxTheClipboard-&amp;#62;GetData&amp;#40;temp&amp;#41;; // get the data from the clipboard&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;if &amp;#40;this-&amp;#62;LatestText &amp;#33;= temp.GetText&amp;#40;&amp;#41;&amp;#41; { // if it&amp;#39;s changed, we want to update&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;if &amp;#40;temp.GetText&amp;#40;&amp;#41; &amp;#33;= wxT&amp;#40;&amp;#34;&amp;#34;&amp;#41;&amp;#41; { // if it&amp;#39;s not an empty string&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;this-&amp;#62;LatestText = temp.GetText&amp;#40;&amp;#41;;&amp;nbsp;&amp;nbsp;// update the &amp;#34;LatestText&amp;#34;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;this-&amp;#62;list-&amp;#62;Append&amp;#40;temp.GetText&amp;#40;&amp;#41;&amp;#41;; // append to the list&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;wxTheClipboard-&amp;#62;Close&amp;#40;&amp;#41;; // close the clipboard&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;class threaded_app &amp;#58; public wxApp {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;public&amp;#58;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;bool OnInit&amp;#40;void&amp;#41;;&lt;br /&gt;};&lt;br /&gt;&lt;br /&gt;bool threaded_app&amp;#58;&amp;#58;OnInit&amp;#40;void&amp;#41; {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;// quickly create a wxFrame to display a window&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;wxFrame* f = new wxFrame&amp;#40;NULL, wxID_ANY, wxT&amp;#40;&amp;#34;Threaded App&amp;#33;&amp;#34;&amp;#41;&amp;#41;;&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;// add a list to the frame we created&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;wxListBox* list = new wxListBox&amp;#40;f, wxID_ANY&amp;#41;;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;// display the frame&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;f-&amp;#62;Show&amp;#40;true&amp;#41;;&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;// pass the list to the clipboard monitor so it knows what to update&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;ClipLogger* cl = new ClipLogger&amp;#40;list&amp;#41;; // construct our thread&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;cl-&amp;#62;Create&amp;#40;&amp;#41;; // we have to create a thread before we can run it&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;cl-&amp;#62;Run&amp;#40;&amp;#41;; // run our thread&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;return true;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;IMPLEMENT_APP&amp;#40;threaded_app&amp;#41;&lt;!--c2--&gt;&lt;/div&gt;&lt;!--ec2--&gt;&lt;br /&gt;Happy coding&amp;#33; &lt;img src=&quot;style_emoticons/&lt;#EMO_DIR#&gt;/smile.gif&quot; style=&quot;vertical-align:middle&quot; emoid=&quot;:)&quot; border=&quot;0&quot; alt=&quot;smile.gif&quot; /&gt;</description>
			<pubDate>Sat, 31 Oct 2009 12:05:58 -0500</pubDate>
			<category>C++ Tutorials</category>
			<author>gabehabe</author>
         </item>
         <item>
            <link>http://forums.dreamincode.net/showtopic134917.htm</link>
            <title>Intro Generics in Java Tutorials</title>
            <description>This tutorial shows some uses of generics.&lt;br /&gt;&lt;br /&gt;&lt;b&gt;Generics and Collections&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;A non-generic collection can hold any kind of object. Hence, the methods that get objects out of the collection are of the type java.lang.Object.&lt;br /&gt;&lt;br /&gt;Suppose you intend to have a list of String’s objects.&lt;br /&gt;Without generics:&lt;br /&gt;&lt;!--c1--&gt;&lt;div class='codetop'&gt;CODE&lt;/div&gt;&lt;div class='codemain'&gt;&lt;!--ec1--&gt;List l = new ArrayList&amp;#40;&amp;#41;;&lt;br /&gt;l.add&amp;#40;“Dream”&amp;#41;;&lt;br /&gt;l.add&amp;#40;“in”&amp;#41;;&lt;br /&gt;l.add&amp;#40;“Code”&amp;#41;;&lt;br /&gt;l.add&amp;#40;10&amp;#41;; // It compiles fine *&lt;br /&gt;&lt;br /&gt;// Getting the length of all strings in this list&lt;br /&gt;Iterator i = l.iterator&amp;#40;&amp;#41;;&lt;br /&gt;while&amp;#40;i.hasNext&amp;#40;&amp;#41;&amp;#41; {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;String s = &amp;#40;String&amp;#41;i.next&amp;#40;&amp;#41;; // cast is needed&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;System.out.println&amp;#40;s.length&amp;#40;&amp;#41;&amp;#41;;&lt;br /&gt;}&lt;!--c2--&gt;&lt;/div&gt;&lt;!--ec2--&gt;&lt;br /&gt;&lt;br /&gt;* Pay attention here. I said that compiles fine, but this is true only for Java 5 or above. Java 5 introduced the autoboxing and unboxing features. What the code really does is to insert an Integer object which has the value 10.&lt;br /&gt;&lt;br /&gt;This code runs fine, until it tries to cast an Integer to String. So an exception is through at runtime:&lt;br /&gt;Exception in thread &amp;quot;main&amp;quot; java.lang.ClassCastException: java.lang.Integer cannot be cast to java.lang.String&lt;br /&gt;&lt;br /&gt;Two great things about generics are that it ensures the type of objects that the collection can have and also eliminates the need to cast. The problem with cast is that it can fails at runtime time. Using generics, this error is caught at compile time.&lt;br /&gt;&lt;br /&gt;Now the same code using generics:&lt;br /&gt;&lt;!--c1--&gt;&lt;div class='codetop'&gt;CODE&lt;/div&gt;&lt;div class='codemain'&gt;&lt;!--ec1--&gt;// With generics&lt;br /&gt;List&amp;#60;String&amp;#62; l = new ArrayList&amp;#60;String&amp;#62;&amp;#40;&amp;#41;;&lt;br /&gt;l.add&amp;#40;&amp;#34;Dream&amp;#34;&amp;#41;;&lt;br /&gt;l.add&amp;#40;&amp;#34;in&amp;#34;&amp;#41;;&lt;br /&gt;l.add&amp;#40;&amp;#34;Code&amp;#34;&amp;#41;;&lt;br /&gt;/*l.add&amp;#40;10&amp;#41;; /* It won&amp;#39;t compile.&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Error&amp;#58; generics&amp;#092;Test1.java&amp;#58;33&amp;#58; cannot find symbol&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;symbol&amp;nbsp;&amp;nbsp;&amp;#58; method add&amp;#40;int&amp;#41;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;location&amp;#58; interface java.util.List&amp;#60;java.lang.String&amp;#62;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;l.add&amp;#40;10&amp;#41;; // Won&amp;#39;t compile. Error&amp;#58;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;*/&lt;br /&gt;&lt;br /&gt;// Getting the length of all strings in this list&lt;br /&gt;for&amp;#40;String s&amp;#58;l&amp;#41; {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;System.out.println&amp;#40;s.length&amp;#40;&amp;#41;&amp;#41;;&lt;br /&gt;}&lt;!--c2--&gt;&lt;/div&gt;&lt;!--ec2--&gt;&lt;br /&gt;&lt;br /&gt;Remove the “/*” before l.add(10); to generate the compile error. &lt;br /&gt;&lt;br /&gt;You can easily use generics for parameter and return types. The following examples illustrate this.&lt;br /&gt;&lt;br /&gt;&lt;!--c1--&gt;&lt;div class='codetop'&gt;CODE&lt;/div&gt;&lt;div class='codemain'&gt;&lt;!--ec1--&gt;public List&amp;#60;String&amp;#62; getList&amp;#40;&amp;#41; {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;return new ArrayList&amp;#60;String&amp;#62;&amp;#40;&amp;#41;;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;public void setList&amp;#40;List&amp;#60;String&amp;#62; list&amp;#41; {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;myList = list;&lt;br /&gt;}&lt;!--c2--&gt;&lt;/div&gt;&lt;!--ec2--&gt;&lt;br /&gt;&lt;br /&gt;Ok. Those were the basic uses of generics. Let’s see other interesting things.&lt;br /&gt;&lt;br /&gt;&lt;b&gt;Legacy Code&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;The following code will compile:&lt;br /&gt;&lt;br /&gt;&lt;!--c1--&gt;&lt;div class='codetop'&gt;CODE&lt;/div&gt;&lt;div class='codemain'&gt;&lt;!--ec1--&gt;List&amp;#60;String&amp;#62; l2 = new ArrayList&amp;#60;String&amp;#62;&amp;#40;&amp;#41;;&lt;br /&gt;l2.add&amp;#40;&amp;#34;Dream&amp;#34;&amp;#41;;&lt;br /&gt;l2.add&amp;#40;&amp;#34;in&amp;#34;&amp;#41;;&lt;br /&gt;OldClass oc = new OldClass&amp;#40;&amp;#41;;&lt;br /&gt;oc.insert&amp;#40;l2&amp;#41;; // No compile error and no exception&lt;br /&gt;for&amp;#40;String s&amp;#58;l2&amp;#41; { // ClassCastException&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;System.out.println&amp;#40;s.length&amp;#40;&amp;#41;&amp;#41;;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;class OldClass {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;public void insert&amp;#40;List list&amp;#41; {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;list.add&amp;#40;new Integer&amp;#40;10&amp;#41;&amp;#41;;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;br /&gt;}&lt;!--c2--&gt;&lt;/div&gt;&lt;!--ec2--&gt;&lt;br /&gt;&lt;br /&gt;In order to support legacy code, Java 5 and Java 6 allows your newer type safe code to make use of older code. So code above compiles, even passing an Integer object to a list of String. The exception only happens when you try to cast from Integer to String.&lt;br /&gt;&lt;br /&gt;&lt;b&gt;Polymorphism&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;Polymorphism doesn’t apply for generics.&lt;br /&gt;Eg:&lt;br /&gt;&lt;!--c1--&gt;&lt;div class='codetop'&gt;CODE&lt;/div&gt;&lt;div class='codemain'&gt;&lt;!--ec1--&gt;class Animal {}&lt;br /&gt;class Dog extends Animal {}&lt;br /&gt;List&amp;#60;Animal&amp;#62; list = new ArrayList&amp;#60;Dog&amp;#62;&amp;#40;&amp;#41;;&lt;!--c2--&gt;&lt;/div&gt;&lt;!--ec2--&gt;&lt;br /&gt;&lt;br /&gt;Error:&lt;br /&gt;incompatible types&lt;br /&gt;found   : java.util.ArrayList&amp;lt;generics.Dog&amp;gt;&lt;br /&gt;required: java.util.List&amp;lt;generics.Animal&amp;gt;&lt;br /&gt;                List&amp;lt;Animal&amp;gt; pList = new ArrayList&amp;lt;Dog&amp;gt;();&lt;br /&gt;&lt;br /&gt;So, in the below method, the only thing you can pass as parameter is List&amp;lt;Animal&amp;gt;.&lt;br /&gt;&lt;!--c1--&gt;&lt;div class='codetop'&gt;CODE&lt;/div&gt;&lt;div class='codemain'&gt;&lt;!--ec1--&gt;public void add&amp;#40;List&amp;#60;Animal&amp;#62; animals&amp;#41; {}&lt;br /&gt;List&amp;#60;Dog&amp;#62; dogs = new ArrayList&amp;#60;Dog&amp;#62;&amp;#40;&amp;#41;;&lt;br /&gt;add&amp;#40;dogs&amp;#41;; // error&lt;!--c2--&gt;&lt;/div&gt;&lt;!--ec2--&gt;&lt;br /&gt;&lt;br /&gt;&lt;b&gt;? wildcard&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;You can use the wildcard “?” to partially solve the above problem.&lt;br /&gt;&lt;!--c1--&gt;&lt;div class='codetop'&gt;CODE&lt;/div&gt;&lt;div class='codemain'&gt;&lt;!--ec1--&gt;public void add&amp;#40;List&amp;#60;? extends Animal&amp;#62; animals&amp;#41; {}&lt;br /&gt;List&amp;#60;Dog&amp;#62; dogs = new ArrayList&amp;#60;Dog&amp;#62;&amp;#40;&amp;#41;;&lt;br /&gt;add&amp;#40;dogs&amp;#41;; // OK&amp;#33;&amp;#33; &amp;#58;&amp;#41;&lt;!--c2--&gt;&lt;/div&gt;&lt;!--ec2--&gt;&lt;br /&gt;&lt;br /&gt;But you can’t really add something to the list, not even an Animal.&lt;br /&gt;&lt;!--c1--&gt;&lt;div class='codetop'&gt;CODE&lt;/div&gt;&lt;div class='codemain'&gt;&lt;!--ec1--&gt;public void add&amp;#40;List&amp;#60;? extends Animal&amp;#62; animals&amp;#41; {&lt;br /&gt;animals.add&amp;#40;new Animal&amp;#40;&amp;#41;&amp;#41;; // very awkward error &amp;#58;&amp;#40;&lt;br /&gt;}&lt;!--c2--&gt;&lt;/div&gt;&lt;!--ec2--&gt;&lt;br /&gt;&lt;br /&gt;The extends keyword can also be used with interfaces (in this case&amp;#33;).&lt;br /&gt;public void add(List&amp;lt;? extends Runnable&amp;gt; list) {}&lt;br /&gt;&lt;br /&gt;Another Java keyword has a special meaning in generics: super.&lt;br /&gt;&lt;!--c1--&gt;&lt;div class='codetop'&gt;CODE&lt;/div&gt;&lt;div class='codemain'&gt;&lt;!--ec1--&gt;public void add&amp;#40;List&amp;#60;? super Dog&amp;#62; dogs&amp;#41; {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;dogs.add&amp;#40;new Dog&amp;#40;&amp;#41;&amp;#41;;&lt;br /&gt;}&lt;!--c2--&gt;&lt;/div&gt;&lt;!--ec2--&gt;&lt;br /&gt;&lt;br /&gt;It means that you can pass a Dog or a supertype of Dog. Note that you can only add a Dog&amp;#33;&lt;br /&gt;&lt;b&gt;&lt;br /&gt;Conclusion&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;This was a simple introduction. I recommend you to make a search to learn some tricks and advanced techniques.&lt;br /&gt;&lt;br /&gt;&lt;b&gt;Reference&lt;/b&gt;&lt;br /&gt;Sierra, Katherine; Bates, Bert. SCJP Sun Certified Programmer for Java 6.&lt;br /&gt;&lt;a href=&quot;http://www.amazon.com/SCJP-Certified-Programmer-Java-310-065/dp/0071591060&quot; target=&quot;_blank&quot;&gt;http://www.amazon.com/SCJP-Certified-Progr...5/dp/0071591060&lt;/a&gt;&lt;br /&gt;It’s an AMZING BOOK&amp;#33;&amp;#33;&amp;#33;&lt;br /&gt;</description>
			<pubDate>Tue, 27 Oct 2009 23:37:36 -0500</pubDate>
			<category>Java Tutorials</category>
			<author>tivrfoa</author>
         </item>
         <item>
            <link>http://forums.dreamincode.net/showtopic134691.htm</link>
            <title>Highlight and search words in page in PHP Tutorials</title>
            <description>&lt;!--quoteo--&gt;&lt;div class='quotetop'&gt;QUOTE&lt;/div&gt;&lt;div class='quotemain'&gt;&lt;!--quotec--&gt;Excellent tutorial&amp;#33; Keep up the great work&lt;!--QuoteEnd--&gt;&lt;/div&gt;&lt;!--QuoteEEnd--&gt;&lt;br /&gt;Thanks &lt;img src=&quot;style_emoticons/&lt;#EMO_DIR#&gt;/smile.gif&quot; style=&quot;vertical-align:middle&quot; emoid=&quot;:)&quot; border=&quot;0&quot; alt=&quot;smile.gif&quot; /&gt;, I will try my best.</description>
			<pubDate>Sat, 31 Oct 2009 01:06:51 -0500</pubDate>
			<category>PHP Tutorials</category>
			<author>noorahmad</author>
         </item>
         <item>
            <link>http://forums.dreamincode.net/showtopic134432.htm</link>
            <title>Create own User control - Basic Steps. in Visual Basic Tutorials</title>
            <description>&lt;!--sizeo:4--&gt;&lt;span style=&quot;font-size:14pt;line-height:100%&quot;&gt;&lt;!--/sizeo--&gt;&lt;!--fonto:Times New Roman--&gt;&lt;span style=&quot;font-family:Times New Roman&quot;&gt;&lt;!--/fonto--&gt;Hello friends here , i made a simple and Basic steps to learn how to create your own controls.I think it is  very useful when you create your own controls.This post covers only basic steps to create a new control which will show images with their file id and if there is no image It will show No image. This is not a perfect one but it will help you to crate own controls with custom properties.&lt;br /&gt;&lt;!--fontc--&gt;&lt;/span&gt;&lt;!--/fontc--&gt;&lt;!--sizec--&gt;&lt;/span&gt;&lt;!--/sizec--&gt;&lt;br /&gt;First start a new project in vb then select Project Explorer , normally top of the properties.Right click on the Project 1 and select Add - User control.Here you can create new or open existing Controls. Now click new User-control.&lt;br /&gt;It is just like a vb form ,you can add buttons , labels , anything you need like a normal form.&lt;br /&gt;When you added a new user-control then you can see it in tools.&lt;br /&gt;To get your control then close the User-control then open the first form , now add your control form the tools.Please remember that it will not work if you open the User-control.Here i made normal References , nothing more ...&lt;br /&gt;&lt;!--sizeo:4--&gt;&lt;span style=&quot;font-size:14pt;line-height:100%&quot;&gt;&lt;!--/sizeo--&gt;&lt;u&gt;&lt;b&gt;Create Own User Control :&lt;/b&gt;&lt;/u&gt;&lt;!--sizec--&gt;&lt;/span&gt;&lt;!--/sizec--&gt;&lt;br /&gt;&lt;br /&gt;&lt;b&gt;Close all forms and controls , open the new User-control ..&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;Add one image control ,change its properties to :&lt;br /&gt;        Name       = img&lt;br /&gt;	Height      = 500&lt;br /&gt;	Width       = 2000&lt;br /&gt;        Stretch     = True&lt;br /&gt;Add one Label&lt;br /&gt;	Name        =lbl&lt;br /&gt;	Autosize   =false&lt;br /&gt;	BackStyle  =0-Transparent&lt;br /&gt;&lt;br /&gt;&lt;u&gt;&lt;b&gt;Changing name of user-control:&lt;/b&gt;&lt;/u&gt;&lt;br /&gt;Just change the name property like a form.Set it to MyImage.If you add your controlto your form then it will appear like MyImage1.&lt;br /&gt;&lt;br /&gt;The first and important part of a user-control is its properties , events and Methods.It is easy to create all.But the first thing to change is its Initialize and Resize.To do this Double click on the user-control then in code add this :&lt;br /&gt;&lt;br /&gt;&lt;!--c1--&gt;&lt;div class='codetop'&gt;CODE&lt;/div&gt;&lt;div class='codemain'&gt;&lt;!--ec1--&gt;Private Sub UserControl_Initialize&amp;#40;&amp;#41;&lt;br /&gt;UserControl.Height = 500&lt;br /&gt;UserControl.Width = 2000&lt;br /&gt;End Sub&lt;br /&gt;&lt;br /&gt;Private Sub UserControl_Resize&amp;#40;&amp;#41;&lt;br /&gt;img.Width = UserControl.Width&lt;br /&gt;img.Height = UserControl.Height&lt;br /&gt;lbl.Width = UserControl.Width&lt;br /&gt;lbl.Height = UserControl.Height&lt;br /&gt;End Sub&lt;!--c2--&gt;&lt;/div&gt;&lt;!--ec2--&gt;&lt;br /&gt;&lt;br /&gt;Here Initialize is like form load.Every code in Initialize works on when you create a new user control.&lt;br /&gt;Resize will work when you change the size of user-control.Here i used code to adjust the height and width of image control and label control when the user change the size of the control.Else if the user change the size of the control then it will become a disorder.&lt;br /&gt;              After that you can set its properties.Properties are visible in the properties window , it will allow users to access any part of the control like setting the control enable or disable or changing the caption.You can access the property of a control in coding.&lt;br /&gt;&lt;br /&gt;To create a new Property :&lt;br /&gt;In code view In menu bar : Take tools and click Add Procedures , then select Property [ it will create a new property ] and type &amp;quot; Caption &amp;quot; in that box.&lt;br /&gt;Then you will get this&lt;br /&gt;&lt;!--c1--&gt;&lt;div class='codetop'&gt;CODE&lt;/div&gt;&lt;div class='codemain'&gt;&lt;!--ec1--&gt;Public Property Get Caption&amp;#40;&amp;#41; As Variant&lt;br /&gt;&lt;br /&gt;End Property&lt;br /&gt;&lt;br /&gt;Public Property Let Caption&amp;#40;ByVal vNewValue As Variant&amp;#41;&lt;br /&gt;&lt;br /&gt;End Property&lt;!--c2--&gt;&lt;/div&gt;&lt;!--ec2--&gt;&lt;br /&gt;Here it will set a Property called caption like Label caption.Using this property you can use it to do what you think.Here i am using this property to display the caption of the Label - lbl and load that image file id to the image control - img.&lt;br /&gt;For this add these lines :&lt;br /&gt;&lt;!--c1--&gt;&lt;div class='codetop'&gt;CODE&lt;/div&gt;&lt;div class='codemain'&gt;&lt;!--ec1--&gt;Public Property Get Caption&amp;#40;&amp;#41; As Variant&lt;br /&gt;Caption = lbl.Caption&lt;br /&gt;End Property&lt;br /&gt;&lt;br /&gt;Public Property Let Caption&amp;#40;ByVal vNewValue As Variant&amp;#41;&lt;br /&gt;lbl.Caption = vNewValue&lt;br /&gt;PropertyChanged &amp;#34;Caption&amp;#34;&lt;br /&gt;End Property&lt;br /&gt;&lt;!--c2--&gt;&lt;/div&gt;&lt;!--ec2--&gt;&lt;br /&gt;Here it will change the caption of the label when you typed a text in the caption property of the user control. [do it in form view , after closing the control]You can use the property like normal label : UserControl11.Caption = &amp;quot;Button Click&amp;quot;&lt;br /&gt;But the new property Caption is a temporary , if you run the program the caption will change back.To stop this just change the user-control &amp;#39;s &lt;b&gt;WriteProperties &amp;amp; ReadProperties&lt;/b&gt;.Now in code view add this :&lt;br /&gt;&lt;!--c1--&gt;&lt;div class='codetop'&gt;CODE&lt;/div&gt;&lt;div class='codemain'&gt;&lt;!--ec1--&gt;Private Sub UserControl_WriteProperties&amp;#40;PropBag As PropertyBag&amp;#41;&lt;br /&gt;PropBag.WriteProperty &amp;#34;Caption&amp;#34;, lbl.Caption&lt;br /&gt;End Sub&lt;br /&gt;&lt;br /&gt;Private Sub UserControl_ReadProperties&amp;#40;PropBag As PropertyBag&amp;#41;&lt;br /&gt;lbl.Caption = PropBag.ReadProperty&amp;#40;&amp;#34;Caption&amp;#34;, lbl.Caption&amp;#41;&lt;br /&gt;End Sub&lt;!--c2--&gt;&lt;/div&gt;&lt;!--ec2--&gt;&lt;br /&gt;Now the caption will become permanent.If you want to add image to your image control then Change the Caption and ReadProperties code to this&lt;br /&gt;&lt;!--c1--&gt;&lt;div class='codetop'&gt;CODE&lt;/div&gt;&lt;div class='codemain'&gt;&lt;!--ec1--&gt;&lt;br /&gt;Public Property Get Caption&amp;#40;&amp;#41; As Variant&lt;br /&gt;Caption = lbl.Caption&lt;br /&gt;End Property&lt;br /&gt;&lt;br /&gt;Public Property Let Caption&amp;#40;ByVal vNewValue As Variant&amp;#41;&lt;br /&gt;On Error Resume Next&lt;br /&gt;lbl.Caption = vNewValue&lt;br /&gt;PropertyChanged &amp;#34;Caption&amp;#34;&lt;br /&gt;img.Picture = LoadPicture&amp;#40;lbl.Caption&amp;#41;&lt;br /&gt;End Property&lt;br /&gt;&lt;br /&gt;Private Sub UserControl_ReadProperties&amp;#40;PropBag As PropertyBag&amp;#41;&lt;br /&gt;On Error Resume Next&lt;br /&gt;lbl.Caption = PropBag.ReadProperty&amp;#40;&amp;#34;Caption&amp;#34;, lbl.Caption&amp;#41;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Set img.Picture = LoadPicture&amp;#40;lbl.Caption&amp;#41;&lt;br /&gt;End Sub&lt;br /&gt;&lt;!--c2--&gt;&lt;/div&gt;&lt;!--ec2--&gt;&lt;br /&gt;Now it will load image when you give the file id to your caption.If it is a wrong file name then nothing will happen , for that i am used On Error Resume Next.Now you can change the image of the control at run time just call the Caption property and give a value.&lt;br /&gt;&lt;br /&gt;&lt;u&gt;&lt;b&gt;Adding a method&lt;/u&gt;&lt;/b&gt; will help you to do more works in user-control in form or at run-time.If you want to add a new method then use this codes:&lt;br /&gt;Take tools and click Add Procedures , then select Sub [ it will create a new method ]Type &amp;quot; check &amp;quot; in that box.The result will be :&lt;br /&gt;&lt;br /&gt;&lt;!--c1--&gt;&lt;div class='codetop'&gt;CODE&lt;/div&gt;&lt;div class='codemain'&gt;&lt;!--ec1--&gt;Public Sub check&amp;#40;&amp;#41;&lt;br /&gt;If img.Picture = False Then lbl.Caption = &amp;#34;No Image&amp;#34;&lt;br /&gt;End Sub&lt;!--c2--&gt;&lt;/div&gt;&lt;!--ec2--&gt;&lt;br /&gt;Here i used a new method to check that the image contains any image or not.The real use of such methods appear when you need to check it at run time.For calling one method open form add a button and in code view just add one line like this :&lt;b&gt; UserControl11.check , the result will be &amp;quot; No Image &amp;quot; .&lt;/b&gt; When you run the program and click the button then it will call the method.&lt;br /&gt;&lt;u&gt;&lt;b&gt;Adding an event&lt;/b&gt;&lt;/u&gt;&lt;br /&gt;Events appear when you double click them or selecting from a combo [ top side in the code view].Events are used to do action when the user did something. for example Click event , it will activate the code in that event when you click that control.Adding an event is like adding a new method .To Add a new event :&lt;br /&gt;Take tools and click Add Procedures , then select Event [ it will create a new method ]&lt;br /&gt;&lt;b&gt;Then you will get : Public Event Click()&lt;/b&gt;&lt;br /&gt;Add this to your code.It will call the click event when user clicks the label or control.&lt;br /&gt;&lt;!--c1--&gt;&lt;div class='codetop'&gt;CODE&lt;/div&gt;&lt;div class='codemain'&gt;&lt;!--ec1--&gt;Private Sub lbl_Click&amp;#40;&amp;#41;&lt;br /&gt;RaiseEvent imgClick&lt;br /&gt;End Sub&lt;br /&gt;&lt;br /&gt;Private Sub UserControl_Click&amp;#40;&amp;#41;&lt;br /&gt;RaiseEvent imgClick&lt;br /&gt;End Sub&lt;!--c2--&gt;&lt;/div&gt;&lt;!--ec2--&gt;&lt;br /&gt;To access the new event , close all forms and controls , open the first form, and add one new control and double click it then you can see the new event  imgClick.&lt;br /&gt;Like click you can add any event for your control.To make your control more useful it is necessary to create more properties like Enable , setting font ....&lt;b&gt;You can add any properties you like but the important thing is you must change it or add codes in ReadProperties &amp;amp; WriteProperties.&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;Enable &amp;#092; Disable : Allow you to make a control enable or disable.&lt;br /&gt;&lt;!--c1--&gt;&lt;div class='codetop'&gt;CODE&lt;/div&gt;&lt;div class='codemain'&gt;&lt;!--ec1--&gt;&lt;br /&gt;Public Property Get Enabled&amp;#40;&amp;#41; As Boolean&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Enabled = m_bEnabled &amp;#39;declare m_bEnabled before Private m_bEnabled As Boolean&lt;br /&gt;End Property&lt;br /&gt;Public Property Let Enabled&amp;#40;ByVal New_Enabled As Boolean&amp;#41;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;m_bEnabled = New_Enabled&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;UserControl.Enabled = m_bEnabled&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;PropertyChanged &amp;#34;Enabled&amp;#34;&lt;br /&gt;End Property&lt;br /&gt;&lt;!--c2--&gt;&lt;/div&gt;&lt;!--ec2--&gt;&lt;br /&gt;Font : will change the font of the caption.&lt;br /&gt;&lt;!--c1--&gt;&lt;div class='codetop'&gt;CODE&lt;/div&gt;&lt;div class='codemain'&gt;&lt;!--ec1--&gt;Public Property Get Font&amp;#40;&amp;#41; As StdFont&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Set Font = UserControl.Font&lt;br /&gt;End Property&lt;br /&gt;&lt;br /&gt;Public Property Set Font&amp;#40;ByVal New_Font As StdFont&amp;#41;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Set UserControl.Font = New_Font&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Set lbl.Font = New_Font&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Refresh&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;PropertyChanged &amp;#34;Font&amp;#34;&lt;br /&gt;End Property&lt;!--c2--&gt;&lt;/div&gt;&lt;!--ec2--&gt;&lt;br /&gt;&lt;br /&gt;Change the ReadProperties &amp;amp; WriteProperties to make the property working.&lt;br /&gt;&lt;!--c1--&gt;&lt;div class='codetop'&gt;CODE&lt;/div&gt;&lt;div class='codemain'&gt;&lt;!--ec1--&gt;&lt;br /&gt;Private Sub UserControl_ReadProperties&amp;#40;PropBag As PropertyBag&amp;#41;&lt;br /&gt;On Error Resume Next&lt;br /&gt;lbl.Caption = PropBag.ReadProperty&amp;#40;&amp;#34;Caption&amp;#34;, lbl.Caption&amp;#41;&lt;br /&gt;Set img.Picture = LoadPicture&amp;#40;lbl.Caption&amp;#41;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;With PropBag&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Set UserControl.Font = .ReadProperty&amp;#40;&amp;#34;Font&amp;#34;, Ambient.Font&amp;#41;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Set lbl.Font = .ReadProperty&amp;#40;&amp;#34;Font&amp;#34;, Ambient.Font&amp;#41;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;m_bEnabled = .ReadProperty&amp;#40;&amp;#34;Enabled&amp;#34;, True&amp;#41;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;UserControl.Enabled = m_bEnabled&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;End With&lt;br /&gt;End Sub&lt;br /&gt;&lt;br /&gt;Private Sub UserControl_WriteProperties&amp;#40;PropBag As PropertyBag&amp;#41;&lt;br /&gt;PropBag.WriteProperty &amp;#34;Caption&amp;#34;, lbl.Caption&lt;br /&gt;PropBag.WriteProperty &amp;#34;Caption&amp;#34;, lbl.Caption&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;With PropBag&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;.WriteProperty &amp;#34;Enabled&amp;#34;, m_bEnabled, True&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;.WriteProperty &amp;#34;Font&amp;#34;, UserControl.Font, Ambient.Font&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;End With&lt;br /&gt;End Sub&lt;!--c2--&gt;&lt;/div&gt;&lt;!--ec2--&gt;&lt;br /&gt;&lt;br /&gt;You can make the control enable or disable and change the font of the caption&lt;br /&gt;The full code i used to create this control is given.[attachmentid=14551]&lt;br /&gt;&lt;br /&gt;Best Of Luck ...</description>
			<pubDate>Mon, 26 Oct 2009 04:05:14 -0500</pubDate>
			<category>Visual Basic Tutorials</category>
			<author>Vineeth k</author>
         </item>
         <item>
            <link>http://forums.dreamincode.net/showtopic133327.htm</link>
            <title>Twitter Logo Remake In Photoshop [Regular + Halloween] in Graphic Design &amp; Photoshop Tutorials</title>
            <description>Here&amp;#39;s the final result of the logo we will be making today:&lt;br /&gt;&lt;br /&gt;&lt;img src=&quot;http://img195.imageshack.us/img195/6375/twitterlogow.png&quot; border=&quot;0&quot; alt=&quot;IPB Image&quot; /&gt;&lt;br /&gt;&lt;br /&gt;And here is my Halloween version:&lt;br /&gt;&lt;br /&gt;&lt;img src=&quot;http://img198.imageshack.us/img198/5865/twitterhalloween.png&quot; border=&quot;0&quot; alt=&quot;IPB Image&quot; /&gt;&lt;br /&gt;&lt;br /&gt;First off, you need to find a font that you would like to use. I generally use the font known as &amp;quot;Tondo&amp;quot; because it resembles the actual font of the twitter logo very closely.&lt;br /&gt;&lt;br /&gt;You can download Tondo here: &lt;a href=&quot;http://www.dafont.com/tondo.font&quot; target=&quot;_blank&quot;&gt;http://www.dafont.com/tondo.font&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;Install it (or whatever font) on Windows XP by opening up Control Panel -&amp;gt; Fonts, and then dragging the font over into the Fonts folder. On vista, simply right-click the font and select &amp;quot;Install.&amp;quot;&lt;br /&gt;&lt;br /&gt;Once you have your font ready, open up Photoshop. Your document should be properly sized to fit the logo but not too big as to leave empty space. I will be using the size [inline]350x125[/inline] pixels. Resolution 72 pixels per inch. Color mode RGB, 8 bit. Background contents white (we will change this later). Just the default settings pretty much.&lt;br /&gt;&lt;br /&gt;&lt;img src=&quot;http://img26.imageshack.us/img26/8621/photoshoptut1.png&quot; border=&quot;0&quot; alt=&quot;IPB Image&quot; /&gt;&lt;br /&gt;&lt;br /&gt;Now that we have our open document, let&amp;#39;s start off by unlocking the background layer (just in case). To do this, ALT+Double Click the name of the layer.&lt;br /&gt;&lt;br /&gt;Now, let&amp;#39;s create a new layer using the New Layer icon or by pressing CTRL+ALT+SHIFT+N.&lt;br /&gt;&lt;br /&gt;Go ahead and select the text tool, select the Tondo font (or whatever font you are using), set the size to about 72 points, and type out the word &amp;quot;twitter&amp;quot; (or whatever text you wish to type). Yes, leave the &amp;#39;t&amp;#39; lowercase.&lt;br /&gt;&lt;br /&gt;Your stage should now look like this:&lt;br /&gt;&lt;br /&gt;&lt;img src=&quot;http://img23.imageshack.us/img23/5366/photoshoptut2.png&quot; border=&quot;0&quot; alt=&quot;IPB Image&quot; /&gt;&lt;br /&gt;&lt;br /&gt;There is a small adjustment we need to make to the text&amp;#39;s character spacing. I&amp;#39;ve noticed the twitter logo seems to have the characters pretty close together. After some experimentation, I find that [inline]-60[/inline] character tracking works best for the font size 72 points.&lt;br /&gt;&lt;br /&gt;To change this, go to Window -&amp;gt; Character. On the window that pops up, find Character Tracking, and set it to -60. Character tracking is the text highlighted in the screenshot below. While your in the character panel, go ahead and change the text color to whatever you like. I will be using the twitter logo&amp;#39;s exact color which is hex code [inline]#33ccff[/inline].&lt;br /&gt;&lt;br /&gt;&lt;img src=&quot;http://img8.imageshack.us/img8/8108/photoshoptut3.png&quot; border=&quot;0&quot; alt=&quot;IPB Image&quot; /&gt;&lt;br /&gt;&lt;br /&gt;Now, select the background layer (the layer we unlocked earlier), set your foreground color to solid black by pressing the &amp;quot;D&amp;quot; key on your keyboard to restore default colors, or just clicking the foreground icon and changing it in the color panel. Now, press ALT+Backspace to fill the layer with black. We are doing this right now so that we can see the white stroke we are about to apply to the text.&lt;br /&gt;&lt;br /&gt;Your stage should now look like this:&lt;br /&gt;&lt;br /&gt;&lt;img src=&quot;http://img7.imageshack.us/img7/7545/photoshoptut4.png&quot; border=&quot;0&quot; alt=&quot;IPB Image&quot; /&gt;&lt;br /&gt;&lt;br /&gt;Alright, now select the layer with our text on it, and go to Layer-&amp;gt;Layer Style-&amp;gt;Blending Options. Check the box next to &amp;quot;Stroke&amp;quot;. Now, we need to find a decent size for our stroke. I find that for font size 72 point, the stroke size of [inline]8[/inline] works perfectly. Change the fill color to solid white (#FFFFFF).&lt;br /&gt;&lt;br /&gt;&lt;img src=&quot;http://img41.imageshack.us/img41/4107/photoshoptut5.png&quot; border=&quot;0&quot; alt=&quot;IPB Image&quot; /&gt;&lt;br /&gt;&lt;br /&gt;Now, your logo is almost done. This last step is optional, but I think it adds a bit more style to the logo.&lt;br /&gt;&lt;br /&gt;First, CTRL+Click the icon of the text layer. This will make a complete selection around the next. Next, create a new layer above the text layer. Select the elliptical marquee (you may have to click and hold down the rectangular marquee tool until a list pops up and the select the elliptical from the list). Hold SHIFT+ALT, click a bit off the stage in the top left hand corner, then hold and drag to off the stage a bit in the right hand corner. Let go of the mouse and you should have created a new, oval like selection at the top of the text.&lt;br /&gt;&lt;br /&gt;&lt;img src=&quot;http://img198.imageshack.us/img198/9530/photoshoptut6.png&quot; border=&quot;0&quot; alt=&quot;IPB Image&quot; /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Select the gradient tool by clicking down and holding on the fill tool (the bucket) until a last comes down, then selecting the gradient. Change your foreground color to solid white (#FFFFFF) and change the gradient settings to Foreground to Transparent by clicking on the gradient in the upper left hand corner of the screen under the &amp;quot;Edit&amp;quot; and &amp;quot;Image&amp;quot; drop-down buttons, then selecting Foreground to Transparent from the list (the second icon on the list).&lt;br /&gt;&lt;br /&gt;Hold down SHIFT and click and hold a bit above the text. Drag your mouse down to a bit below the text and let go of the mouse. This will make a nice highlight on the text. You may need to experiment around with where you click and where you let go for best results. Now, if needed, drop the opacity of the new layer with the highlight on it down a bit. Sometimes I find 60% opcaity best, sometimes 40%, and sometimes I don&amp;#39;t change the opacity at all. It really depends on where you clicked and let go of the mouse during the gradient stage on how intense the gradient is and where it fades out.&lt;br /&gt;&lt;br /&gt;Here is what the stage should look like:&lt;br /&gt;&lt;br /&gt;&lt;img src=&quot;http://img195.imageshack.us/img195/8933/photoshoptut7.png&quot; border=&quot;0&quot; alt=&quot;IPB Image&quot; /&gt;&lt;br /&gt;&lt;br /&gt;Now, if you wish to have a transparent background, click the eyeball next to the background layer to turn it off. Thank you for reading my tutorial. I hope it gave you new insight into photoshop and helped you create a cool logo. You can change the text of the logo to whatever you like and experiment around with the colors and settings to create new and cool logos (like the Halloween version I created).&lt;br /&gt;&lt;br /&gt;Again, here is the final result of the logo:&lt;br /&gt;&lt;br /&gt;&lt;img src=&quot;http://img195.imageshack.us/img195/6375/twitterlogow.png&quot; border=&quot;0&quot; alt=&quot;IPB Image&quot; /&gt;</description>
			<pubDate>Tue, 20 Oct 2009 19:40:26 -0500</pubDate>
			<category>Graphic Design &amp; Photoshop Tutorials</category>
			<author>Master Jake</author>
         </item>
         <item>
            <link>http://forums.dreamincode.net/showtopic133300.htm</link>
            <title>Password Reset System Without Using A Database in PHP Tutorials</title>
            <description>NOTE: &amp;quot;Without Using A Database&amp;quot; means we aren&amp;#39;t going to be storing keys in the database, not that we won&amp;#39;t be using one period. We will need a database with user&amp;#39;s in them; otherwise, resetting passwords is pretty pointless.&lt;br /&gt;&lt;br /&gt;This tutorial is going to be on a password reset system to go with your registration/login systems. People forget their passwords often, so it is a good idea to create a system allowing them to reset their password when needed.&lt;br /&gt;&lt;br /&gt;Now, there are a couple ways to go about doing this. One is without the use of a database, and one is with the use of a database. Obviously, we are going to be going over the one without the use of a database today.&lt;br /&gt;&lt;br /&gt;The negative end of this is that each user&amp;#39;s unique password reset key will always be the same. This being the case, this key should be protected even more than the password itself. I recommend telling the user&amp;#39;s that when you e-mail them the key. If they are to give out their unique key to someone (as well as their e-mail address), anyone will be able to reset their account password at any time.&lt;br /&gt;&lt;br /&gt;The positive end of actually using a database is the exact opposite of the negative end of not using one. When using a database, you can also generate a unique key for each user which is only good for one password recovery. This is much more secure as even if a user does give out his/her key, the password can only be reset once using that key. If a user&amp;#39;s account is stolen, he/she can simply reset the password again which will send them a new unique key. They can use this new unique key to reset their password and then their account is safe again.&lt;br /&gt;&lt;br /&gt;However, as stated, we aren&amp;#39;t going to be using the database approach today.&lt;br /&gt;&lt;br /&gt;Now, there are a few things this password reset system depends on:&lt;br /&gt;&lt;br /&gt;1. PHP mail() function must be enabled&lt;br /&gt;2. You must have each user&amp;#39;s e-mail stored in a database in order for us to mail them their password&lt;br /&gt;&lt;br /&gt;If you are ready, let&amp;#39;s get started.&lt;br /&gt;&lt;br /&gt; &lt;img src=&quot;style_emoticons/&lt;#EMO_DIR#&gt;/smile.gif&quot; style=&quot;vertical-align:middle&quot; emoid=&quot;:)&quot; border=&quot;0&quot; alt=&quot;smile.gif&quot; /&gt; &lt;br /&gt;&lt;br /&gt;First of all, we will use 2 pages for this complete system. I will only be posting the important snippets of each page such as the form and PHP script. We&amp;#39;ll call these 2 pages &lt;b&gt;forgot_password.php&lt;/b&gt; and &lt;b&gt;reset_password.php&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;Let&amp;#39;s start with forgot_password.php. We need to create a form which asks for the user&amp;#39;s e-mail. The action of the form will be &amp;#036;_SERVER[&amp;quot;PHP_SELF&amp;quot;] so that it returns to the same page the form is on to process the information. We will use PHP at the top of this page to process the form, create the unique user key, and then send it to them via e-mail.&lt;br /&gt;&lt;br /&gt;Let&amp;#39;s do the form first:&lt;br /&gt;forgot_password.php&lt;br /&gt;&lt;!--c1--&gt;&lt;div class='codetop'&gt;CODE&lt;/div&gt;&lt;div class='codemain'&gt;&lt;!--ec1--&gt;&lt;br /&gt;&amp;#60;form action=&amp;#34;&amp;#60;?php echo &amp;#036;_SERVER&amp;#91;&amp;#34;PHP_SELF&amp;#34;&amp;#93;; ?&amp;#62;&amp;#34; method=&amp;#34;post&amp;#34;&amp;#62;&lt;br /&gt;E-mail Address&amp;#58; &amp;#60;input type=&amp;#34;text&amp;#34; name=&amp;#34;email&amp;#34; size=&amp;#34;20&amp;#34; /&amp;#62; &amp;#60;input type=&amp;#34;submit&amp;#34; name=&amp;#34;ForgotPasswordForm&amp;#34; value=&amp;#34; Process &amp;#34; /&amp;#62;&lt;br /&gt;&amp;#60;/form&amp;#62;&lt;br /&gt;&lt;!--c2--&gt;&lt;/div&gt;&lt;!--ec2--&gt;&lt;br /&gt;&lt;br /&gt;Alright. We have a text field called &amp;quot;email&amp;quot; and a submit button called &amp;quot;ForgotPasswordForm.&amp;quot; The submit button is named so that we can check to see if the right form was submitted.&lt;br /&gt;&lt;br /&gt;Now let&amp;#39;s get onto the PHP code for this page:&lt;br /&gt;forgot_password.php&lt;br /&gt;&lt;!--c1--&gt;&lt;div class='codetop'&gt;CODE&lt;/div&gt;&lt;div class='codemain'&gt;&lt;!--ec1--&gt;&lt;br /&gt;&amp;#60;?php&lt;br /&gt;&lt;br /&gt;// Connect to MySQL&lt;br /&gt;&amp;#036;c = mysql_connect&amp;#40;&amp;#34;localhost&amp;#34;, &amp;#34;root&amp;#34;, &amp;#34;&amp;#34;&amp;#41;;&lt;br /&gt;mysql_select_db&amp;#40;&amp;#34;main&amp;#34;, &amp;#036;c&amp;#41;;&lt;br /&gt;&lt;br /&gt;// Was the form submitted?&lt;br /&gt;if &amp;#40;&amp;#036;_POST&amp;#91;&amp;#34;ForgotPasswordForm&amp;#34;&amp;#93;&amp;#41;&lt;br /&gt;{&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;// Harvest submitted e-mail address&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;#036;email = mysql_real_escape_string&amp;#40;&amp;#036;_POST&amp;#91;&amp;#34;email&amp;#34;&amp;#93;&amp;#41;;&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;// Check to see if a user exists with this e-mail&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;#036;userExists = mysql_fetch_assoc&amp;#40;mysql_query&amp;#40;&amp;#34;SELECT &amp;#96;email&amp;#96; FROM &amp;#96;users&amp;#96; WHERE &amp;#96;email&amp;#96; = &amp;#39;&amp;#036;email&amp;#39;&amp;#34;&amp;#41;&amp;#41;;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;if &amp;#40;&amp;#036;userExists&amp;#91;&amp;#34;email&amp;#34;&amp;#93;&amp;#41;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;// Create a unique salt. This will never leave PHP unencrypted.&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;#036;salt = &amp;#34;PiuwrO1#O0rl@+luH1&amp;#33;froe*l?8oEb&amp;#33;iu&amp;#41;_1Xaspi*&amp;#40;sw&amp;#40;^&amp;amp;.laBr~u3i&amp;#33;c?es-l651&amp;#34;;&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;// Create the unique user password reset key&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;#036;password = md5&amp;#40;&amp;#036;salt . &amp;#036;userExists&amp;#91;&amp;#34;email&amp;#34;&amp;#93;&amp;#41;&amp;#41;;&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;// Create a url which we will direct them to reset their password&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;#036;pwrurl = &amp;#34;www.yoursite.com/reset_password.php?q=&amp;#34; . &amp;#036;password;&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;// Mail them their key&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;#036;mailbody = &amp;#34;Dear user,&amp;#092;n&amp;#092;nIf this e-mail does not apply to you please ignore it. It appears that you have requested a password reset at our website www.yoursitehere.com&amp;#092;n&amp;#092;nTo reset your password, please click the link below. If you cannot click it, please paste it into your web browser&amp;#39;s address bar.&amp;#092;n&amp;#092;n&amp;#34; . &amp;#036;pwrurl . &amp;#34;&amp;#092;n&amp;#092;nThanks,&amp;#092;nThe Administration&amp;#34;;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;mail&amp;#40;&amp;#036;userExists&amp;#91;&amp;#34;email&amp;#34;&amp;#93;, &amp;#34;www.yoursitehere.com - Password Reset&amp;#34;, &amp;#036;mailbody&amp;#41;;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;echo &amp;#34;Your password recovery key has been sent to your e-mail address.&amp;#34;;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;else&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;echo &amp;#34;No user with that e-mail address exists.&amp;#34;;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;?&amp;#62;&lt;br /&gt;&lt;!--c2--&gt;&lt;/div&gt;&lt;!--ec2--&gt;&lt;br /&gt;&lt;br /&gt;Quite a bit is going on here, so let&amp;#39;s break it down into sections and I&amp;#39;ll explain what each is doing.&lt;br /&gt;&lt;br /&gt;&lt;!--c1--&gt;&lt;div class='codetop'&gt;CODE&lt;/div&gt;&lt;div class='codemain'&gt;&lt;!--ec1--&gt;&lt;br /&gt;&amp;#60;?php&lt;br /&gt;&lt;br /&gt;// Connect to MySQL&lt;br /&gt;&amp;#036;c = mysql_connect&amp;#40;&amp;#34;localhost&amp;#34;, &amp;#34;root&amp;#34;, &amp;#34;&amp;#34;&amp;#41;;&lt;br /&gt;mysql_select_db&amp;#40;&amp;#34;main&amp;#34;, &amp;#036;c&amp;#41;;&lt;br /&gt;&lt;!--c2--&gt;&lt;/div&gt;&lt;!--ec2--&gt;&lt;br /&gt;&lt;br /&gt;We start by connecting to MySQL so that we can check to see if a user exists with the submitted e-mail, etc. The host, username, password, and database name may be different for your account. You should know your MySQL settings.&lt;br /&gt;&lt;br /&gt;&lt;!--c1--&gt;&lt;div class='codetop'&gt;CODE&lt;/div&gt;&lt;div class='codemain'&gt;&lt;!--ec1--&gt;&lt;br /&gt;// Was the form submitted?&lt;br /&gt;if &amp;#40;&amp;#036;_POST&amp;#91;&amp;#34;ForgotPasswordForm&amp;#34;&amp;#93;&amp;#41;&lt;br /&gt;{&lt;br /&gt;&lt;!--c2--&gt;&lt;/div&gt;&lt;!--ec2--&gt;&lt;br /&gt;&lt;br /&gt;Here we are just checking to see if the form was submitted. If the post value of ForgotPasswordForm (the name of our form&amp;#39;s submit button) is true, then the form was submitted.&lt;br /&gt;&lt;br /&gt;&lt;!--c1--&gt;&lt;div class='codetop'&gt;CODE&lt;/div&gt;&lt;div class='codemain'&gt;&lt;!--ec1--&gt;&lt;br /&gt;// Harvest submitted e-mail address&lt;br /&gt;&amp;#036;email = mysql_real_escape_string&amp;#40;&amp;#036;_POST&amp;#91;&amp;#34;email&amp;#34;&amp;#93;&amp;#41;;&lt;br /&gt;&lt;!--c2--&gt;&lt;/div&gt;&lt;!--ec2--&gt;&lt;br /&gt;&lt;br /&gt;Here we are retrieving the e-mail submitted from the form and MySQL_Real escaping it. This is so that when we check it with the database, it won&amp;#39;t contain harmful characters which can be used for SQL Injection. &lt;!--coloro:#CC0000--&gt;&lt;span style=&quot;color:#CC0000&quot;&gt;&lt;!--/coloro--&gt;(Hackers are terrible people)&lt;!--colorc--&gt;&lt;/span&gt;&lt;!--/colorc--&gt;&lt;br /&gt;&lt;br /&gt;&lt;!--c1--&gt;&lt;div class='codetop'&gt;CODE&lt;/div&gt;&lt;div class='codemain'&gt;&lt;!--ec1--&gt;&lt;br /&gt;// Check to see if a user exists with this e-mail&lt;br /&gt;&amp;#036;userExists = mysql_fetch_assoc&amp;#40;mysql_query&amp;#40;&amp;#34;SELECT &amp;#96;email&amp;#96; FROM &amp;#96;users&amp;#96; WHERE &amp;#96;email&amp;#96; = &amp;#39;&amp;#036;email&amp;#39;&amp;#34;&amp;#41;&amp;#41;;&lt;br /&gt;if &amp;#40;&amp;#036;userExists&amp;#91;&amp;#34;email&amp;#34;&amp;#93;&amp;#41;&lt;br /&gt;{&lt;br /&gt;&lt;!--c2--&gt;&lt;/div&gt;&lt;!--ec2--&gt;&lt;br /&gt;&lt;br /&gt;These lines of code are interesting. We are creating a variable called &amp;quot;&amp;#036;userExists&amp;quot; which will actually become an associative array from mysql_fetch_assoc(). Basically, it is running a query saying, &amp;quot;Select the user&amp;#39;s e-mail address from the table &amp;#96;users&amp;#96; where their e-mail address is equal to the one submitted.&amp;quot;&lt;br /&gt;&lt;br /&gt;Why are we doing this exactly? Well, to check to see if the user really does exists, of course. The fields in the query will change depending on your database, but I&amp;#39;m sure you already knew that. The next if statement checks to see if [inline]&amp;#036;userExists[&amp;quot;email&amp;quot;][/inline] has a value. If it does, then we know the user exists (because the query returned a value into the variable).&lt;br /&gt;&lt;br /&gt;&lt;!--c1--&gt;&lt;div class='codetop'&gt;CODE&lt;/div&gt;&lt;div class='codemain'&gt;&lt;!--ec1--&gt;&lt;br /&gt;// Create a unique salt. This will never leave PHP unencrypted.&lt;br /&gt;&amp;#036;salt = &amp;#34;PiuwrO1#O0rl@+luH1&amp;#33;froe*l?8oEb&amp;#33;iu&amp;#41;_1Xaspi*&amp;#40;sw&amp;#40;^&amp;amp;.laBr~u3i&amp;#33;c?es-l651&amp;#34;;&lt;br /&gt;&lt;!--c2--&gt;&lt;/div&gt;&lt;!--ec2--&gt;&lt;br /&gt;&lt;br /&gt;You may be wondering what this is. Well basically, it&amp;#39;s a SALT. Now what is a SALT? It&amp;#39;s a key of random letters, numbers, digits in general, characters, whatever you want to call it. It&amp;#39;s basically a key that never leaves your PHP code. You do not store your salt in a database, print it to the screen, or ANYTHING without it being encrypted. It also needs to be long and very random so that it is very difficult to figure out what the salt really is when it is encrypted.&lt;br /&gt;&lt;br /&gt;&lt;!--c1--&gt;&lt;div class='codetop'&gt;CODE&lt;/div&gt;&lt;div class='codemain'&gt;&lt;!--ec1--&gt;&lt;br /&gt;// Create the unique user password reset key&lt;br /&gt;&amp;#036;password = md5&amp;#40;&amp;#036;salt . &amp;#036;userExists&amp;#91;&amp;#34;email&amp;#34;&amp;#93;&amp;#41;&amp;#41;;&lt;br /&gt;&lt;!--c2--&gt;&lt;/div&gt;&lt;!--ec2--&gt;&lt;br /&gt;&lt;br /&gt;This line makes use of the SALT. Basically we are saying, add the SALT together with the user&amp;#39;s e-mail address and then hash it with MD5. If the user entered say &amp;quot;blahman@yahoo.com&amp;quot; for his e-mail address, the salt combined with that would become:&lt;br /&gt;&lt;br /&gt;[inline]PiuwrO1#O0rl@+luH1&amp;#33;froe*l?8oEb&amp;#33;iu)_1Xaspi*(sw(^&amp;amp;.laBr~u3i&amp;#33;c?es-l651blahman@yahoo.com[/inline]&lt;br /&gt;&lt;br /&gt;Now, when we hash this entire new combined string in MD5, it becomes secure. You will see later how we use this key to actually check and reset the password.&lt;br /&gt;&lt;br /&gt;&lt;!--c1--&gt;&lt;div class='codetop'&gt;CODE&lt;/div&gt;&lt;div class='codemain'&gt;&lt;!--ec1--&gt;&lt;br /&gt;// Create a url which we will direct them to reset their password&lt;br /&gt;&amp;#036;pwrurl = &amp;#34;http&amp;#58;//www.yoursite.com/reset_password.php?q=&amp;#34; . &amp;#036;password;&lt;br /&gt;&lt;!--c2--&gt;&lt;/div&gt;&lt;!--ec2--&gt;&lt;br /&gt;&lt;br /&gt;Here we are creating a url and storing it in the variable &amp;quot;&amp;#036;pwurl.&amp;quot; You don&amp;#39;t have to store it into a variable and can actually put in the mail string itself, but I did this so it would be easier to point out and explain.&lt;br /&gt;&lt;br /&gt;You basically need the URL to point your websites &amp;quot;reset_password.php&amp;quot; page that we talked about earlier in this tutorial. We are also adding &amp;quot;?q=&amp;quot; to the end of it and appending the user&amp;#39;s new password key onto it. This way, we can check the URL on the &amp;quot;reset_password.php&amp;quot; page to get the user&amp;#39;s key when they click the link from their e-mail.&lt;br /&gt;&lt;br /&gt;&lt;!--c1--&gt;&lt;div class='codetop'&gt;CODE&lt;/div&gt;&lt;div class='codemain'&gt;&lt;!--ec1--&gt;&lt;br /&gt;// Mail them their key&lt;br /&gt;&amp;#036;mailbody = &amp;#34;Dear user,&amp;#092;n&amp;#092;nIf this e-mail does not apply to you please ignore it. It appears that you have requested a password reset at our website www.yoursitehere.com&amp;#092;n&amp;#092;nTo reset your password, please click the link below. If you cannot click it, please paste it into your web browser&amp;#39;s address bar.&amp;#092;n&amp;#092;n&amp;#34; . &amp;#036;pwrurl . &amp;#34;&amp;#092;n&amp;#092;nThanks,&amp;#092;nThe Administration&amp;#34;;&lt;br /&gt;mail&amp;#40;&amp;#036;userExists&amp;#91;&amp;#34;email&amp;#34;&amp;#93;, &amp;#34;www.yoursitehere.com - Password Reset&amp;#34;, &amp;#036;mailbody&amp;#41;;&lt;br /&gt;echo &amp;#34;Your password recovery key has been sent to your e-mail address.&amp;#34;;&lt;br /&gt;&lt;!--c2--&gt;&lt;/div&gt;&lt;!--ec2--&gt;&lt;br /&gt;&lt;br /&gt;Here is the long message stored in the variable &amp;quot;&amp;#036;mailbody&amp;quot; which basically tells the user, &amp;quot;hey, if this is you, then click this link and reset your password.&amp;quot; You will also see use of the &amp;quot;&amp;#036;pwrurl&amp;quot; variable inside the &amp;quot;&amp;#036;mailbody&amp;quot; string. That is the area where we are placing their password reset link we generated above. Finally, we are using mail() to actually send them the e-mail. We are using &amp;quot;www.yoursitehere.com - Password Reset&amp;quot; as the subject and the value of &amp;quot;&amp;#036;mailbody&amp;quot; as the body message.&lt;br /&gt;&lt;br /&gt;&lt;!--c1--&gt;&lt;div class='codetop'&gt;CODE&lt;/div&gt;&lt;div class='codemain'&gt;&lt;!--ec1--&gt;&lt;br /&gt;}&lt;br /&gt;else&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;echo &amp;#34;No user with that e-mail address exists.&amp;#34;;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;?&amp;#62;&lt;br /&gt;&lt;!--c2--&gt;&lt;/div&gt;&lt;!--ec2--&gt;&lt;br /&gt;&lt;br /&gt;Here we are just cleaning up. The else refers to the if statement regarding whether or not the user actually exists. The last curly bracket closes the if statement regarding whether or not the form was actually submitted.&lt;br /&gt;&lt;br /&gt;So, now we have created a page which asks the user for their e-mail address; and, if a user exists with that e-mail address, sends them an e-mail with a unique password recovery key for their account. Let&amp;#39;s move on to the &amp;quot;reset_password.php&amp;quot; page.&lt;br /&gt;&lt;br /&gt;This page is also going to have a form and some PHP code. First we will post the form which, once again, redirects to itself and then processes using PHP. In this form, we need the user to retype his/her e-mail address, new password, and confirm their new password. We also need to store the value of &amp;quot;?q=&amp;quot; from the URL into a hidden section of the form so we can carry it over into processing in post data.&lt;br /&gt;&lt;br /&gt;reset_password.php&lt;br /&gt;&lt;!--c1--&gt;&lt;div class='codetop'&gt;CODE&lt;/div&gt;&lt;div class='codemain'&gt;&lt;!--ec1--&gt;&lt;br /&gt;&amp;#60;form action=&amp;#34;&amp;#60;?php echo &amp;#036;_SERVER&amp;#91;&amp;#34;PHP_SELF&amp;#34;&amp;#93;; ?&amp;#62;&amp;#34; method=&amp;#34;post&amp;#34;&amp;#62;&lt;br /&gt;E-mail Address&amp;#58; &amp;#60;input type=&amp;#34;text&amp;#34; name=&amp;#34;email&amp;#34; size=&amp;#34;20&amp;#34; /&amp;#62;&amp;#60;br /&amp;#62;&lt;br /&gt;New Password&amp;#58; &amp;#60;input type=&amp;#34;password&amp;#34; name=&amp;#34;password&amp;#34; size=&amp;#34;20&amp;#34; /&amp;#62;&amp;#60;br /&amp;#62;&lt;br /&gt;Confirm Password&amp;#58; &amp;#60;input type=&amp;#34;password&amp;#34; name=&amp;#34;confirmpassword&amp;#34; size=&amp;#34;20&amp;#34; /&amp;#62;&amp;#60;br /&amp;#62;&lt;br /&gt;&amp;#60;input type=&amp;#34;hidden&amp;#34; name=&amp;#34;q&amp;#34; value=&amp;#34;&amp;#60;?php echo &amp;#036;_GET&amp;#91;&amp;#34;q&amp;#34;&amp;#93;; ?&amp;#62;&amp;#34; /&amp;#62;&amp;#60;input type=&amp;#34;submit&amp;#34; name=&amp;#34;ResetPasswordForm&amp;#34; value=&amp;#34; Reset Password &amp;#34; /&amp;#62;&lt;br /&gt;&amp;#60;/form&amp;#62;&lt;br /&gt;&lt;!--c2--&gt;&lt;/div&gt;&lt;!--ec2--&gt;&lt;br /&gt;&lt;br /&gt;Now that we have the form for the page, let&amp;#39;s move onto the PHP section.&lt;br /&gt;&lt;br /&gt;reset_password.php&lt;br /&gt;&lt;!--c1--&gt;&lt;div class='codetop'&gt;CODE&lt;/div&gt;&lt;div class='codemain'&gt;&lt;!--ec1--&gt;&lt;br /&gt;&amp;#60;?php&lt;br /&gt;&lt;br /&gt;// Connect to MySQL&lt;br /&gt;&amp;#036;c = mysql_connect&amp;#40;&amp;#34;localhost&amp;#34;, &amp;#34;root&amp;#34;, &amp;#34;&amp;#34;&amp;#41;;&lt;br /&gt;mysql_select_db&amp;#40;&amp;#34;main&amp;#34;, &amp;#036;c&amp;#41;;&lt;br /&gt;&lt;br /&gt;// Was the form submitted?&lt;br /&gt;if &amp;#40;&amp;#036;_POST&amp;#91;&amp;#34;ResetPasswordForm&amp;#34;&amp;#93;&amp;#41;&lt;br /&gt;{&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;// Gather the post data&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;#036;email = mysql_real_escape_string&amp;#40;&amp;#036;_POST&amp;#91;&amp;#34;email&amp;#34;&amp;#93;&amp;#41;;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;#036;password = md5&amp;#40;mysql_real_escape_string&amp;#40;&amp;#036;_POST&amp;#91;&amp;#34;password&amp;#34;&amp;#93;&amp;#41;&amp;#41;;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;#036;confirmpassword = md5&amp;#40;mysql_real_escape_string&amp;#40;&amp;#036;_POST&amp;#91;&amp;#34;confirmpassword&amp;#34;&amp;#93;&amp;#41;&amp;#41;;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;#036;q = &amp;#036;_POST&amp;#91;&amp;#34;q&amp;#34;&amp;#93;;&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;// Use the same salt from the forgot_password.php file&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;#036;salt = &amp;#34;PiuwrO1#O0rl@+luH1&amp;#33;froe*l?8oEb&amp;#33;iu&amp;#41;_1Xaspi*&amp;#40;sw&amp;#40;^&amp;amp;.laBr~u3i&amp;#33;c?es-l651&amp;#34;;&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;// Generate the reset key&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;#036;resetkey = md5&amp;#40;&amp;#036;salt . &amp;#036;email&amp;#41;;&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;// Does the new reset key match the old one?&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;if &amp;#40;&amp;#036;resetkey == &amp;#036;q&amp;#41;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;if &amp;#40;&amp;#036;password == &amp;#036;confirmpassword&amp;#41;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;// Update the user&amp;#39;s password&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;mysql_query&amp;#40;&amp;#34;UPDATE &amp;#96;users&amp;#96; SET &amp;#96;password&amp;#96; = &amp;#39;&amp;#036;password&amp;#39; WHERE &amp;#96;email&amp;#96; = &amp;#39;&amp;#036;email&amp;#39;&amp;#34;&amp;#41;;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;echo &amp;#34;Your password has been successfully reset.&amp;#34;;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;else&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;echo &amp;#34;Your password&amp;#39;s do not match.&amp;#34;;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;else&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;echo &amp;#34;Your password reset key is invalid.&amp;#34;;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;?&amp;#62;&lt;br /&gt;&lt;!--c2--&gt;&lt;/div&gt;&lt;!--ec2--&gt;&lt;br /&gt;&lt;br /&gt;Again, a lot is going on here. So let&amp;#39;s break it down line by line.&lt;br /&gt;&lt;br /&gt;&lt;!--c1--&gt;&lt;div class='codetop'&gt;CODE&lt;/div&gt;&lt;div class='codemain'&gt;&lt;!--ec1--&gt;&lt;br /&gt;&amp;#60;?php&lt;br /&gt;&lt;br /&gt;// Connect to MySQL&lt;br /&gt;&amp;#036;c = mysql_connect&amp;#40;&amp;#34;localhost&amp;#34;, &amp;#34;root&amp;#34;, &amp;#34;&amp;#34;&amp;#41;;&lt;br /&gt;mysql_select_db&amp;#40;&amp;#34;main&amp;#34;, &amp;#036;c&amp;#41;;&lt;br /&gt;&lt;!--c2--&gt;&lt;/div&gt;&lt;!--ec2--&gt;&lt;br /&gt;&lt;br /&gt;Connecting to MySQL, again. Nothing new here.&lt;br /&gt;&lt;br /&gt;&lt;!--c1--&gt;&lt;div class='codetop'&gt;CODE&lt;/div&gt;&lt;div class='codemain'&gt;&lt;!--ec1--&gt;&lt;br /&gt;// Was the form submitted?&lt;br /&gt;if &amp;#40;&amp;#036;_POST&amp;#91;&amp;#34;ResetPasswordForm&amp;#34;&amp;#93;&amp;#41;&lt;br /&gt;{&lt;br /&gt;&lt;!--c2--&gt;&lt;/div&gt;&lt;!--ec2--&gt;&lt;br /&gt;&lt;br /&gt;Checking to see if the form was submitted.&lt;br /&gt;&lt;br /&gt;&lt;!--c1--&gt;&lt;div class='codetop'&gt;CODE&lt;/div&gt;&lt;div class='codemain'&gt;&lt;!--ec1--&gt;&lt;br /&gt;// Gather the post data&lt;br /&gt;&amp;#036;email = mysql_real_escape_string&amp;#40;&amp;#036;_POST&amp;#91;&amp;#34;email&amp;#34;&amp;#93;&amp;#41;;&lt;br /&gt;&amp;#036;password = md5&amp;#40;mysql_real_escape_string&amp;#40;&amp;#036;_POST&amp;#91;&amp;#34;password&amp;#34;&amp;#93;&amp;#41;&amp;#41;;&lt;br /&gt;&amp;#036;confirmpassword = md5&amp;#40;mysql_real_escape_string&amp;#40;&amp;#036;_POST&amp;#91;&amp;#34;confirmpassword&amp;#34;&amp;#93;&amp;#41;&amp;#41;;&lt;br /&gt;&amp;#036;q = &amp;#036;_POST&amp;#91;&amp;#34;q&amp;#34;&amp;#93;;&lt;br /&gt;&lt;!--c2--&gt;&lt;/div&gt;&lt;!--ec2--&gt;&lt;br /&gt;&lt;br /&gt;This is gathering all of the post data submitted from the form and storing each value into a variable. You may notice the use of mysql_real_escape_string(). Again, we are using this to protect our database from SQL Injection. &amp;#036;q doesn&amp;#39;t need to be escaped because we aren&amp;#39;t going to be checking it with the database. Also, you may notice use of md5() on the password&amp;#39;s. This is because I assume this is the hashing you are using on your passwords. Change it if needed.&lt;br /&gt;&lt;br /&gt;&lt;!--c1--&gt;&lt;div class='codetop'&gt;CODE&lt;/div&gt;&lt;div class='codemain'&gt;&lt;!--ec1--&gt;&lt;br /&gt;// Use the same salt from the forgot_password.php file&lt;br /&gt;&amp;#036;salt = &amp;#34;PiuwrO1#O0rl@+luH1&amp;#33;froe*l?8oEb&amp;#33;iu&amp;#41;_1Xaspi*&amp;#40;sw&amp;#40;^&amp;amp;.laBr~u3i&amp;#33;c?es-l651&amp;#34;;&lt;br /&gt;&lt;!--c2--&gt;&lt;/div&gt;&lt;!--ec2--&gt;&lt;br /&gt;&lt;br /&gt;Here we are, once again, creating the salt. Make sure this is the &lt;b&gt;EXACT&lt;/b&gt; same salt you used from the forgot_password.php file or the system won&amp;#39;t work.&lt;br /&gt;&lt;br /&gt;&lt;!--c1--&gt;&lt;div class='codetop'&gt;CODE&lt;/div&gt;&lt;div class='codemain'&gt;&lt;!--ec1--&gt;&lt;br /&gt;// Generate the reset key&lt;br /&gt;&amp;#036;resetkey = md5&amp;#40;&amp;#036;salt . &amp;#036;email&amp;#41;;&lt;br /&gt;&lt;!--c2--&gt;&lt;/div&gt;&lt;!--ec2--&gt;&lt;br /&gt;&lt;br /&gt;As we did in the forgot_password.php file, we are combining the salt and the user&amp;#39;s inputted e-mail and then hashing it with md5(). We are storing it into a variable called &amp;#036;resetkey this time.&lt;br /&gt;&lt;br /&gt;&lt;!--c1--&gt;&lt;div class='codetop'&gt;CODE&lt;/div&gt;&lt;div class='codemain'&gt;&lt;!--ec1--&gt;&lt;br /&gt;// Does the new reset key match the old one?&lt;br /&gt;if &amp;#40;&amp;#036;resetkey == &amp;#036;q&amp;#41;&lt;br /&gt;{&lt;br /&gt;&lt;!--c2--&gt;&lt;/div&gt;&lt;!--ec2--&gt;&lt;br /&gt;&lt;br /&gt;This is the major check. Since we combined the same salt with the same e-mail and hashed it the same way, both &amp;#036;resetkey and &amp;#036;q will be the same. If they aren&amp;#39;t the same, the user either inputted the wrong e-mail address or it&amp;#39;s a hacker trying to steal their account.&lt;br /&gt;&lt;br /&gt;&lt;!--c1--&gt;&lt;div class='codetop'&gt;CODE&lt;/div&gt;&lt;div class='codemain'&gt;&lt;!--ec1--&gt;&lt;br /&gt;if &amp;#40;&amp;#036;password == &amp;#036;confirmpassword&amp;#41;&lt;br /&gt;{&lt;br /&gt;&lt;!--c2--&gt;&lt;/div&gt;&lt;!--ec2--&gt;&lt;br /&gt;&lt;br /&gt;This is making sure both the password and confirmed password match.&lt;br /&gt;&lt;br /&gt;&lt;!--c1--&gt;&lt;div class='codetop'&gt;CODE&lt;/div&gt;&lt;div class='codemain'&gt;&lt;!--ec1--&gt;&lt;br /&gt;// Update the user&amp;#39;s password&lt;br /&gt;mysql_query&amp;#40;&amp;#34;UPDATE &amp;#96;users&amp;#96; SET &amp;#96;password&amp;#96; = &amp;#39;&amp;#036;password&amp;#39; WHERE &amp;#96;email&amp;#96; = &amp;#39;&amp;#036;email&amp;#39;&amp;#34;&amp;#41;;&lt;br /&gt;echo &amp;#34;Your password has been successfully reset.&amp;#34;;&lt;br /&gt;&lt;!--c2--&gt;&lt;/div&gt;&lt;!--ec2--&gt;&lt;br /&gt;&lt;br /&gt;Here we are simply running a mysql_query() to update the user&amp;#39;s password and set it to the new one where their e-mail equals the one submitted. Afterward, we are echoing out that it has been successful. Again, you may need to change the table &amp;#96;users&amp;#96; and the fields depending on your database.&lt;br /&gt;&lt;br /&gt;&lt;!--c1--&gt;&lt;div class='codetop'&gt;CODE&lt;/div&gt;&lt;div class='codemain'&gt;&lt;!--ec1--&gt;&lt;br /&gt;}&lt;br /&gt;else&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;echo &amp;#34;Your password&amp;#39;s do not match.&amp;#34;;&lt;br /&gt;}&lt;br /&gt;else&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;echo &amp;#34;Your password reset key is invalid.&amp;#34;;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;?&amp;#62;&lt;br /&gt;&lt;!--c2--&gt;&lt;/div&gt;&lt;!--ec2--&gt;&lt;br /&gt;&lt;br /&gt;This is all the clean up and finalizing code. We are running else statements on previous if&amp;#39;s. The first one is for whether or not the password and confirmed password matched. If not, tell them it didn&amp;#39;t. The second is for the check determining whether or not the new recovery key matched the old one. The final curly braces closes the if statement which checked to see if the form was actually submitted.&lt;br /&gt;&lt;br /&gt;&lt;!--coloro:#CC0000--&gt;&lt;span style=&quot;color:#CC0000&quot;&gt;&lt;!--/coloro--&gt;CONGRATULATIONS&amp;#33;&lt;!--colorc--&gt;&lt;/span&gt;&lt;!--/colorc--&gt;&lt;br /&gt;&lt;br /&gt;If you have made it this far, your password reset system is complete. I hope my tutorial has helped you learn and understand new concepts. Go out and enjoy the wonderful world of PHP now&amp;#33;</description>
			<pubDate>Tue, 20 Oct 2009 18:07:22 -0500</pubDate>
			<category>PHP Tutorials</category>
			<author>Master Jake</author>
         </item>
         <item>
            <link>http://forums.dreamincode.net/showtopic133233.htm</link>
            <title>Search Engine [Basic] in PHP Tutorials</title>
            <description>Hello. Today you are going to be learning how to create a very simple search engine system which you can implement into your own website. Keep in mind that this search engine tutorial is meant to teach only the fundamental basics.&lt;br /&gt;&lt;br /&gt;If you are implementing this search engine into a professional or commercial site, be sure to update it with &lt;b&gt;paging&lt;/b&gt; so that 20 billion results aren&amp;#39;t displayed on one page. Let&amp;#39;s get started.&lt;br /&gt;&lt;br /&gt;&lt;b&gt;&lt;u&gt;1: The Database&lt;/u&gt;&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;In order for this search engine to operate properly, we need to store information into a database which we will scan for later. You can use this to search pretty much any field in a table; however, for this example we will be using a simple &amp;quot;blog&amp;quot; type section.&lt;br /&gt;&lt;br /&gt;Our database will be very simple, and looks like this:&lt;br /&gt;&lt;!--c1--&gt;&lt;div class='codetop'&gt;CODE&lt;/div&gt;&lt;div class='codemain'&gt;&lt;!--ec1--&gt;&lt;br /&gt;TABLE&amp;#58; blog_entries&lt;br /&gt;&lt;br /&gt;id &amp;#40;primary key; auto increment&amp;#41; - int&amp;#40;11&amp;#41;&lt;br /&gt;blogbody - text&lt;br /&gt;&lt;!--c2--&gt;&lt;/div&gt;&lt;!--ec2--&gt;&lt;br /&gt;&lt;br /&gt;Obviously, a real blog_entries table would contain MUCH more data than this;however, like I said, I want to make this as simple and easily understandable as possible.&lt;br /&gt;&lt;br /&gt;Now, we will assume that there are already quite a few entries into this table for which we may search.&lt;br /&gt;&lt;br /&gt;First, we need to create an HTML form field using GET as the method so that our user&amp;#39;s can search the database.&lt;br /&gt;&lt;br /&gt;File: test.html&lt;br /&gt;&lt;!--c1--&gt;&lt;div class='codetop'&gt;CODE&lt;/div&gt;&lt;div class='codemain'&gt;&lt;!--ec1--&gt;&lt;br /&gt;&amp;#60;form action=&amp;#34;search.php&amp;#34; method=&amp;#34;get&amp;#34;&amp;#62;&lt;br /&gt;&amp;#60;input type=&amp;#34;text&amp;#34; name=&amp;#34;q&amp;#34; size=&amp;#34;20&amp;#34; /&amp;#62; &amp;#60;input type=&amp;#34;submit&amp;#34; value=&amp;#34; Search &amp;#34; /&amp;#62;&lt;br /&gt;&amp;#60;/form&amp;#62;&lt;br /&gt;&lt;!--c2--&gt;&lt;/div&gt;&lt;!--ec2--&gt;&lt;br /&gt;&lt;br /&gt;I didn&amp;#39;t name the input for the submit button because it&amp;#39;s not really needed for this example.&lt;br /&gt;&lt;br /&gt;Now, there are a few things you may notice. First of all, this form directs the data to the page &amp;quot;search.php&amp;quot; using the &amp;quot;get&amp;quot; method. This means that if the user type&amp;#39;s in say &amp;quot;Hello World&amp;quot; in the input textbox and press&amp;#39;s &amp;quot;Search&amp;quot;, the url will look like this:&lt;br /&gt;&lt;br /&gt;&lt;!--c1--&gt;&lt;div class='codetop'&gt;CODE&lt;/div&gt;&lt;div class='codemain'&gt;&lt;!--ec1--&gt;&lt;br /&gt;search.php?q=Hello+World&lt;br /&gt;&lt;!--c2--&gt;&lt;/div&gt;&lt;!--ec2--&gt;&lt;br /&gt;&lt;br /&gt;The nifty thing about using the get method is that it will automatically url encode the form data and then url decode it when we use php&amp;#39;s &amp;#036;_GET to retrieve it.&lt;br /&gt;&lt;br /&gt;Speaking of PHP, let&amp;#39;s get on with the &amp;quot;search.php&amp;quot; page which this form directs to.&lt;br /&gt;&lt;br /&gt;First we need to connect to MySQL so that we can use mysql_query and etc.&lt;br /&gt;&lt;br /&gt;&lt;!--c1--&gt;&lt;div class='codetop'&gt;CODE&lt;/div&gt;&lt;div class='codemain'&gt;&lt;!--ec1--&gt;&lt;br /&gt;&amp;#60;?php&lt;br /&gt;&lt;br /&gt;&amp;#036;c = mysql_connect&amp;#40;&amp;#34;localhost&amp;#34;, &amp;#34;root&amp;#34;, &amp;#34;&amp;#34;&amp;#41;;&lt;br /&gt;mysql_select_db&amp;#40;&amp;#34;my_database&amp;#34;, &amp;#036;c&amp;#41;;&lt;br /&gt;&lt;!--c2--&gt;&lt;/div&gt;&lt;!--ec2--&gt;&lt;br /&gt;&lt;br /&gt;Of course, the username, password, host, and database name will change depending on your MySQL information. Now that we are connected, let&amp;#39;s grab the value of &amp;quot;q&amp;quot; in the URL.&lt;br /&gt;&lt;br /&gt;&lt;!--c1--&gt;&lt;div class='codetop'&gt;CODE&lt;/div&gt;&lt;div class='codemain'&gt;&lt;!--ec1--&gt;&lt;br /&gt;&amp;#036;q = mysql_real_escape_string&amp;#40;&amp;#036;_GET&amp;#91;&amp;#34;q&amp;#34;&amp;#93;&amp;#41;;&lt;br /&gt;&amp;#036;newq = strtoupper&amp;#40;&amp;#036;q&amp;#41;;&lt;br /&gt;&lt;!--c2--&gt;&lt;/div&gt;&lt;!--ec2--&gt;&lt;br /&gt;&lt;br /&gt;We use mysql_real_escape_string to escape harmful characters which can be used to SQL Inject the database. We also created a second variable called &amp;quot;&amp;#036;newq&amp;quot; which is simply an all uppercase version of the search query. This is that we may run a case insensitive search.&lt;br /&gt;&lt;br /&gt; Now that we have the information in which the user submitted (and keep in mind that &amp;#036;_GET automatically url decoded the data), we may run the main search query.&lt;br /&gt;&lt;br /&gt;&lt;!--c1--&gt;&lt;div class='codetop'&gt;CODE&lt;/div&gt;&lt;div class='codemain'&gt;&lt;!--ec1--&gt;&lt;br /&gt;&amp;#036;searchQuery = mysql_query&amp;#40;&amp;#34;SELECT * FROM &amp;#96;blog_entries&amp;#96; WHERE UPPER&amp;#40;&amp;#96;blogbody&amp;#96;&amp;#41; LIKE &amp;#39;%&amp;#036;newq%&amp;#39; ORDER BY &amp;#96;id&amp;#96; DESC LIMIT 10&amp;#34;&amp;#41;;&lt;br /&gt;&lt;!--c2--&gt;&lt;/div&gt;&lt;!--ec2--&gt;&lt;br /&gt;&lt;br /&gt;Now, a lot is going on in this query. I hope that if you are reading this tutorial you already know a little about MySQL. First of all, we are selecting every field from the table &amp;quot;blog_entries&amp;quot; (which I showed above). We are selecting only the fields in which the value of &amp;quot;blogbody&amp;quot; contains the string &amp;quot;&amp;#036;newq.&amp;quot; We use MySQL&amp;#39;s UPPER() around the blogbody so that, once again, the search query is case insensitive. This tests a full uppercase version of the &amp;quot;blogbody&amp;quot; field with a full uppercase version of the search query. All case insensitive.&lt;br /&gt;&lt;br /&gt;You may notice the %%&amp;#39;s around &amp;#036;newq. Basically they are wildcards which mean &amp;quot;anything in this spot.&amp;quot; This means that if the user searches:&lt;br /&gt;&lt;br /&gt;&amp;#39;o&amp;#39;&lt;br /&gt;&lt;br /&gt;and the word &amp;quot;dog&amp;quot; is in &amp;quot;blogbody&amp;quot;, it will return that result.&lt;br /&gt;&lt;br /&gt;%o% = anything-o-anything&lt;br /&gt;&lt;br /&gt;dog would match in that case. This is used for better search results. In case the user searches:&lt;br /&gt;&lt;br /&gt;tut&lt;br /&gt;&lt;br /&gt;instead of &amp;quot;tutorial&amp;quot;, it will still match.&lt;br /&gt;&lt;br /&gt;You may also notice that we are ordering these by the id descending. Since the id auto increments with each new entry, the highest id is going to be the newest entry. Descending means highest to lowest. Basically we are ordering them from newest to oldest. You can also do this with a date timestamp, but we won&amp;#39;t get into that right now.&lt;br /&gt;&lt;br /&gt;Also, we are limiting this search to a maximum of 10 results. This is so the page doesn&amp;#39;t get cluttered with too many search results. If you want unlimited results, I suggest creating a paging system and adding it to your search system so that it displays say 10 search results per page.&lt;br /&gt;&lt;br /&gt;Now that we have the value of the search query tested with the database, we need to print the retrieved values (providing there are any). We can do this by using a while() loop.&lt;br /&gt;&lt;br /&gt;&lt;!--c1--&gt;&lt;div class='codetop'&gt;CODE&lt;/div&gt;&lt;div class='codemain'&gt;&lt;!--ec1--&gt;&lt;br /&gt;while &amp;#40;&amp;#036;row = mysql_fetch_assoc&amp;#40;&amp;#036;searchQuery&amp;#41;&amp;#41;&lt;br /&gt;{&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;echo &amp;#34;Blog Entry #&amp;#34; . &amp;#036;row&amp;#91;&amp;#34;id&amp;#34;&amp;#93; . &amp;#34;&amp;#60;br /&amp;#62;&amp;#60;br /&amp;#62;&amp;#34; . stripslashes&amp;#40;&amp;#036;row&amp;#91;&amp;#34;blogbody&amp;#34;&amp;#93;&amp;#41; . &amp;#34;&amp;#60;hr /&amp;#62;&amp;#34;;&lt;br /&gt;}&lt;br /&gt;&lt;!--c2--&gt;&lt;/div&gt;&lt;!--ec2--&gt;&lt;br /&gt;&lt;br /&gt;A few things are going on here. We are assigning the variable &amp;quot;&amp;#036;row&amp;quot; to each row of data retrieved from the search query. Each time the while loop increments, one new row is retrieved and we can print data associated with that row. mysql_fetch_assoc() is simply retrieving the rows and storing them in an associative array of &amp;quot;&amp;#036;row.&amp;quot;&lt;br /&gt;&lt;br /&gt;These values can be accessed with the variable name, brackets, and the field name in quotes:&lt;br /&gt;&lt;br /&gt;&lt;!--c1--&gt;&lt;div class='codetop'&gt;CODE&lt;/div&gt;&lt;div class='codemain'&gt;&lt;!--ec1--&gt;&lt;br /&gt;&amp;#036;row&amp;#91;&amp;#34;blogbody&amp;#34;&amp;#93;; // returns the blogbody field&lt;br /&gt;&lt;!--c2--&gt;&lt;/div&gt;&lt;!--ec2--&gt;&lt;br /&gt;&lt;br /&gt;The rest is pretty self explanatory. We are echoing out the id of each blog entry that was successfully matched with the search query, and then echoing out the actually blogbody of that field itself. You may notice &amp;quot;stripslashes()&amp;quot; around the blogbody. I assumed that whoever was making the blog system used &amp;quot;mysql_real_escape_string()&amp;quot; to escape the blogbody before entry into the database.&lt;br /&gt;&lt;br /&gt;This make&amp;#39;s all single and double quotes (and a few other characters) have a backslash before them. E.g. &amp;quot; becomes &amp;#092;&amp;quot;. We need to strip those slashes when echoing them out so that &amp;#092;&amp;quot; returns back to &amp;quot;, etc.&lt;br /&gt;&lt;br /&gt;Well, that&amp;#39;s pretty much it. I hope you found this tutorial helpful, and I hope that it wasn&amp;#39;t too confusing. Here is the final code put together:&lt;br /&gt;&lt;br /&gt;&lt;!--c1--&gt;&lt;div class='codetop'&gt;CODE&lt;/div&gt;&lt;div class='codemain'&gt;&lt;!--ec1--&gt;&lt;br /&gt;&amp;#60;?php&lt;br /&gt;&lt;br /&gt;// Connect to MySQL&lt;br /&gt;&amp;#036;c = mysql_connect&amp;#40;&amp;#34;localhost&amp;#34;, &amp;#34;root&amp;#34;, &amp;#34;&amp;#34;&amp;#41;;&lt;br /&gt;mysql_select_db&amp;#40;&amp;#34;my_database&amp;#34;, &amp;#036;c&amp;#41;;&lt;br /&gt;&lt;br /&gt;// Retrieve the Search String&lt;br /&gt;&amp;#036;q = mysql_real_escape_string&amp;#40;&amp;#036;_GET&amp;#91;&amp;#34;q&amp;#34;&amp;#93;&amp;#41;;&lt;br /&gt;&amp;#036;newq = strtoupper&amp;#40;&amp;#036;q&amp;#41;;&lt;br /&gt;&lt;br /&gt;// Run the Search Query&lt;br /&gt;&amp;#036;searchQuery = mysql_query&amp;#40;&amp;#34;SELECT * FROM &amp;#96;blog_entries&amp;#96; WHERE UPPER&amp;#40;&amp;#96;blogbody&amp;#96;&amp;#41; LIKE &amp;#39;%&amp;#036;newq%&amp;#39; ORDER BY &amp;#96;id&amp;#96; DESC LIMIT 10&amp;#34;&amp;#41;;&lt;br /&gt;&lt;br /&gt;// Display Results Based on the Retrieved Data&lt;br /&gt;while &amp;#40;&amp;#036;row = mysql_fetch_assoc&amp;#40;&amp;#036;searchQuery&amp;#41;&amp;#41;&lt;br /&gt;{&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;echo &amp;#34;Blog Entry #&amp;#34; . &amp;#036;row&amp;#91;&amp;#34;id&amp;#34;&amp;#93; . &amp;#34;&amp;#60;br /&amp;#62;&amp;#60;br /&amp;#62;&amp;#34; . stripslashes&amp;#40;&amp;#036;row&amp;#91;&amp;#34;blogbody&amp;#34;&amp;#93;&amp;#41; . &amp;#34;&amp;#60;hr /&amp;#62;&amp;#34;;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;?&amp;#62;&lt;br /&gt;&lt;!--c2--&gt;&lt;/div&gt;&lt;!--ec2--&gt;&lt;br /&gt;&lt;br /&gt;If you are wondering why I didn&amp;#39;t just use &amp;quot;strtoupper&amp;quot; on the &amp;quot;&amp;#036;q&amp;quot; value itself, I wanted it separate so that the original search string was saved. This way, if you wanted to print out what they searched, you could:&lt;br /&gt;&lt;br /&gt;&lt;!--c1--&gt;&lt;div class='codetop'&gt;CODE&lt;/div&gt;&lt;div class='codemain'&gt;&lt;!--ec1--&gt;&lt;br /&gt;&amp;#60;?php&lt;br /&gt;&lt;br /&gt;echo &amp;#34;You searched for &amp;#60;b&amp;#62;&amp;#34; . stripslashes&amp;#40;&amp;#036;q&amp;#41; . &amp;#34;&amp;#60;/b&amp;#62;&amp;#34;;&lt;br /&gt;&lt;br /&gt;?&amp;#62;&lt;br /&gt;&lt;!--c2--&gt;&lt;/div&gt;&lt;!--ec2--&gt;</description>
			<pubDate>Tue, 20 Oct 2009 11:48:32 -0500</pubDate>
			<category>PHP Tutorials</category>
			<author>Master Jake</author>
         </item>
         <item>
            <link>http://forums.dreamincode.net/showtopic132768.htm</link>
            <title>Installing FLTK for Beginners in C++ Tutorials</title>
            <description>Hi, This tutorial is for installing FLTK in your Linux Operating System. i am using Ubuntu jaunty 9.04. You can use this guide to install it in other operating system.&lt;br /&gt;&lt;br /&gt;Before installing FLTK in ubuntu or any other Linux distros you need few packages. If you try to install it without these pre-build packages, it will produce an error. &lt;br /&gt;&lt;br /&gt;1. You need g++-x.x ( x.x is the version number 3.0+, preferably 4.3 )&lt;br /&gt;   &lt;br /&gt;             You can install this using &amp;#39;build-essentials&amp;#39;&lt;br /&gt;&lt;!--c1--&gt;&lt;div class='codetop'&gt;CODE&lt;/div&gt;&lt;div class='codemain'&gt;&lt;!--ec1--&gt;ubuntu &amp;#58; sudo apt-get install build-essentials&lt;!--c2--&gt;&lt;/div&gt;&lt;!--ec2--&gt;&lt;br /&gt;These essential packages comes with CD rom. All you have to do is add the CD-ROM to software sources.&lt;br /&gt;&lt;br /&gt;2. installing autoconf and automake&lt;br /&gt;&lt;br /&gt;&lt;!--c1--&gt;&lt;div class='codetop'&gt;CODE&lt;/div&gt;&lt;div class='codemain'&gt;&lt;!--ec1--&gt;sudo apt-get install autoconf automake&lt;!--c2--&gt;&lt;/div&gt;&lt;!--ec2--&gt;&lt;br /&gt;&lt;br /&gt;3. installing xorg-dev packages and libglut3-dev&lt;br /&gt;&lt;br /&gt;&lt;!--c1--&gt;&lt;div class='codetop'&gt;CODE&lt;/div&gt;&lt;div class='codemain'&gt;&lt;!--ec1--&gt;sudo apt-get install xorg-dev libglut3-dev&lt;!--c2--&gt;&lt;/div&gt;&lt;!--ec2--&gt;&lt;br /&gt;&lt;br /&gt;&lt;u&gt;So the files that needed to be installed are:&lt;/u&gt;&lt;br /&gt;1. G++&lt;br /&gt;2. autoconf&lt;br /&gt;3. automake&lt;br /&gt;4. xorg-dev&lt;br /&gt;5. libglut3-dev&lt;br /&gt;&lt;br /&gt;In whatever linux distro you are using, use the package manager to install all these. &lt;!--coloro:#FF0000--&gt;&lt;span style=&quot;color:#FF0000&quot;&gt;&lt;!--/coloro--&gt;These will also install other dependency files.&lt;!--colorc--&gt;&lt;/span&gt;&lt;!--/colorc--&gt;&lt;br /&gt;&lt;b&gt;&lt;br /&gt;Installing FLTK&lt;br /&gt;&lt;/b&gt;&lt;br /&gt;1. donwload FLTK from their website &lt;a href=&quot;http://www.fltk.org&quot; target=&quot;_blank&quot;&gt;http://www.fltk.org&lt;/a&gt;&lt;br /&gt;2. unrar the package.&lt;br /&gt;3. navigate to the extracted folder in terminal&lt;br /&gt;4. run the following commands in terminal&lt;br /&gt;    ./configure&lt;br /&gt;    sudo make&lt;br /&gt;    sudo make install&lt;br /&gt;&lt;br /&gt;You are done&amp;#33;.&lt;br /&gt;&lt;b&gt;First fltk Code:&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;&lt;!--c1--&gt;&lt;div class='codetop'&gt;CODE&lt;/div&gt;&lt;div class='codemain'&gt;&lt;!--ec1--&gt;#include &amp;#60;fltk/Window.h&amp;#62;&lt;br /&gt;#include &amp;#60;fltk/Widget.h&amp;#62;&lt;br /&gt;#include &amp;#60;fltk/run.h&amp;#62;&lt;br /&gt;#include &amp;#60;fltk/ask.h&amp;#62;&lt;br /&gt;using namespace fltk;&lt;br /&gt;&lt;br /&gt;void window_callback&amp;#40;Widget* widget, void*&amp;#41; {&lt;br /&gt;&amp;nbsp;&amp;nbsp;if &amp;#40;ask&amp;#40;&amp;#34;Do you really want to exit?&amp;#34;&amp;#41;&amp;#41;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;#40;&amp;#40;Window*&amp;#41;widget&amp;#41;-&amp;#62;hide&amp;#40;&amp;#41;;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;int main&amp;#40;int argc, char **argv&amp;#41; {&lt;br /&gt;&amp;nbsp;&amp;nbsp;Window *window = new Window&amp;#40;300, 180&amp;#41;;&lt;br /&gt;&amp;nbsp;&amp;nbsp;window-&amp;#62;callback&amp;#40;window_callback&amp;#41;;&lt;br /&gt;&amp;nbsp;&amp;nbsp;window-&amp;#62;begin&amp;#40;&amp;#41;;&lt;br /&gt;&amp;nbsp;&amp;nbsp;Widget *box = new Widget&amp;#40;20, 40, 260, 100, &amp;#34;Hello, World&amp;#33;&amp;#34;&amp;#41;;&lt;br /&gt;&amp;nbsp;&amp;nbsp;box-&amp;#62;box&amp;#40;UP_BOX&amp;#41;;&lt;br /&gt;&amp;nbsp;&amp;nbsp;box-&amp;#62;labelfont&amp;#40;HELVETICA_BOLD_ITALIC&amp;#41;;&lt;br /&gt;&amp;nbsp;&amp;nbsp;box-&amp;#62;labelsize&amp;#40;36&amp;#41;;&lt;br /&gt;&amp;nbsp;&amp;nbsp;box-&amp;#62;labeltype&amp;#40;SHADOW_LABEL&amp;#41;;&lt;br /&gt;&amp;nbsp;&amp;nbsp;window-&amp;#62;end&amp;#40;&amp;#41;;&lt;br /&gt;&amp;nbsp;&amp;nbsp;window-&amp;#62;show&amp;#40;argc, argv&amp;#41;;&lt;br /&gt;&amp;nbsp;&amp;nbsp;return run&amp;#40;&amp;#41;;&lt;br /&gt;}&lt;br /&gt;&lt;!--c2--&gt;&lt;/div&gt;&lt;!--ec2--&gt;&lt;br /&gt;I got this code from fltk website. &lt;br /&gt;&lt;br /&gt;&lt;b&gt;Compiling FLTK program:&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;In your terminal &lt;br /&gt; &lt;!--c1--&gt;&lt;div class='codetop'&gt;CODE&lt;/div&gt;&lt;div class='codemain'&gt;&lt;!--ec1--&gt;Syntax&amp;#58; fltk2-config --compile &amp;#60;filename.cpp&amp;#62;&lt;br /&gt; &amp;#036;&amp;#62; fltk2-config --compile Apps.cpp&lt;br /&gt; &amp;#036;&amp;#62; ./Apps&lt;!--c2--&gt;&lt;/div&gt;&lt;!--ec2--&gt;&lt;br /&gt;&lt;br /&gt;Now Fltk is properly installed in you Linux Distro.&lt;img src=&quot;style_emoticons/&lt;#EMO_DIR#&gt;/smile.gif&quot; style=&quot;vertical-align:middle&quot; emoid=&quot;:)&quot; border=&quot;0&quot; alt=&quot;smile.gif&quot; /&gt;</description>
			<pubDate>Sun, 18 Oct 2009 10:11:15 -0500</pubDate>
			<category>C++ Tutorials</category>
			<author>balasurfs</author>
         </item>
         <item>
            <link>http://forums.dreamincode.net/showtopic132558.htm</link>
            <title>C Part V: String in C++ Tutorials</title>
            <description>&lt;!--sizeo:3--&gt;&lt;span style=&quot;font-size:12pt;line-height:100%&quot;&gt;&lt;!--/sizeo--&gt;&lt;b&gt;C Part V: String&lt;/b&gt;&lt;!--sizec--&gt;&lt;/span&gt;&lt;!--/sizec--&gt;&lt;br /&gt;We have another data type in C its called string, a string is used to store words or text for example: someone&amp;#8217;s name or address or some random piece of text, anything from ASCII character set, these are called string.&lt;br /&gt;Basically string is array of characters; let&amp;#8217;s have a look to some example than we should know clearly about what we are talking.&lt;br /&gt;&lt;b&gt;Example:&lt;/b&gt;&lt;br /&gt;&lt;b&gt;&lt;!--coloro:#000099--&gt;&lt;span style=&quot;color:#000099&quot;&gt;&lt;!--/coloro--&gt;char&lt;!--colorc--&gt;&lt;/span&gt;&lt;!--/colorc--&gt;&lt;/b&gt; Letter = &lt;!--coloro:#FF0000--&gt;&lt;span style=&quot;color:#FF0000&quot;&gt;&lt;!--/coloro--&gt;&amp;#8216;N&amp;#8217;&lt;!--colorc--&gt;&lt;/span&gt;&lt;!--/colorc--&gt;; 	// this is a character.&lt;br /&gt;&lt;b&gt;&lt;!--coloro:#000099--&gt;&lt;span style=&quot;color:#000099&quot;&gt;&lt;!--/coloro--&gt;char&lt;!--colorc--&gt;&lt;/span&gt;&lt;!--/colorc--&gt;&lt;/b&gt; Name[6] = &lt;!--coloro:#CC0000--&gt;&lt;span style=&quot;color:#CC0000&quot;&gt;&lt;!--/coloro--&gt;&amp;#8220;String&amp;#8221;&lt;!--colorc--&gt;&lt;/span&gt;&lt;!--/colorc--&gt;;	// this is a string, a collection of characters &amp;#8216;S&amp;#8217;, &amp;#8216;t&amp;#8217;, &amp;#8216;r&amp;#8217;, &amp;#8216;I&amp;#8217;, &amp;#8216;n&amp;#8217;, &amp;#8216;g&amp;#8217;.&lt;br /&gt;or&lt;br /&gt;&lt;!--coloro:#000099--&gt;&lt;span style=&quot;color:#000099&quot;&gt;&lt;!--/coloro--&gt;char&lt;!--colorc--&gt;&lt;/span&gt;&lt;!--/colorc--&gt; &lt;b&gt;Name&lt;/b&gt;[20]; &lt;!--coloro:#009900--&gt;&lt;span style=&quot;color:#009900&quot;&gt;&lt;!--/coloro--&gt;//&amp;#8220;it will accept 20 or less than 20 characters&amp;#8221;.&lt;!--colorc--&gt;&lt;/span&gt;&lt;!--/colorc--&gt;&lt;br /&gt;&lt;br /&gt;What is a char? Char is a single character like the latter &amp;#8216;P&amp;#8217; or &amp;#8216;M&amp;#8217; or &amp;#8216;s&amp;#8217; etc&amp;#8230; &lt;br /&gt;What is an array? Array is a collection of one or more data types.&lt;br /&gt;Remember that string terminated by a null (0) character like &amp;#8216;&amp;#092;0&amp;#8217;, this is not a digit 0, it&amp;#8217;s actually the very very first character in the list of ASCII code characters, let&amp;#8217;s look to a practical example:&lt;br /&gt;[code=c]main()&lt;br /&gt;{&lt;br /&gt;    char name[20];&lt;br /&gt;    strcpy(name,&amp;quot;Noor Ahmad&amp;quot;);&lt;br /&gt;    printf(&amp;quot;The contencts of name are: %s&amp;#092;n&amp;quot;,name);&lt;br /&gt;&lt;br /&gt;    char fname[20];&lt;br /&gt;    char lname[20];&lt;br /&gt;    char fullname[40];&lt;br /&gt;&lt;br /&gt;    strcpy(fname,&amp;quot;Noor &amp;quot;);&lt;br /&gt;    strcpy(lname,&amp;quot;Ahmad&amp;#092;n&amp;quot;);&lt;br /&gt;    strcpy(fullname,&amp;quot;My full name is &amp;quot;);&lt;br /&gt;&lt;br /&gt;    strcat(fullname,fname);&lt;br /&gt;    strcat(fullname,lname);&lt;br /&gt;&lt;br /&gt;    printf(fullname);&lt;br /&gt;    return 0;&lt;br /&gt;}[/code]&lt;br /&gt; &lt;br /&gt;&lt;b&gt;strcpy()&lt;/b&gt; is a function from the standard C Library, it is copying a string to a variable it (&lt;i&gt;strcpy(name,&lt;!--coloro:#CC0000--&gt;&lt;span style=&quot;color:#CC0000&quot;&gt;&lt;!--/coloro--&gt;&amp;#8221;Noor Ahmad&amp;#8221;&lt;!--colorc--&gt;&lt;/span&gt;&lt;!--/colorc--&gt;)&lt;/i&gt;) it is copying &amp;#8220;Noor Ahmad&amp;#8221; to name variable, and it is always goes from the right to left direction.&lt;br /&gt;How do we know that string assigned to the variable? With using prinft() function.&lt;br /&gt;printf(&lt;!--coloro:#CC0000--&gt;&lt;span style=&quot;color:#CC0000&quot;&gt;&lt;!--/coloro--&gt;&amp;quot;The contencts of name are: %s&amp;#092;n&amp;quot;&lt;!--colorc--&gt;&lt;/span&gt;&lt;!--/colorc--&gt;,name); for int we using %d in printf() function and for string we are using %s to print out it.&lt;br /&gt;&lt;b&gt;strcat&lt;/b&gt;(var1, var2) is also a function from the standard C library and it is using for concatenating tow variables&lt;br /&gt;example: I have 3 variables fname (First Name), lname (Last Name), fullname (Full Name) and I want to assign my First Name in fname and Last Name in lname variables and then I want to concatenate it with fullname.&lt;br /&gt;[code=c]char fname[20];&lt;br /&gt;char lname[20];&lt;br /&gt;char fullname[40];&lt;br /&gt;strcpy(fname,&amp;#8221;Noor &amp;#8220;);&lt;br /&gt;strcpy(lname,&amp;#8221;Ahmad&amp;#092;n&amp;#8221;);&lt;br /&gt;strcpy(fullname,&amp;#8220;My full name is :&amp;#8221;);&lt;br /&gt;strcat(fullname,fname);&lt;br /&gt;strcat(fullname,lname);[/code]&lt;br /&gt;And now content of fullname is &amp;#8220;My full name is Noor Ahmad&amp;#8221;.&lt;br /&gt;&lt;b&gt;strlen&lt;/b&gt;(): with this function we can get the length of a string or contents in a variable&lt;br /&gt;    &lt;b&gt;&lt;!--coloro:#000099--&gt;&lt;span style=&quot;color:#000099&quot;&gt;&lt;!--/coloro--&gt;int&lt;!--colorc--&gt;&lt;/span&gt;&lt;!--/colorc--&gt;&lt;/b&gt; len;&lt;br /&gt;    len = strlen(fullname);&lt;br /&gt;    printf(&lt;!--coloro:#CC0000--&gt;&lt;span style=&quot;color:#CC0000&quot;&gt;&lt;!--/coloro--&gt;&amp;quot;%d&amp;quot;&lt;!--colorc--&gt;&lt;/span&gt;&lt;!--/colorc--&gt;,len);&lt;br /&gt;We also can assign string to a variable with = sign or as a character.&lt;br /&gt;Example:&lt;br /&gt;[code=c]char name[20];&lt;br /&gt;name[0] = &amp;#8216;N&amp;#8217;;&lt;br /&gt;name[1] = &amp;#8216;o&amp;#8217;;&lt;br /&gt;name[2] = &amp;#8216;o&amp;#8217;;&lt;br /&gt;name[3] = &amp;#8216;r&amp;#8217;;&lt;br /&gt;name[4] = &amp;#8216;&amp;#092;0&amp;#8217;; // compile and check without &amp;#092;0 to see what you get.&lt;br /&gt;printf(&amp;#8220;the variable name contain %s&amp;#8221;,name);[/code]&lt;br /&gt;&lt;br /&gt;Thanks for reading &lt;img src=&quot;style_emoticons/&lt;#EMO_DIR#&gt;/smile.gif&quot; style=&quot;vertical-align:middle&quot; emoid=&quot;:)&quot; border=&quot;0&quot; alt=&quot;smile.gif&quot; /&gt;</description>
			<pubDate>Sat, 17 Oct 2009 02:30:40 -0500</pubDate>
			<category>C++ Tutorials</category>
			<author>noorahmad</author>
         </item>
         <item>
            <link>http://forums.dreamincode.net/showtopic132272.htm</link>
            <title>How to recover GRUB after Windows re-install in Linux Tutorials</title>
            <description>Have you ever attempted to reinstall Windows Vista on a Windows/Linux dual boot only to find yourself only booting into windows? I recently did&amp;#33; How frustrating&amp;#33; I finally found out how exactly to go about fixing the problem. If you ever find yourself in this situation, I hope these next steps will get you to where you need to be.&lt;br /&gt;&lt;br /&gt;NOTE: I am using Windows Vista / Kubuntu 9.04 Dual Boot in this example.&lt;br /&gt;&lt;br /&gt;The first thing you need to do is find a Live CD you can boot into. This can be just about any Live CD, but for optimum results use one that shares the same Linux distribution that you use. Boot into this CD and open up a prompt.&lt;br /&gt;&lt;br /&gt;The next thing you have to do is find out what device your Linux partition is running on. This can easily be accomplished using the following commands:&lt;br /&gt;&lt;br /&gt;&lt;!--c1--&gt;&lt;div class='codetop'&gt;CODE&lt;/div&gt;&lt;div class='codemain'&gt;&lt;!--ec1--&gt;fdisk /dev/xxx&lt;!--c2--&gt;&lt;/div&gt;&lt;!--ec2--&gt;&lt;br /&gt;&lt;br /&gt;xxx is equal to any of the following directly from fdisk(8) man pages:&lt;br /&gt;&lt;br /&gt;(/dev/hd[a-h] for IDE disks, /dev/sd[a-p] for SCSI disks, /dev/ed[a-d] for ESDI disks, /dev/xd[ab] for XT disks)&lt;br /&gt;&lt;br /&gt;You will be given a list of options and a prompt to type in your choice. Use the choice &amp;#39;p&amp;#39; to print your partition table and hit &amp;quot;Enter&amp;quot;.&lt;br /&gt;&lt;br /&gt;The table will be printed to the screen in which you can deduce which device your Bootable Linux Partition resides in. Once you figure out the device, make a note of the device string. Mine is: &amp;quot;/dev/sda5&amp;quot;&lt;br /&gt;&lt;br /&gt;NOTE: There will be two or more Linux Partitions on a simple partition table. One is the root partition and the other will most likely be the Linux Swap partition. Make sure you note the correct device.&lt;br /&gt;&lt;br /&gt;Good job&amp;#33; Now you&amp;#39;re ready for the meat of the process.&lt;br /&gt;&lt;br /&gt;You will need to make a new directory to hold the mounted partition that will be your Linux partition. This will make more sense to you as we progress through the rest of the process. The command is:&lt;br /&gt;&lt;br /&gt;&lt;!--c1--&gt;&lt;div class='codetop'&gt;CODE&lt;/div&gt;&lt;div class='codemain'&gt;&lt;!--ec1--&gt;sudo mkdir /mnt/system&lt;!--c2--&gt;&lt;/div&gt;&lt;!--ec2--&gt;&lt;br /&gt;&lt;br /&gt;Next, you need to mount your Linux partition to this new directory so we can access all the files on your Linux Operating System.&lt;br /&gt;&lt;br /&gt;&lt;!--c1--&gt;&lt;div class='codetop'&gt;CODE&lt;/div&gt;&lt;div class='codemain'&gt;&lt;!--ec1--&gt;sudo mount /dev/xxxx /mnt/system&lt;!--c2--&gt;&lt;/div&gt;&lt;!--ec2--&gt;&lt;br /&gt;&lt;br /&gt;In my case, &amp;#39;xxxx&amp;#39; would be &amp;#39;sda5&amp;#39;. You&amp;#39;re Linux partition may be different.&lt;br /&gt;&lt;br /&gt;The next few steps involve &amp;quot;chroot&amp;#39;ing&amp;quot; into this new mounting partition. When you &amp;#39;chroot&amp;#39; to a mounted device, you are literally changing the root directory of the LiveCD system to the root directory of the mounted device. What this does is it allows you to run commands directly on the Linux partition that you specify instead of running the commands on the LiveCD.&lt;br /&gt;&lt;br /&gt;The first thing you need to do is take control of the root user.&lt;br /&gt;&lt;br /&gt;&lt;!--c1--&gt;&lt;div class='codetop'&gt;CODE&lt;/div&gt;&lt;div class='codemain'&gt;&lt;!--ec1--&gt;sudo -i&lt;!--c2--&gt;&lt;/div&gt;&lt;!--ec2--&gt;&lt;br /&gt;&lt;br /&gt;You do this so you can run the &amp;#39;chroot&amp;#39; command.&lt;br /&gt;&lt;br /&gt;Now, you need to bind the /dev tree from the LiveCD file tree to the mounted Linux Partition using the following command:&lt;br /&gt;&lt;br /&gt;&lt;!--c1--&gt;&lt;div class='codetop'&gt;CODE&lt;/div&gt;&lt;div class='codemain'&gt;&lt;!--ec1--&gt;mount -o bind /dev /mnt/system/dev&lt;!--c2--&gt;&lt;/div&gt;&lt;!--ec2--&gt;&lt;br /&gt;&lt;br /&gt;Now, chroot into our partition.&lt;br /&gt;&lt;br /&gt;&lt;!--c1--&gt;&lt;div class='codetop'&gt;CODE&lt;/div&gt;&lt;div class='codemain'&gt;&lt;!--ec1--&gt;chroot /mnt/system&lt;!--c2--&gt;&lt;/div&gt;&lt;!--ec2--&gt;&lt;br /&gt;&lt;br /&gt;Finally&amp;#33; We are inside our Linux partition. We have one more command left. What this command does is reinstall and configure our Grub Bootloader so that we can boot into either Windows or Linux when we restart.&lt;br /&gt;&lt;br /&gt;&lt;!--c1--&gt;&lt;div class='codetop'&gt;CODE&lt;/div&gt;&lt;div class='codemain'&gt;&lt;!--ec1--&gt;grub-install /dev/xxx&lt;!--c2--&gt;&lt;/div&gt;&lt;!--ec2--&gt;&lt;br /&gt;&lt;br /&gt;&amp;#39;xxx&amp;#39; refers to the three character description representing our hard-drive.&lt;br /&gt;&lt;br /&gt;We are finally finished&amp;#33;&lt;br /&gt;&lt;br /&gt;All you have to do is restart&amp;#33; We now have choices when we boot up our computer&amp;#33;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;**Please note: This post is for my own reference. However, if do find yourself stuck with this little situation, I hope this helps you out&amp;#33;**&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;P.S. If you want to change the default choices in the bootloader you can edit the file &amp;quot;/boot/grub/menu.lst&amp;quot;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Thanks for reading&amp;#33;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;--Chris</description>
			<pubDate>Thu, 15 Oct 2009 17:53:42 -0500</pubDate>
			<category>Linux Tutorials</category>
			<author>CBart21</author>
         </item>
         <item>
            <link>http://forums.dreamincode.net/showtopic132258.htm</link>
            <title>Editing MSFlexGrid by users in Visual Basic Tutorials</title>
            <description>FlexGrid Editing by users&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;hello all&lt;br /&gt;i will show you how to make MSFlexGrid editible from the user.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;you will need to add MSFlexGrid Componet do this by clicking on menu Project-&amp;gt;Components-&amp;gt; select Microsoft FlexGrid Control 6.0(SP6) or from same menu click Browse... button and select from Windows&amp;#092;Systrem32&amp;#092;MSFLXGRD.OCX&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Lets Create MSFlexGrid table Drow your Table (MSFGTable is mine FlexGrid)&lt;br /&gt;Put a textbox in your form and make it property Visible - &amp;gt;  False&lt;br /&gt;&lt;br /&gt;So it is not hard at all we need a MSFlexGrid table and we need a Textbox to show on the cells we need to edit &lt;img src=&quot;style_emoticons/&lt;#EMO_DIR#&gt;/smile.gif&quot; style=&quot;vertical-align:middle&quot; emoid=&quot;:)&quot; border=&quot;0&quot; alt=&quot;smile.gif&quot; /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Now lets begin with the form load and Option explicit of our code&lt;br /&gt;In Option Explicit we add 2 variables they are not rly necessary but it help me understand the code better &lt;br /&gt;Private lRow as Long is used to store the selected row of the table throug our code &lt;br /&gt;Private lCol as  Long is used to store the selected Column in the grid &lt;br /&gt;&lt;br /&gt;They are global variables only for the curent form.&lt;br /&gt;&lt;br /&gt;In From_Load sub i will create the MSFlexGrid table prepera the columns put some data in it&lt;br /&gt;i add a counter so i can put some data in the cells. So i make 4 Columns give them names for that we use the first row of the MSflexGrid. Make the first row Fixed so it cant be edited or selected by user and the name of the columns cant be edited.&lt;br /&gt;After we make the columns and name them we put in Some values that is what the for cycle do.&lt;br /&gt;&lt;br /&gt;&lt;!--c1--&gt;&lt;div class='codetop'&gt;CODE&lt;/div&gt;&lt;div class='codemain'&gt;&lt;!--ec1--&gt;&lt;br /&gt;Option Explicit&lt;br /&gt;Private lRow As Long&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;#39;Selected Row&lt;br /&gt;Private lCol As Long&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;#39;Selected Column&lt;br /&gt;&lt;br /&gt;Private Sub Form_Load&amp;#40;&amp;#41;&lt;br /&gt;Dim i As Integer&lt;br /&gt;On Error GoTo err_h&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;With MSFGTable&lt;br /&gt;&amp;#39; Generate 4 columns and 1 fixed row used as Names of the cells &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;.FixedRows = 1&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;.FixedCols = 0&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;.Rows = 1&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;.Cols = 4&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;.TextMatrix&amp;#40;0, 0&amp;#41; = &amp;#34;Value1&amp;#34;&amp;nbsp;&amp;nbsp; &amp;#39;First row is for cells names&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;.TextMatrix&amp;#40;0, 1&amp;#41; = &amp;#34;Value2&amp;#34;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;.TextMatrix&amp;#40;0, 2&amp;#41; = &amp;#34;Value3&amp;#34;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;.TextMatrix&amp;#40;0, 3&amp;#41; = &amp;#34;Value4&amp;#34;&lt;br /&gt;&lt;br /&gt;&amp;#39; Add a data in the cells that will be edited later &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;For i = 1 To 10&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;.Rows = i + 1&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;.TextMatrix&amp;#40;i, 0&amp;#41; = i&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;.TextMatrix&amp;#40;i, 1&amp;#41; = i + 1&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;.TextMatrix&amp;#40;i, 2&amp;#41; = &amp;#34;val&amp;#34; &amp;amp; i&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;.TextMatrix&amp;#40;i, 3&amp;#41; = &amp;#34;val&amp;#34; &amp;amp; i &amp;amp; &amp;#34;= &amp;#34; &amp;amp; i + 1&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Next i&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;End With&lt;br /&gt;Exit Sub&lt;br /&gt;err_h&amp;#58;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;MsgBox Err.Description, vbCritical&lt;br /&gt;End Sub&lt;br /&gt;&lt;!--c2--&gt;&lt;/div&gt;&lt;!--ec2--&gt;&lt;br /&gt;&lt;br /&gt;By now you got the columns name in place and have full 10 rows with some values &lt;br /&gt;&lt;br /&gt;now making the FlexGrid edit use flexgrid_DblClick() and put one TextBox make it visible=false (txtEdit is mine textbox)&lt;br /&gt;&lt;br /&gt;i will make only Columns 2 and 4 able for editing &lt;br /&gt;&lt;br /&gt;This code below Use FlexGrid Double Click event to place the textbox we put in teh cell boundary of the editible cell.&lt;br /&gt;When the textbox is in place we can input data in and change the flexgrid cell values.&lt;br /&gt;&lt;br /&gt;the variables &lt;br /&gt;tL , th, tw and tt is used as the cell boundary of the cell of the MSFlexGrid we want to edit&lt;br /&gt;lRow and lCol gets the selected row and col of the MSFlexGrid. As i say i make only Cols 2 and 4 editeble so here is in place a simple if that check if lCol is 1 or 3. It is 1 and 3 becose MSFlexGrid Cols and Rows count from 0.&lt;br /&gt;&lt;br /&gt;So after we get conformation that this is the right col we place the textbox above the cell we want to edit.&lt;br /&gt;&lt;br /&gt;&lt;!--c1--&gt;&lt;div class='codetop'&gt;CODE&lt;/div&gt;&lt;div class='codemain'&gt;&lt;!--ec1--&gt;&lt;br /&gt;Private Sub MSFGTable_DblClick&amp;#40;&amp;#41;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Dim tL As Long, tH As Long, tW As Long, tT As Long &amp;#39;MSFlexGrid cell boundary&lt;br /&gt;On Error GoTo error_h&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;With MSFGTable&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;lRow = .RowSel&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;lCol = .ColSel&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;If lCol = 1 Or lCol = 3 Then &amp;#39;Check if the clolumns we want to edit are 2 and 4&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;tT = .CellTop&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;tL = .CellLeft&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;tH = .CellHeight&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;tW = .CellWidth&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;#39;Move the text box on the cell we dbl click on&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;txtEdit.Move tL + .Left, tT + .Top, tW + 2 * Screen.TwipsPerPixelX, tH&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;txtEdit.Visible = True&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;txtEdit.ZOrder 0&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;txtEdit.SetFocus&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;End If&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;End With&lt;br /&gt;Exit Sub&lt;br /&gt;&lt;br /&gt;error_h&amp;#58;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;MsgBox Err.Description, vbCritical&lt;br /&gt;End Sub&lt;br /&gt;&lt;!--c2--&gt;&lt;/div&gt;&lt;!--ec2--&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;ok now the textbox show where you want to edit use keypress event of the textbox to track vbKeyReturn and textbox LostFocus event to edit the celltext of the MSFlexGrid and hide the textbox.&lt;br /&gt;&lt;br /&gt;so in KeyPress event we select the ascii code of the keys. 13 is for enter so we track it&lt;br /&gt;&lt;br /&gt;Becos the values i give to the cells on Column 2 can accept ony numbers and Column 4 can accept all values (numbers and text) so we put a if so we can track only the Number values for Column 2 edited cells&lt;br /&gt;&lt;br /&gt;&lt;b&gt;I dont track esc button so you can put it and on escape to hide the textbox &amp;#33;&amp;#33;&amp;#33;&amp;#33;&amp;#33;&amp;#33;&amp;#33;&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;&lt;!--c1--&gt;&lt;div class='codetop'&gt;CODE&lt;/div&gt;&lt;div class='codemain'&gt;&lt;!--ec1--&gt;&lt;br /&gt;Private Sub txtEdit_KeyPress&amp;#40;KeyAscii As Integer&amp;#41;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;If KeyAscii = Str&amp;#40;13&amp;#41; Then&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;#39;Enter&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Select Case lCol&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Case 1&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;#39;Making Cell2 to accept numbers only&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;If IsNumeric&amp;#40;txtEdit.Text&amp;#41; Then&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Change_FGCell_Value lRow, lCol&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Else&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;#39; An error and exite the function awaiting right value&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;MsgBox &amp;#34;Numbers only&amp;#33;&amp;#34;, vbCritical&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Exit Sub&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;End If&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Case 3&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Change_FGCell_Value lRow, lCol&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Case Else&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;#39; An error becose is edited wrong Column&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;MsgBox &amp;#34;Error invalid Cell&amp;#34;, vbCritical&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;End Select&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;End If&lt;br /&gt;End Sub&lt;br /&gt;&lt;br /&gt;&lt;!--c2--&gt;&lt;/div&gt;&lt;!--ec2--&gt;&lt;br /&gt;&lt;br /&gt;This function belov change the value of the cell we edit.&lt;br /&gt;&lt;br /&gt;&lt;!--c1--&gt;&lt;div class='codetop'&gt;CODE&lt;/div&gt;&lt;div class='codemain'&gt;&lt;!--ec1--&gt;&lt;br /&gt;Private Sub Change_FGCell_Value&amp;#40;&amp;#41;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;#39;Change selected value of the cell in MSFlexGrid&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;MSFGTable.TextMatrix&amp;#40;lRow, lCol&amp;#41; = txtEdit.Text&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;txtEdit.Text = &amp;#34;&amp;#34;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;txtEdit.Visible = False&lt;br /&gt;End Sub&lt;br /&gt;&lt;!--c2--&gt;&lt;/div&gt;&lt;!--ec2--&gt;&lt;br /&gt;&lt;br /&gt;Here is the Lost Focus event of the textbox. As you can see its  almost the same as keypress even but dont track for a key. It select what calumn is editing and if it is 1 make sure it is only numbers the diference is here it hide the textbox. I make it for corection if user select wrong cell by any chance. the value is stored.&lt;br /&gt;&lt;br /&gt;&lt;!--c1--&gt;&lt;div class='codetop'&gt;CODE&lt;/div&gt;&lt;div class='codemain'&gt;&lt;!--ec1--&gt;&lt;br /&gt;Private Sub txtEdit_LostFocus&amp;#40;&amp;#41;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Private Sub txtEdit_LostFocus&amp;#40;&amp;#41;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Select Case lCol&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Case 1&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;#39;Making cell2 to accept numbers only&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;If IsNumeric&amp;#40;txtEdit.Text&amp;#41; Then&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Change_FGCell_Value lRow, lCol&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Else&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;txtEdit.Visible = False&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;#39; put txtEdit.Text=&amp;#34;&amp;#34; if you want your textbox text is deleted&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;End If&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Case 3&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Change_FGCell_Value lRow, lCol&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Case Else&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;#39;An error for editing wrong column&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;MsgBox &amp;#34;Error invalid Cell&amp;#34;, vbCritical&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;End Select&lt;br /&gt;End Sub&lt;br /&gt;&lt;br /&gt;&lt;!--c2--&gt;&lt;/div&gt;&lt;!--ec2--&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;ok so here is how i do it. i hope you like it . Modify it. &lt;img src=&quot;style_emoticons/&lt;#EMO_DIR#&gt;/smile.gif&quot; style=&quot;vertical-align:middle&quot; emoid=&quot;:)&quot; border=&quot;0&quot; alt=&quot;smile.gif&quot; /&gt;</description>
			<pubDate>Thu, 15 Oct 2009 16:43:27 -0500</pubDate>
			<category>Visual Basic Tutorials</category>
			<author>NoBrain</author>
         </item>
         <item>
            <link>http://forums.dreamincode.net/showtopic132167.htm</link>
            <title>Very simple updater in Visual Basic Tutorials</title>
            <description>so here is an update of a sort to the updater&lt;br /&gt;&lt;br /&gt;the updater download the file and copy it to the spec location&lt;br /&gt;&lt;br /&gt;the main program only run the updater and close it self. then updater do all the things&lt;br /&gt;&lt;br /&gt;so in the button update in our main program we start the updater and end the main program.&lt;br /&gt;&lt;br /&gt;so here is the code&lt;br /&gt;&lt;br /&gt;&lt;!--c1--&gt;&lt;div class='codetop'&gt;CODE&lt;/div&gt;&lt;div class='codemain'&gt;&lt;!--ec1--&gt;&lt;br /&gt;Private Sub cmdUpdate_Click&amp;#40;&amp;#41;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Dim process As Long&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;process = Shell&amp;#40;FilePth, vbNormalNoFocus&amp;#41;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;End&lt;br /&gt;End Sub&lt;br /&gt;&lt;!--c2--&gt;&lt;/div&gt;&lt;!--ec2--&gt;&lt;br /&gt;&lt;br /&gt;so now we start the updater.&lt;br /&gt;&lt;br /&gt;here is the function that download the file.&lt;br /&gt;&lt;br /&gt;&lt;!--c1--&gt;&lt;div class='codetop'&gt;CODE&lt;/div&gt;&lt;div class='codemain'&gt;&lt;!--ec1--&gt;&lt;br /&gt;Private Function DownLoadUPDate&amp;#40;&amp;#41; As Boolean&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;On Error GoTo err_hnld&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Dim FileName As String &amp;#39; Contain the file name&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Dim URLName As String &amp;#39;Contain the URL for our http server&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Dim FileToGet As String &amp;#39; Used to combine urlname and filename variable&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;#39; Downloading the file&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;FileName = &amp;#34;Place your file name here &amp;#40;example&amp;#58; test.txt&amp;#41;&amp;#34;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;URLName = &amp;#34;Place your URL here &amp;#40;example&amp;#58; http&amp;#58;//myurlspace.com/&amp;#41;&amp;#34;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;FileToGet = URLName &amp;amp; FileName&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Inet1.Execute FileToGet, &amp;#34;GET &amp;#34; &amp;amp; Chr&amp;#40;34&amp;#41; &amp;amp; App.Path &amp;amp; &amp;#34;&amp;#092;&amp;#34; &amp;amp; FileName &amp;amp; Chr&amp;#40;34&amp;#41;&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;#39; File is downloaded and we return true&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;DownLoadUPDate = True&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Exit Function&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;br /&gt;err_hnld&amp;#58;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;DownLoadUPDate = False&lt;br /&gt;End Function&lt;br /&gt;&lt;!--c2--&gt;&lt;/div&gt;&lt;!--ec2--&gt;&lt;br /&gt;this function is put in your Updater project you will need to place Inet control there and make the configuration of &lt;br /&gt;&lt;br /&gt;his propertys.&lt;br /&gt;&lt;br /&gt;so here is the new code for your updater&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;!--c1--&gt;&lt;div class='codetop'&gt;CODE&lt;/div&gt;&lt;div class='codemain'&gt;&lt;!--ec1--&gt;&lt;br /&gt;&lt;br /&gt;Private Sub Form_Load&amp;#40;&amp;#41;&lt;br /&gt;On Error GoTo err_hndl&lt;br /&gt;&lt;br /&gt;&amp;#39;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~&lt;br /&gt;&amp;#39; put delay here if you want to update the exe of your main program &amp;#33;&amp;#33;&amp;#33;&lt;br /&gt;&amp;#39; make it to wait till your main program is closed&lt;br /&gt;&amp;#39;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~&lt;br /&gt;&lt;br /&gt;If DownLoadUPDate = True Then&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Me.Visible = False&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Dim NewFile As String&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Dim PathToCopy As String&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Dim StartingPrgrm As String&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Dim Process As Long&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;NewFile = App.Path &amp;amp; &amp;#34;&amp;#092;Test.txt&amp;#34;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Debug.Print NewFile&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;PathToCopy = &amp;#34;C&amp;#58;&amp;#092;Documents and Settings&amp;#092;Raziel&amp;#092;Desktop&amp;#092;me Tutorials&amp;#092;DIC&amp;#092;Updated Program&amp;#092;&amp;#34;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;With New FileSystemObject&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;.CopyFile NewFile, PathToCopy&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;End With&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;StartingPrgrm = &amp;#34;C&amp;#58;&amp;#092;Documents and Settings&amp;#092;Raziel&amp;#092;Desktop&amp;#092;me Tutorials&amp;#092;DIC&amp;#092;Updated Program&amp;#092;&amp;#34;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;StartingPrgrm = StartingPrgrm &amp;amp; &amp;#34;MyExe.exe&amp;#34;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Process = Shell&amp;#40;StartingPrgrm, vbNormalFocus&amp;#41;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;End&lt;br /&gt;Else&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;MsgBox &amp;#34;Error Downloading file&amp;#34;, vbCritical&lt;br /&gt;End If&lt;br /&gt;End&lt;br /&gt;err_hndl&amp;#58;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;MsgBox Err.Description, vbCritical&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;End&lt;br /&gt;End Sub&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Private Function DownLoadUPDate&amp;#40;&amp;#41; As Boolean&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;On Error GoTo err_hnld&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Dim FileName As String &amp;#39; Contain the file name&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Dim URLName As String &amp;#39;Contain the URL for our http server&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Dim FileToGet As String &amp;#39; Used to combine urlname and filename variable&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Dim FilePth As String &amp;#39; The path to our updater&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;#39; Downloading the file&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;FileName = &amp;#34;Place your file name here &amp;#40;example&amp;#58; test.txt&amp;#41;&amp;#34;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;URLName = &amp;#34;Place your URL here &amp;#40;example&amp;#58; http&amp;#58;//myurlspace.com/&amp;#41;&amp;#34;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;FileToGet = URLName &amp;amp; FileName&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Inet1.Execute FileToGet, &amp;#34;GET &amp;#34; &amp;amp; Chr&amp;#40;34&amp;#41; &amp;amp; App.Path &amp;amp; &amp;#34;&amp;#092;&amp;#34; &amp;amp; FileName &amp;amp; Chr&amp;#40;34&amp;#41;&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;#39; File is downloaded and we return true&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;DownLoadUPDate = True&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Exit Function&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;br /&gt;err_hnld&amp;#58;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;DownLoadUPDate = False&lt;br /&gt;End Function&lt;br /&gt;&lt;!--c2--&gt;&lt;/div&gt;&lt;!--ec2--&gt;&lt;br /&gt;&lt;br /&gt;it is kinda new version &lt;img src=&quot;style_emoticons/&lt;#EMO_DIR#&gt;/tongue.gif&quot; style=&quot;vertical-align:middle&quot; emoid=&quot;:P&quot; border=&quot;0&quot; alt=&quot;tongue.gif&quot; /&gt;&lt;br /&gt;&lt;br /&gt;i Hope i dont break some rule :S&lt;br /&gt;&lt;br /&gt;feel free to modify it &lt;img src=&quot;style_emoticons/&lt;#EMO_DIR#&gt;/smile.gif&quot; style=&quot;vertical-align:middle&quot; emoid=&quot;:)&quot; border=&quot;0&quot; alt=&quot;smile.gif&quot; /&gt;&lt;br /&gt;&lt;br /&gt;EDIT:&lt;br /&gt;&lt;br /&gt;&lt;a href=&quot;http://stackoverflow.com/questions/95112/how-do-i-delay-code-execution-in-visual-basic-vb6&quot; target=&quot;_blank&quot;&gt;http://stackoverflow.com/questions/95112/h...isual-basic-vb6&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;use sleep for delay if you want to update the exe of your main program</description>
			<pubDate>Thu, 15 Oct 2009 18:14:34 -0500</pubDate>
			<category>Visual Basic Tutorials</category>
			<author>NoBrain</author>
         </item>
         <item>
            <link>http://forums.dreamincode.net/showtopic132134.htm</link>
            <title>Guide to interactively use Select Options in a Drop Down Box in PHP Tutorials</title>
            <description>&lt;b&gt;Guide to interactively use Select Options in a Drop Down Box&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;In this Tutorial I will show you how to properly use the Select/Option HTML code in an interactive PHP environment.  We will validate, &amp;amp; then properly utilize the users input.  You can use &amp;#036;_GET interchangeably with &amp;#036;_POST in this tutorial.  Their differences however, will not be discussed here.&lt;br /&gt;&lt;br /&gt;Lets begin &lt;img src=&quot;style_emoticons/&lt;#EMO_DIR#&gt;/smile.gif&quot; style=&quot;vertical-align:middle&quot; emoid=&quot;:)&quot; border=&quot;0&quot; alt=&quot;smile.gif&quot; /&gt;&lt;br /&gt;&lt;br /&gt;1st we have a simple Select/Option HTML block :&lt;br /&gt;&lt;!--c1--&gt;&lt;div class='codetop'&gt;CODE&lt;/div&gt;&lt;div class='codemain'&gt;&lt;!--ec1--&gt;&lt;br /&gt;&amp;#60;select name=&amp;#34;dropdown&amp;#34;&amp;#62;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;#60;option value=&amp;#34;1&amp;#34;&amp;#62;First&amp;#60;/option&amp;#62;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;#60;option value=&amp;#34;2&amp;#34;&amp;#62;Second&amp;#60;/option&amp;#62;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;#60;option value=&amp;#34;3&amp;#34;&amp;#62;Third&amp;#60;/option&amp;#62;&lt;br /&gt;&amp;#60;/select&amp;#62;&lt;br /&gt;&lt;!--c2--&gt;&lt;/div&gt;&lt;!--ec2--&gt;&lt;br /&gt;We have three options, &amp;amp; for anyone who may not have seen, it&amp;#39;s named the ever so obvious &amp;quot;dropdown&amp;quot;.  We will pull this value out of the &amp;#036;_POST array in PHP.&lt;br /&gt;&lt;br /&gt;When someone is viewing the form, &amp;amp; the submit button is pushed, the value contain in &amp;quot;name&amp;quot; will be the array element in the &amp;#036;_POST array.  So we could get away with doing something as simple as directly calling our passed in element.&lt;br /&gt;&lt;br /&gt;&lt;!--c1--&gt;&lt;div class='codetop'&gt;CODE&lt;/div&gt;&lt;div class='codemain'&gt;&lt;!--ec1--&gt;&lt;br /&gt;&amp;#60;?php&lt;br /&gt;&amp;nbsp;&amp;nbsp;echo &amp;#34;&amp;#60;P&amp;#62;&amp;#34;.&amp;#036;_POST&amp;#91;&amp;#39;dropdown&amp;#39;&amp;#93;.&amp;#34;&amp;#60;/p&amp;#62;&amp;#34;;&lt;br /&gt;?&amp;#62;&lt;br /&gt;&amp;#60;form action=&amp;#34;&amp;#60;?php echo &amp;#036;_SERVER&amp;#91;&amp;#39;PHP_SELF&amp;#39;&amp;#93;; ?&amp;#62;&amp;#34; method=&amp;#34;POST&amp;#34;&amp;#62;&lt;br /&gt;&amp;#60;select name=&amp;#34;dropdown&amp;#34;&amp;#62;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;#60;option value=&amp;#34;1&amp;#34;&amp;#62;First&amp;#60;/option&amp;#62;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;#60;option value=&amp;#34;2&amp;#34;&amp;#62;Second&amp;#60;/option&amp;#62;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;#60;option value=&amp;#34;3&amp;#34;&amp;#62;Third&amp;#60;/option&amp;#62;&lt;br /&gt;&amp;#60;/select&amp;#62;&lt;br /&gt;&amp;#60;input type=&amp;#34;Submit&amp;#34; name=&amp;#34;Submit&amp;#34;&amp;#62;&lt;br /&gt;&amp;#60;/form&amp;#62;&lt;br /&gt;&lt;!--c2--&gt;&lt;/div&gt;&lt;!--ec2--&gt;&lt;br /&gt;&lt;br /&gt;However, this will simply print the numerical values given in the name column.  While this will work great in a database, or for conditional comparisons, it does little to correspond with the viewer of our website.  Since it&amp;#39;s conveniently a numeric value, lets parse the value through a switch statement &lt;img src=&quot;style_emoticons/&lt;#EMO_DIR#&gt;/smile.gif&quot; style=&quot;vertical-align:middle&quot; emoid=&quot;:)&quot; border=&quot;0&quot; alt=&quot;smile.gif&quot; /&gt;  Because we control the input (in our HTML value options) there is no need for a default.  We know, without a doubt the value will be one two or three.&lt;br /&gt;&lt;br /&gt;&lt;!--c1--&gt;&lt;div class='codetop'&gt;CODE&lt;/div&gt;&lt;div class='codemain'&gt;&lt;!--ec1--&gt;&lt;br /&gt;&amp;#60;?php&lt;br /&gt;&amp;#036;number=&amp;#036;_POST&amp;#91;&amp;#39;dropdown&amp;#39;&amp;#93;;&lt;br /&gt;switch &amp;#40;&amp;#036;number&amp;#41; {&lt;br /&gt;case 1&amp;#58;&lt;br /&gt;&amp;nbsp;&amp;nbsp;echo &amp;#34;Number 1&amp;#34;;&lt;br /&gt;&amp;nbsp;&amp;nbsp;break;&lt;br /&gt;case 2&amp;#58;&lt;br /&gt;&amp;nbsp;&amp;nbsp;echo &amp;#34;Number 2&amp;#34;;&lt;br /&gt;&amp;nbsp;&amp;nbsp;break;&lt;br /&gt;case 3&amp;#58;&lt;br /&gt;&amp;nbsp;&amp;nbsp;echo &amp;#34;Number 3&amp;#34;;&lt;br /&gt;&amp;nbsp;&amp;nbsp;break;&lt;br /&gt;}&lt;br /&gt;?&amp;#62;&lt;br /&gt;&amp;#60;form action=&amp;#34;&amp;#60;?php echo &amp;#036;_SERVER&amp;#91;&amp;#39;PHP_SELF&amp;#39;&amp;#93;; ?&amp;#62;&amp;#34; method=&amp;#34;POST&amp;#34;&amp;#62;&lt;br /&gt;&amp;#60;select name=&amp;#34;dropdown&amp;#34;&amp;#62;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;#60;option value=&amp;#34;1&amp;#34;&amp;#62;First&amp;#60;/option&amp;#62;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;#60;option value=&amp;#34;2&amp;#34;&amp;#62;Second&amp;#60;/option&amp;#62;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;#60;option value=&amp;#34;3&amp;#34;&amp;#62;Third&amp;#60;/option&amp;#62;&lt;br /&gt;&amp;#60;/select&amp;#62;&lt;br /&gt;&amp;#60;input type=&amp;#34;Submit&amp;#34; name=&amp;#34;Submit&amp;#34;&amp;#62;&lt;br /&gt;&amp;#60;/form&amp;#62;&lt;br /&gt;&lt;!--c2--&gt;&lt;/div&gt;&lt;!--ec2--&gt;&lt;br /&gt;&lt;br /&gt;Now that&amp;#39;s fine &amp;amp; dandy, but lets give the user a little more interaction, with a nice default message, urging them to make a selection.  In the event that they don&amp;#39;t choose a value, we can catch that by giving that option a value of zero, &amp;amp; verifying that the input value is not zero.  By 1st checking for Submit, we know that the user has seen the options, has mad a selection, &amp;amp; we can now verify that the option was something other than default.  The default value is prepared for them in the HTML option with the &amp;quot;selected&amp;quot; value.&lt;br /&gt;&lt;br /&gt;&lt;!--c1--&gt;&lt;div class='codetop'&gt;CODE&lt;/div&gt;&lt;div class='codemain'&gt;&lt;!--ec1--&gt;&amp;#60;?php&lt;br /&gt;&amp;nbsp;&amp;nbsp;if&amp;#40;&amp;#036;_POST&amp;#91;&amp;#39;Submit&amp;#39;&amp;#93;&amp;#41; {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;if&amp;#40;&amp;#036;_POST&amp;#91;&amp;#39;dropdown&amp;#39;&amp;#93;==0&amp;#41; die&amp;#40;&amp;#34;You must select a valid entry&amp;#34;&amp;#41;;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;#036;number=&amp;#036;_POST&amp;#91;&amp;#39;dropdown&amp;#39;&amp;#93;;&lt;br /&gt;&amp;nbsp;&amp;nbsp;switch &amp;#40;&amp;#036;number&amp;#41; {&lt;br /&gt;&amp;nbsp;&amp;nbsp;case 1&amp;#58;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;echo &amp;#34;Number 1&amp;#34;;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;break;&lt;br /&gt;&amp;nbsp;&amp;nbsp;case 2&amp;#58;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;echo &amp;#34;Number 2&amp;#34;;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;break;&lt;br /&gt;&amp;nbsp;&amp;nbsp;case 3&amp;#58;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;echo &amp;#34;Number 3&amp;#34;;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;break;&lt;br /&gt;&amp;nbsp;&amp;nbsp;}&lt;br /&gt;}&lt;br /&gt;?&amp;#62;&lt;br /&gt;&amp;#60;form action=&amp;#34;&amp;#60;?php echo &amp;#036;_SERVER&amp;#91;&amp;#39;PHP_SELF&amp;#39;&amp;#93;; ?&amp;#62;&amp;#34; method=&amp;#34;POST&amp;#34;&amp;#62;&lt;br /&gt;&amp;#60;select name=&amp;#34;dropdown&amp;#34;&amp;#62;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;#60;option value=&amp;#34;0&amp;#34;&amp;#62;-Please choose one-&amp;#60;/option&amp;#62;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;#60;option value=&amp;#34;1&amp;#34;&amp;#62;First&amp;#60;/option&amp;#62;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;#60;option value=&amp;#34;2&amp;#34;&amp;#62;Second&amp;#60;/option&amp;#62;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;#60;option value=&amp;#34;3&amp;#34;&amp;#62;Third&amp;#60;/option&amp;#62;&lt;br /&gt;&amp;#60;/select&amp;#62;&lt;br /&gt;&amp;#60;input type=&amp;#34;Submit&amp;#34; name=&amp;#34;Submit&amp;#34;&amp;#62;&lt;br /&gt;&amp;#60;/form&amp;#62;&lt;br /&gt;&lt;br /&gt;&lt;!--c2--&gt;&lt;/div&gt;&lt;!--ec2--&gt;&lt;br /&gt;&lt;br /&gt;In a nutshell, this is a quick way to add a little interaction with your viewers when they are making a selection.  It helps to give your form a little more personality, &amp;amp; take the faceless values away from your site.  &lt;img src=&quot;style_emoticons/&lt;#EMO_DIR#&gt;/biggrin.gif&quot; style=&quot;vertical-align:middle&quot; emoid=&quot;:D&quot; border=&quot;0&quot; alt=&quot;biggrin.gif&quot; /&gt;    &lt;img src=&quot;style_emoticons/&lt;#EMO_DIR#&gt;/icon_up.gif&quot; style=&quot;vertical-align:middle&quot; emoid=&quot;:^:&quot; border=&quot;0&quot; alt=&quot;icon_up.gif&quot; /&gt; &lt;br /&gt;&lt;br /&gt;This tutorial can be seen working at the following URL : &lt;a href=&quot;http://akroncdnr.com/select.test.php&quot; target=&quot;_blank&quot;&gt;http://akroncdnr.com/select.test.php&lt;/a&gt;</description>
			<pubDate>Thu, 15 Oct 2009 03:54:08 -0500</pubDate>
			<category>PHP Tutorials</category>
			<author>no2pencil</author>
         </item>
         <item>
            <link>http://forums.dreamincode.net/showtopic131093.htm</link>
            <title>Zen and The Art of Using Functors With STL Algorithms in C++ Tutorials</title>
            <description>&lt;!--fonto:Time--&gt;&lt;span style=&quot;font-family:Time&quot;&gt;&lt;!--/fonto--&gt;&lt;!--sizeo:12--&gt;&lt;span style=&quot;font-size:12pt;line-height:100%&quot;&gt;&lt;!--/sizeo--&gt;&lt;br /&gt;&lt;!--fonto:Arial--&gt;&lt;span style=&quot;font-family:Arial&quot;&gt;&lt;!--/fonto--&gt;&lt;!--sizeo:16--&gt;&lt;span style=&quot;font-size:12pt;line-height:100%&quot;&gt;&lt;!--/sizeo--&gt;&lt;b&gt;Introduction&lt;/b&gt;&lt;!--sizec--&gt;&lt;/span&gt;&lt;!--/sizec--&gt;&lt;!--fontc--&gt;&lt;/span&gt;&lt;!--/fontc--&gt;&lt;br /&gt;&lt;br /&gt;This tutorial presents the use of function objects using Standard Template algorithm functions. The tutorial uses a simple inventory program to illustrate the use of these functors. &lt;br /&gt;  &lt;br /&gt;The first function object, or functor, is used to facilitate the find_if algorithm on a data structure. We&amp;#39;ll create a simple product structure for an inventory program. The user can pick what information to update and which one to update. To do so the user needs to identify which product to update. They might know the product id or just the product description. The functor allows us to check for both possibilities.&lt;br /&gt;&lt;br /&gt;The second function object is used to store the product to a data file. Normally this would be simple since all we have is a structure but this structure stores a pointer to a Date object which handles obviously the date for the product. Storing the pointer wouldn&amp;#39;t make any sense so we use the functor to serialize the object into a readable format. We also want to store the product in a tab delimited format. You could write specialized loops or a iostream friend to do this, infact we do this for loading, but the functor makes it trivial and we get to use the algorithms in the Standard Template Library. &lt;br /&gt;&lt;br /&gt;&lt;!--fonto:Arial--&gt;&lt;span style=&quot;font-family:Arial&quot;&gt;&lt;!--/fonto--&gt;&lt;!--sizeo:16--&gt;&lt;span style=&quot;font-size:12pt;line-height:100%&quot;&gt;&lt;!--/sizeo--&gt;&lt;b&gt;The Product Structure&lt;/b&gt;&lt;!--sizec--&gt;&lt;/span&gt;&lt;!--/sizec--&gt;&lt;!--fontc--&gt;&lt;/span&gt;&lt;!--/fontc--&gt;&lt;br /&gt;&lt;br /&gt;Each product is stored using the following structure.&lt;br /&gt;[code=cpp]&lt;br /&gt;struct product {&lt;br /&gt;	string id;&lt;br /&gt;	string description;&lt;br /&gt;	int quantity;&lt;br /&gt;	double wholesale;&lt;br /&gt;	double retail;&lt;br /&gt;	Date* date_added;&lt;br /&gt;    friend std::istream&amp;amp; operator &amp;gt;&amp;gt;( istream&amp;amp; is, product&amp;amp; p );&lt;br /&gt;};&lt;br /&gt;[/code]&lt;br /&gt;&lt;br /&gt;Date is just a simple class for dates. A vector of products is used to store the inventory for our program. &lt;br /&gt;&lt;br /&gt;&lt;!--fonto:Arial--&gt;&lt;span style=&quot;font-family:Arial&quot;&gt;&lt;!--/fonto--&gt;&lt;!--sizeo:16--&gt;&lt;span style=&quot;font-size:12pt;line-height:100%&quot;&gt;&lt;!--/sizeo--&gt;&lt;b&gt;Program Flow&lt;/b&gt;&lt;!--sizec--&gt;&lt;/span&gt;&lt;!--/sizec--&gt;&lt;!--fontc--&gt;&lt;/span&gt;&lt;!--/fontc--&gt;&lt;br /&gt;&lt;br /&gt;The program starts out by checking to see if there is an inventory file created in the current directory. If not it then walks the user through the process of creating it etc... Main then moves on to loading the newly created inventory into our vector. Next a menu is presented to the user that allows the user to modify or search for a item. Once the user exits the main menu loop the product information is once again stored.&lt;br /&gt;&lt;br /&gt;&lt;!--fonto:Arial--&gt;&lt;span style=&quot;font-family:Arial&quot;&gt;&lt;!--/fonto--&gt;&lt;!--sizeo:16--&gt;&lt;span style=&quot;font-size:12pt;line-height:100%&quot;&gt;&lt;!--/sizeo--&gt;&lt;b&gt;Function Object Bases&lt;/b&gt;&lt;!--sizec--&gt;&lt;/span&gt;&lt;!--/sizec--&gt;&lt;!--fontc--&gt;&lt;/span&gt;&lt;!--/fontc--&gt;&lt;br /&gt;&lt;br /&gt;Function objects are so common in C++ that the Standard Template Library supplies bases classes for their definition. These definitions help you name your function object return types and parameters so they can seemlessly be used with the algorithms in the Library.&lt;br /&gt;&lt;br /&gt;The first base class supplied by the Standard Template Library is the std::unary_function template. To derive from this class all that is needed is to supply an &lt;b&gt;operator()&lt;/b&gt; that returns &lt;b&gt;bool&lt;/b&gt;. For our purposes we&amp;#39;ll define three functors using this template as a base. The first we&amp;#39;ll use to test equality of the product structures based on the ID or DESCRIPTION field. We&amp;#39;ll use this functor with the find_if algorithm to locate the product in our vector of products.&lt;br /&gt;&lt;br /&gt;[code=cpp]&lt;br /&gt;class prod_eq:public std::unary_function&amp;lt;product, bool&amp;gt;&lt;br /&gt;{&lt;br /&gt;private:&lt;br /&gt;	string m_id;&lt;br /&gt;public:&lt;br /&gt;	prod_eq( const string&amp;amp; n ): m_id( n ){}&lt;br /&gt;	bool operator()(const product&amp;amp; element )&lt;br /&gt;	{&lt;br /&gt;		bool ret_val = true;&lt;br /&gt;        typedef string::const_iterator SI;&lt;br /&gt;        SI p1 = element.id.begin();&lt;br /&gt;        SI p2 = m_id.begin();&lt;br /&gt;&lt;br /&gt;        while( (p1&amp;#33;=element.id.end() &amp;amp;&amp;amp; p2&amp;#33;=m_id.end()) &amp;amp;&amp;amp; ret_val )&lt;br /&gt;        {&lt;br /&gt;            if( toupper(*p1)&amp;#33;= toupper(*p2) ) ret_val = false;&lt;br /&gt;            ++p1;&lt;br /&gt;            ++p2;&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;	    if(&amp;#33;ret_val){&lt;br /&gt;		    SI p1 = element.description.begin();&lt;br /&gt;       	    SI p2 = m_id.begin();&lt;br /&gt;            &lt;br /&gt;            ret_val = true;&lt;br /&gt;            while( (p1&amp;#33;=element.description.end() &amp;amp;&amp;amp; p2&amp;#33;=m_id.end()) &amp;amp;&amp;amp; ret_val )&lt;br /&gt;            {&lt;br /&gt;                if( toupper(*p1)&amp;#33;= toupper(*p2) ) ret_val = false;&lt;br /&gt;                ++p1;&lt;br /&gt;                ++p2;&lt;br /&gt;            }&lt;br /&gt;	    }&lt;br /&gt;        return ret_val;&lt;br /&gt;	}&lt;br /&gt;};&lt;br /&gt;[/code]&lt;br /&gt;&lt;br /&gt;The second we&amp;#39;ll use to store the product structures using a ostream to a file. We&amp;#39;ll use this functor with the for_each algorithm to save each of the products in our vector of products to a data file in tab delimited format.&lt;br /&gt;&lt;br /&gt;[code=cpp]&lt;br /&gt;class save_product:public std::unary_function&amp;lt;product, bool&amp;gt;&lt;br /&gt;{&lt;br /&gt;private:&lt;br /&gt;	ostream* m_os;&lt;br /&gt;public:&lt;br /&gt;	save_product( ostream* os ){ m_os = os; }&lt;br /&gt;	bool operator()( const product&amp;amp; element )&lt;br /&gt;	{&lt;br /&gt;		bool ret_val = false;&lt;br /&gt;		// save element in tab delimited format&lt;br /&gt;		 &lt;br /&gt;		*m_os &amp;lt;&amp;lt; setprecision(2) &amp;lt;&amp;lt; fixed &amp;lt;&amp;lt; element.id.c_str() &lt;br /&gt;			&amp;lt;&amp;lt; &amp;quot;&amp;#092;t&amp;quot; &amp;lt;&amp;lt; element.description.c_str() &lt;br /&gt;			&amp;lt;&amp;lt; &amp;quot;&amp;#092;t&amp;quot; &amp;lt;&amp;lt; element.quantity &lt;br /&gt;            &amp;lt;&amp;lt; &amp;quot;&amp;#092;t&amp;quot; &amp;lt;&amp;lt; element.wholesale &lt;br /&gt;            &amp;lt;&amp;lt; &amp;quot;&amp;#092;t&amp;quot; &amp;lt;&amp;lt; element.retail &lt;br /&gt;			&amp;lt;&amp;lt; &amp;quot;&amp;#092;t&amp;quot; &amp;lt;&amp;lt; element.date_added-&amp;gt;get(2) // write date in month/day/year format&lt;br /&gt;			&amp;lt;&amp;lt; &amp;quot;/&amp;quot; &amp;lt;&amp;lt; element.date_added-&amp;gt;get(1) &lt;br /&gt;			&amp;lt;&amp;lt; &amp;quot;/&amp;quot; &amp;lt;&amp;lt; element.date_added-&amp;gt;get(3)&lt;br /&gt;			&amp;lt;&amp;lt; &amp;quot;&amp;#092;t&amp;quot;;&lt;br /&gt;		if(m_os)&lt;br /&gt;			ret_val = true;&lt;br /&gt;		return ret_val;&lt;br /&gt;	}&lt;br /&gt;};&lt;br /&gt;[/code]&lt;br /&gt;&lt;br /&gt;The last we&amp;#39;ll use to load the product structures from an istream. We&amp;#39;ll use this functor with the copy algorithm to load each of the products from our data file into our vector of products.&lt;br /&gt;&lt;br /&gt;[code=cpp]&lt;br /&gt;class load_product:public std::unary_function&amp;lt;product, bool&amp;gt;&lt;br /&gt;{&lt;br /&gt;private:&lt;br /&gt;    istream* m_is;&lt;br /&gt;public:&lt;br /&gt;    load_product( istream* is ){ m_is = is; }&lt;br /&gt;    bool operator()( product&amp;amp; element )&lt;br /&gt;    {&lt;br /&gt;        bool ret_val = false;&lt;br /&gt;	    char buffer[maxStringSize];&lt;br /&gt;	    unsigned int fieldCnt = 0;&lt;br /&gt;&lt;br /&gt;	    while(m_is &amp;amp;&amp;amp; fieldCnt &amp;lt; REC_FIELD_COUNT )&lt;br /&gt;	    {&lt;br /&gt;		    m_is-&amp;gt;getline(buffer,(streamsize)maxStringSize, &amp;#39;&amp;#092;t&amp;#39;);&lt;br /&gt;		    if(m_is)&lt;br /&gt;		    {&lt;br /&gt;			    switch( fieldCnt )&lt;br /&gt;			    {&lt;br /&gt;				    case 0: element.id = buffer; ++fieldCnt; break;&lt;br /&gt;				    case 1: element.description = buffer; ++fieldCnt; break;&lt;br /&gt;				    case 2: element.quantity = ioConv&amp;lt;int&amp;gt;(buffer); ++fieldCnt; break;&lt;br /&gt;				    case 3: element.retail = ioConv&amp;lt;double&amp;gt;(buffer); ++fieldCnt; break;&lt;br /&gt;				    case 4: element.wholesale = ioConv&amp;lt;double&amp;gt;(buffer); ++fieldCnt; break;&lt;br /&gt;				    default:&lt;br /&gt;                        element.date_added = new Date();&lt;br /&gt;					    element.date_added-&amp;gt;set(buffer, &amp;quot;/&amp;quot;);&lt;br /&gt;					    ret_val = true;&lt;br /&gt;                        break;&lt;br /&gt;			    }&lt;br /&gt;		    }&lt;br /&gt;	    }&lt;br /&gt;        return ret_val;&lt;br /&gt;    }&lt;br /&gt;};&lt;br /&gt;[/code]&lt;br /&gt;&lt;br /&gt;&lt;!--fonto:Arial--&gt;&lt;span style=&quot;font-family:Arial&quot;&gt;&lt;!--/fonto--&gt;&lt;!--sizeo:16--&gt;&lt;span style=&quot;font-size:12pt;line-height:100%&quot;&gt;&lt;!--/sizeo--&gt;&lt;b&gt;The Source&lt;/b&gt;&lt;!--sizec--&gt;&lt;/span&gt;&lt;!--/sizec--&gt;&lt;!--fontc--&gt;&lt;/span&gt;&lt;!--/fontc--&gt;&lt;br /&gt;&lt;br /&gt;main cpp&lt;br /&gt;[code=cpp]&lt;br /&gt;///////////////////////////////////////&lt;br /&gt;/// &amp;#092;file main cpp&lt;br /&gt;/// &amp;#092;brief Main Module for Product project&lt;br /&gt;/// &lt;br /&gt;/// &amp;#092;author John &amp;#39;Ghost&amp;#39; Wicks&lt;br /&gt;/// &amp;#092;version 01.00.01&lt;br /&gt;/// &amp;#092;date 2007-10-16&lt;br /&gt;///&lt;br /&gt;//////////////////////// &lt;br /&gt;// History &lt;br /&gt;// JWW 2007-10-03 v00.99.00 Initial release &lt;br /&gt;// JWW 2007-10-16 v01.00.01 Eliminated transform calls with string&lt;br /&gt;//                          since gnu fails to compile with them&lt;br /&gt;&lt;br /&gt;// Includes &lt;br /&gt;#include &amp;lt;iostream&amp;gt;&lt;br /&gt;#include &amp;lt;iomanip&amp;gt;&lt;br /&gt;#include &amp;lt;vector&amp;gt;&lt;br /&gt;#include &amp;lt;fstream&amp;gt;&lt;br /&gt;#include &amp;lt;string&amp;gt;&lt;br /&gt;#include &amp;lt;sstream&amp;gt;&lt;br /&gt;#include &amp;lt;algorithm&amp;gt;&lt;br /&gt;using namespace std;&lt;br /&gt;&lt;br /&gt;#include &amp;quot;product.h&amp;quot;&lt;br /&gt;#include &amp;quot;date.h&amp;quot;&lt;br /&gt;&lt;br /&gt;// Global constants and variables &lt;br /&gt;const char DATA_FILE[] = {&amp;quot;data_file.dat&amp;quot;};&lt;br /&gt;const char REPORT_FILE[] = {&amp;quot;report_file.txt&amp;quot;};&lt;br /&gt;const char PRG_NAME[] = {&amp;quot;MyInventory Program - v 1.00.01&amp;quot;}; &lt;br /&gt;const char CPY_RGHT[] = {&amp;quot;CopyMePlease 2007 - &amp;quot;}; &lt;br /&gt;const char AUTHOR[] = {&amp;quot;John Wicks&amp;quot;};&lt;br /&gt;#ifdef _WIN32&lt;br /&gt;	const char CLRSCR[] = {&amp;quot;cls&amp;quot;};&lt;br /&gt;#else&lt;br /&gt;	const char CLRSCR[] = {&amp;quot;clear&amp;quot;};&lt;br /&gt;#endif&lt;br /&gt;&lt;br /&gt;const char STR_ERR_DATAFILE_EMPTY[] = {&amp;quot;Error - Data file is empty, using standard input instead...&amp;quot;};&lt;br /&gt;const char STR_ERR_OPEN_RPTFILE[] = {&amp;quot;Error - Unable to open report file, using standard out instead...&amp;quot;};&lt;br /&gt;const char STR_ERR_OPEN_DATAFILE[] = {&amp;quot;Error - Unable to open data file, using manual input instead...&amp;quot;};&lt;br /&gt;const int QUIT = 0;&lt;br /&gt;const int CONTINUE = 1;&lt;br /&gt;&lt;br /&gt;// function prototypes &lt;br /&gt;void show_copyright( void );&lt;br /&gt;int get_choice( const string&amp;amp; prompt ); &lt;br /&gt;bool is_valid_choice( unsigned int val, size_t min, size_t max );&lt;br /&gt;string get_string( const string&amp;amp; prompt, int maxSize );&lt;br /&gt;void show_main_menu( void );&lt;br /&gt;void do_update( vector&amp;lt;product&amp;gt;&amp;amp; p );&lt;br /&gt;void do_report( vector&amp;lt;product&amp;gt;&amp;amp; p );&lt;br /&gt;&lt;br /&gt;// Uncomment to run just the testing main&lt;br /&gt;//#define TEST 1&lt;br /&gt;&lt;br /&gt;/////////////////////////&lt;br /&gt;/// &amp;#092;fn main(int argc, char** argv)&lt;br /&gt;/// &amp;#092;brief Main module for inventory program.&lt;br /&gt;///&lt;br /&gt;/// &amp;#092;param argc - integer number of arguments passed from system to program&lt;br /&gt;/// &amp;#092;param argv - pointer to array of characters of arguments passed to program from system&lt;br /&gt;///&lt;br /&gt;/// &amp;#092;return integer value for success or failure&lt;br /&gt;/////////////////////////&lt;br /&gt;#ifndef TEST&lt;br /&gt;int main(int argc, char* argv[])&lt;br /&gt;{&lt;br /&gt;	int done = 0, choice = 0, nProducts = 0;&lt;br /&gt;	bool flag_inFile = false;&lt;br /&gt;	bool flag_outFile = false;&lt;br /&gt;	ifstream inFile; //Input data file&lt;br /&gt;	ofstream outFile; //Output report file&lt;br /&gt;    ostream* out;&lt;br /&gt;	vector&amp;lt;product&amp;gt; Inventory;&lt;br /&gt;&lt;br /&gt;	system(CLRSCR);&lt;br /&gt;	show_copyright();&lt;br /&gt;&lt;br /&gt;	//Check for existance of datafile or if it&amp;#39;s empty&lt;br /&gt;	inFile.open(DATA_FILE, ios::in|ios::out|ios::binary|ios::app);&lt;br /&gt;	if(flag_inFile = inFile.is_open()){&lt;br /&gt;		if(inFile.peek()==EOF){&lt;br /&gt;			cerr &amp;lt;&amp;lt; STR_ERR_DATAFILE_EMPTY &amp;lt;&amp;lt; endl;&lt;br /&gt;			flag_inFile = false;&lt;br /&gt;			inFile.close();&lt;br /&gt;			outFile.open(DATA_FILE, ios::in|ios::out|ios::binary|ios::app);&lt;br /&gt;			flag_outFile = outFile.is_open();&lt;br /&gt;            if(flag_outFile)&lt;br /&gt;			    out = &amp;amp;outFile;&lt;br /&gt;            else&lt;br /&gt;                out = &amp;amp;cout;&lt;br /&gt;		}&lt;br /&gt;		else&lt;br /&gt;			out = &amp;amp;cout;&lt;br /&gt;	}&lt;br /&gt;	else{&lt;br /&gt;		out = &amp;amp;cout; // No data file output should be to standard out&lt;br /&gt;		cerr &amp;lt;&amp;lt; STR_ERR_OPEN_DATAFILE &amp;lt;&amp;lt; endl;&lt;br /&gt;	}&lt;br /&gt;	&lt;br /&gt;	//Input file doesn&amp;#39;t exist or is empty, Let&amp;#39;s create some data&lt;br /&gt;	if(&amp;#33;flag_inFile){ &lt;br /&gt;		do{&lt;br /&gt;			cout &amp;lt;&amp;lt; endl &amp;lt;&amp;lt; endl;&lt;br /&gt;			do{&lt;br /&gt;				create_product( Inventory );&lt;br /&gt;				show_product( Inventory[nProducts] );&lt;br /&gt;				nProducts++;&lt;br /&gt;				choice = get_choice(&amp;quot;Press 1 to continue entering data or 0 to quit: &amp;quot;);&lt;br /&gt;			}while(&amp;#33;is_valid_choice( choice, 0, 1));&lt;br /&gt;			if (choice == QUIT) done = true;&lt;br /&gt;		}while (&amp;#33;done);&lt;br /&gt;        if(&amp;#33;flag_outFile)&lt;br /&gt;		    *out &amp;lt;&amp;lt; &amp;quot;The following Inventory items were entered...&amp;quot; &amp;lt;&amp;lt; endl;&lt;br /&gt;		for_each(Inventory.begin(), Inventory.end(), show_product);&lt;br /&gt;		&lt;br /&gt;        if(&amp;#33;flag_outFile)&lt;br /&gt;            *out &amp;lt;&amp;lt; &amp;quot;Storing data...&amp;quot; &amp;lt;&amp;lt; endl &amp;lt;&amp;lt; endl;&lt;br /&gt;		for_each(Inventory.begin(), Inventory.end(), save_product(out));&lt;br /&gt;	}&lt;br /&gt;	&lt;br /&gt;	if( Inventory.size() ==0 ){&lt;br /&gt;	    copy(std::istream_iterator&amp;lt;product&amp;gt;(inFile), std::istream_iterator&amp;lt;product&amp;gt;(), std::back_inserter(Inventory));	&lt;br /&gt;	}&lt;br /&gt;	&lt;br /&gt;	// Main Program loop&lt;br /&gt;	do{&lt;br /&gt;        show_main_menu();&lt;br /&gt;		do{ &lt;br /&gt;			choice = get_choice(&amp;quot;Press 1 to continue or 0 to quit: &amp;quot;); &lt;br /&gt;		}while(&amp;#33;is_valid_choice( choice, 0, 3 )); &lt;br /&gt;	&lt;br /&gt;		switch( choice ){&lt;br /&gt;			case 1: create_product( Inventory );&lt;br /&gt;				show_product( Inventory[nProducts] );&lt;br /&gt;				nProducts++;&lt;br /&gt;				break;&lt;br /&gt;			case 2: do_update( Inventory );&lt;br /&gt; 				break;&lt;br /&gt;			case 3: do_report( Inventory );&lt;br /&gt;				break;&lt;br /&gt;			default:&lt;br /&gt;				break;&lt;br /&gt;		}&lt;br /&gt;	}while(choice&amp;#33;= QUIT);&lt;br /&gt;		&lt;br /&gt;	if(flag_inFile) inFile.close();&lt;br /&gt;    if(&amp;#33;flag_outFile){&lt;br /&gt;        outFile.open(DATA_FILE, ios::out|ios::binary|ios::trunc);&lt;br /&gt;        for_each(Inventory.begin(), Inventory.end(), save_product(&amp;amp;outFile));&lt;br /&gt;        outFile.close();&lt;br /&gt;    }&lt;br /&gt;&lt;br /&gt;	return 0;	&lt;br /&gt;}&lt;br /&gt;#else&lt;br /&gt;int main( int argc, char** argv)&lt;br /&gt;{&lt;br /&gt;	return 0;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;#endif&lt;br /&gt;&lt;br /&gt;///////////////////////// &lt;br /&gt;/// &amp;#092;fn show_copyright(void) &lt;br /&gt;/// &amp;#092;brief Show program name and copyright notice &lt;br /&gt;/// &lt;br /&gt;/// &amp;#092;b SideEffects : None&amp;#092;n&lt;br /&gt;/// &amp;#092;b Output : couts PRG_NAME, CPY_RGHT and AUTHOR defines&amp;#092;n&lt;br /&gt;///&lt;br /&gt;/// &amp;#092;return None&lt;br /&gt;//////////////////////// &lt;br /&gt;void show_copyright( void ) &lt;br /&gt;{ &lt;br /&gt;	cout &amp;lt;&amp;lt; PRG_NAME &amp;lt;&amp;lt; endl; &lt;br /&gt;	cout &amp;lt;&amp;lt; CPY_RGHT &amp;lt;&amp;lt; AUTHOR &amp;lt;&amp;lt; endl &amp;lt;&amp;lt; endl; &lt;br /&gt;	return; &lt;br /&gt;} &lt;br /&gt;&lt;br /&gt;///////////////////////// &lt;br /&gt;/// &amp;#092;fn get_choice( const string&amp;amp; prompt )&lt;br /&gt;/// &amp;#092;brief Check to see if user wants to continue &lt;br /&gt;/// &lt;br /&gt;/// &amp;#092;b SideEffects: None&amp;#092;n &lt;br /&gt;/// &amp;#092;b Output: Prompts user to continue program&amp;#092;n&lt;br /&gt;/// &lt;br /&gt;/// &amp;#092;return integer of choice entered by user &lt;br /&gt;///////////////////////// &lt;br /&gt;int get_choice( const string&amp;amp; prompt ) &lt;br /&gt;{ &lt;br /&gt;	int ret_val;&lt;br /&gt;	stringstream ioConv;&lt;br /&gt;	&lt;br /&gt;	ioConv &amp;lt;&amp;lt; get_string(prompt, maxStringSize);&lt;br /&gt;	ioConv &amp;gt;&amp;gt; ret_val;&lt;br /&gt;	&lt;br /&gt;	return ret_val; &lt;br /&gt;} &lt;br /&gt;&lt;br /&gt;///////////////////////// &lt;br /&gt;/// &amp;#092;fn is_valid_choice( int val, size_t min, size_t max ) &lt;br /&gt;/// &amp;#092;brief Checks for valid entry for menu &lt;br /&gt;/// &lt;br /&gt;/// &amp;#092;b SideEffects : None&amp;#092;n &lt;br /&gt;/// &amp;#092;b Output : Displays an error message if an invalid choice is passed &amp;#092;n&lt;br /&gt;/// &lt;br /&gt;/// &amp;#092;param val - Current choice from menu&lt;br /&gt;/// &amp;#092;param min - minimum acceptable value&lt;br /&gt;/// &amp;#092;param max - maximum acceptable value&lt;br /&gt;/// &lt;br /&gt;/// &amp;#092;return boolean true if choice is valid and false otherwise &lt;br /&gt;//////////////////////// &lt;br /&gt;bool is_valid_choice( unsigned int val, size_t min, size_t max ) &lt;br /&gt;{ &lt;br /&gt;	bool ret_val = false;&lt;br /&gt;	if( val &amp;gt;= min &amp;amp;&amp;amp; val &amp;lt;= max )&lt;br /&gt;	{&lt;br /&gt;		ret_val = true;&lt;br /&gt;	}&lt;br /&gt;	if(&amp;#33;ret_val){&lt;br /&gt;		cout &amp;lt;&amp;lt; &amp;quot;Error: Invalid choice &amp;quot; &amp;lt;&amp;lt; val &amp;lt;&amp;lt; &amp;quot; selected.&amp;quot; &amp;lt;&amp;lt; endl; &lt;br /&gt;	}&lt;br /&gt;		&lt;br /&gt;	return ret_val; &lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;///////////////////////// &lt;br /&gt;/// &amp;#092;fn get_string( const string&amp;amp; prompt, int maxSize )&lt;br /&gt;/// &amp;#092;brief Gets a user entered string&lt;br /&gt;/// &lt;br /&gt;/// &amp;#092;b SideEffects: None&amp;#092;n &lt;br /&gt;/// &amp;#092;b Output: Prompts user to enter in string data&amp;#092;n&lt;br /&gt;/// &lt;br /&gt;/// &amp;#092;param prompt - Display string that tells user what type of data string to enter &lt;br /&gt;/// &amp;#092;param maxSize - maximum string size&lt;br /&gt;/// &lt;br /&gt;/// &amp;#092;return ret_val - User entered string&lt;br /&gt;/////////////////////////&lt;br /&gt;string get_string( const string&amp;amp; prompt, int maxSize )&lt;br /&gt;{&lt;br /&gt;	string ret_val;&lt;br /&gt;&lt;br /&gt;	cout &amp;lt;&amp;lt; prompt;&lt;br /&gt;	getline(cin,ret_val);&lt;br /&gt;	&lt;br /&gt;	return ret_val;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;///////////////////////// &lt;br /&gt;/// &amp;#092;fn show_main_menu( void ) &lt;br /&gt;/// &amp;#092;brief Show program menu &lt;br /&gt;/// &lt;br /&gt;/// &amp;#092;b SideEffects : None&amp;#092;n&lt;br /&gt;/// &amp;#092;b Output : couts menu for user choice&amp;#092;n&lt;br /&gt;///&lt;br /&gt;/// &amp;#092;return None&lt;br /&gt;//////////////////////// &lt;br /&gt;void show_main_menu( void ) &lt;br /&gt;{ &lt;br /&gt;	cout &amp;lt;&amp;lt; &amp;quot;1. Enter new product data&amp;quot; &amp;lt;&amp;lt; endl;&lt;br /&gt;	cout &amp;lt;&amp;lt; &amp;quot;2. Modify a product&amp;#39;s data&amp;quot; &amp;lt;&amp;lt; endl;&lt;br /&gt;	cout &amp;lt;&amp;lt; &amp;quot;3. Display a product&amp;#39;s data&amp;quot; &amp;lt;&amp;lt; endl;&lt;br /&gt;	cout &amp;lt;&amp;lt; &amp;quot;0. Exit the program&amp;quot; &amp;lt;&amp;lt; endl;&lt;br /&gt;&lt;br /&gt;	return; &lt;br /&gt;} &lt;br /&gt;&lt;br /&gt;///////////////////////// &lt;br /&gt;/// &amp;#092;fn show_update_menu( void ) &lt;br /&gt;/// &amp;#092;brief Show program update product menu &lt;br /&gt;/// &lt;br /&gt;/// &amp;#092;b SideEffects : None&amp;#092;n&lt;br /&gt;/// &amp;#092;b Output : couts menu for user choice&amp;#092;n&lt;br /&gt;///&lt;br /&gt;/// &amp;#092;return None&lt;br /&gt;//////////////////////// &lt;br /&gt;void show_update_menu( void ) &lt;br /&gt;{ &lt;br /&gt;	cout &amp;lt;&amp;lt; &amp;quot;1. Update Product Description&amp;quot; &amp;lt;&amp;lt; endl;&lt;br /&gt;	cout &amp;lt;&amp;lt; &amp;quot;2. Update Product Quantity on Hand&amp;quot; &amp;lt;&amp;lt; endl;&lt;br /&gt;    cout &amp;lt;&amp;lt; &amp;quot;3. Update Product Wholesale Price&amp;quot; &amp;lt;&amp;lt; endl;&lt;br /&gt;	cout &amp;lt;&amp;lt; &amp;quot;4. Update Product Retail Price&amp;quot; &amp;lt;&amp;lt; endl;&lt;br /&gt;    cout &amp;lt;&amp;lt; &amp;quot;5. Update Product Date Added to Inventory&amp;quot; &amp;lt;&amp;lt; endl;&lt;br /&gt;	cout &amp;lt;&amp;lt; &amp;quot;0. Return to Main Menu.&amp;quot; &amp;lt;&amp;lt; endl;&lt;br /&gt;&lt;br /&gt;	return; &lt;br /&gt;} &lt;br /&gt;&lt;br /&gt;///////////////////////// &lt;br /&gt;/// &amp;#092;fn show_report_menu( void ) &lt;br /&gt;/// &amp;#092;brief Show program report product menu &lt;br /&gt;/// &lt;br /&gt;/// &amp;#092;b SideEffects : None&amp;#092;n&lt;br /&gt;/// &amp;#092;b Output : couts menu for user choice&amp;#092;n&lt;br /&gt;///&lt;br /&gt;/// &amp;#092;return None&lt;br /&gt;//////////////////////// &lt;br /&gt;void show_report_menu( void ) &lt;br /&gt;{ &lt;br /&gt;	cout &amp;lt;&amp;lt; &amp;quot;1. Look up Product by Item Description&amp;quot; &amp;lt;&amp;lt; endl;&lt;br /&gt;	cout &amp;lt;&amp;lt; &amp;quot;2. Look up Product by ID&amp;quot; &amp;lt;&amp;lt; endl;&lt;br /&gt;    cout &amp;lt;&amp;lt; &amp;quot;3. Show all Products&amp;quot; &amp;lt;&amp;lt; endl;&lt;br /&gt;    cout &amp;lt;&amp;lt; &amp;quot;0. Return to Main Menu.&amp;quot; &amp;lt;&amp;lt; endl;&lt;br /&gt;&lt;br /&gt;	return; &lt;br /&gt;} &lt;br /&gt;&lt;br /&gt;/////////////////////////&lt;br /&gt;// &amp;#092;fn do_update( vector&amp;lt;product&amp;gt;&amp;amp; p )&lt;br /&gt;// &amp;#092;brief Handling routine for update menu&lt;br /&gt;//&lt;br /&gt;// &amp;#092;b Purpose: Processes update menu choices&lt;br /&gt;// &amp;#092;b SideEffects: none&lt;br /&gt;//&lt;br /&gt;// &amp;#092;param p - vector containing product records&lt;br /&gt;// &amp;#092;return none&lt;br /&gt;/////////////////////////&lt;br /&gt;void do_update( vector&amp;lt;product&amp;gt;&amp;amp; p )&lt;br /&gt;{&lt;br /&gt;	bool done = false;&lt;br /&gt;	int choice;&lt;br /&gt;	string t, id;&lt;br /&gt;	product* uProd = new( product );&lt;br /&gt;	product&amp;amp; pUpdate = *uProd;&lt;br /&gt;	&lt;br /&gt;	system(CLRSCR);&lt;br /&gt;	show_copyright();&lt;br /&gt;&lt;br /&gt;	do&lt;br /&gt;	{&lt;br /&gt;		id = get_product_id();&lt;br /&gt;	}while(&amp;#33;is_valid_product_id( p, id ));&lt;br /&gt;&lt;br /&gt;    typedef vector&amp;lt;product&amp;gt;::iterator VCI;&lt;br /&gt;	VCI f = find_if( p.begin(), p.end(), prod_eq(id));&lt;br /&gt;	&lt;br /&gt;    do{&lt;br /&gt;        cout &amp;lt;&amp;lt; endl &amp;lt;&amp;lt; &amp;quot;Modifying Product : &amp;quot; &amp;lt;&amp;lt; (*f).id &amp;lt;&amp;lt; endl &amp;lt;&amp;lt; endl;&lt;br /&gt;&lt;br /&gt;	    show_update_menu();&lt;br /&gt;	    do{ &lt;br /&gt;		    choice = get_choice(&amp;quot;Enter the choice of data to modify: &amp;quot;); &lt;br /&gt;	    }while(&amp;#33;is_valid_choice( choice, 0, 5 )); &lt;br /&gt;		&lt;br /&gt;	    switch( choice ){&lt;br /&gt;		    case 1: do_prod_descript( p, pUpdate );&lt;br /&gt;				    (*f).description = pUpdate.description;&lt;br /&gt;				    break;&lt;br /&gt;		    case 2: do_prod_quantity( pUpdate );&lt;br /&gt;				    (*f).quantity = pUpdate.quantity;&lt;br /&gt;				    break;&lt;br /&gt;		    case 3: do_prod_cost( pUpdate, PRD_TYPE_WHOLESALE );&lt;br /&gt;				    (*f).wholesale = pUpdate.wholesale;&lt;br /&gt;				    break;&lt;br /&gt;		    case 4: do_prod_cost( pUpdate, PRD_TYPE_RETAIL );&lt;br /&gt;				    (*f).retail = pUpdate.retail;&lt;br /&gt;				    break;&lt;br /&gt;		    case 5: do_prod_date_added( pUpdate );&lt;br /&gt;				    (*f).date_added = pUpdate.date_added;&lt;br /&gt;				    break;&lt;br /&gt;		    default:&lt;br /&gt;			    done = true;&lt;br /&gt;			    break;&lt;br /&gt;	    }&lt;br /&gt;    }while(&amp;#33;done);&lt;br /&gt;	&lt;br /&gt;&lt;br /&gt;	delete uProd;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;/////////////////////////&lt;br /&gt;// &amp;#092;fn do_report( vector&amp;lt;product&amp;gt;&amp;amp; p )&lt;br /&gt;// &amp;#092;brief Handling routine for report menu&lt;br /&gt;//&lt;br /&gt;// &amp;#092;b Purpose: Processes report menu choices&lt;br /&gt;// &amp;#092;b SideEffects: none&lt;br /&gt;//&lt;br /&gt;// &amp;#092;param p - vector containing product records&lt;br /&gt;// &amp;#092;return none&lt;br /&gt;/////////////////////////&lt;br /&gt;void do_report( vector&amp;lt;product&amp;gt;&amp;amp; p )&lt;br /&gt;{&lt;br /&gt;	bool done = false;&lt;br /&gt;	int choice;&lt;br /&gt;	string id;&lt;br /&gt;&lt;br /&gt;	system(CLRSCR);&lt;br /&gt;	show_copyright();&lt;br /&gt;&lt;br /&gt;    do{&lt;br /&gt;		show_report_menu();&lt;br /&gt;		do{ &lt;br /&gt;			choice = get_choice(&amp;quot;Enter your choice: &amp;quot;); &lt;br /&gt;		}while(&amp;#33;is_valid_choice( choice, 0, 3 )); &lt;br /&gt;		&lt;br /&gt;		switch( choice ){&lt;br /&gt;			case 1:&lt;br /&gt;			case 2:{&lt;br /&gt;					do{&lt;br /&gt;						id = get_product_id();&lt;br /&gt;					}while(&amp;#33;is_valid_product_id( p, id ));&lt;br /&gt;&lt;br /&gt;					typedef vector&amp;lt;product&amp;gt;::iterator VCI;&lt;br /&gt;					VCI f = find_if( p.begin(), p.end(), prod_eq(id));&lt;br /&gt;&lt;br /&gt;					product&amp;amp; pUpdate = *f;&lt;br /&gt;					show_product( pUpdate );&lt;br /&gt;					break;&lt;br /&gt;				   }&lt;br /&gt;            case 3:&lt;br /&gt;                for_each( p.begin(), p.end(), show_product);&lt;br /&gt;                break;&lt;br /&gt;			default:&lt;br /&gt;				done = true;&lt;br /&gt;			break;&lt;br /&gt;		}&lt;br /&gt;&lt;br /&gt;	}while(&amp;#33;done);&lt;br /&gt;}&lt;br /&gt;[/code]&lt;br /&gt;&lt;br /&gt;date.h&lt;br /&gt;[code=cpp]&lt;br /&gt;///////////////////////////////////////&lt;br /&gt;/// &amp;#092;file date.h&lt;br /&gt;/// &amp;#092;brief Date Class header&lt;br /&gt;/// &lt;br /&gt;/// &amp;#092;author John &amp;#39;Ghost&amp;#39; Wicks&lt;br /&gt;/// &amp;#092;version 0.99.0&lt;br /&gt;/// &amp;#092;date 2007-09-14&lt;br /&gt;///&lt;br /&gt;/// &amp;#092;section History&lt;br /&gt;/// &amp;#092;brief Revision 0.99.0 14-Sept-2007 Initial release&lt;br /&gt;///&lt;br /&gt;///////////////////////////////////////&lt;br /&gt;&lt;br /&gt;#ifndef __DATE_H__&lt;br /&gt;#define __DATE_H__&lt;br /&gt;&lt;br /&gt;#include &amp;lt;string&amp;gt;&lt;br /&gt;#include &amp;lt;sstream&amp;gt;&lt;br /&gt;#include &amp;lt;vector&amp;gt;&lt;br /&gt;&lt;br /&gt;using namespace std;&lt;br /&gt;&lt;br /&gt;const int YEAR = 3;&lt;br /&gt;const int MONTH = 2;&lt;br /&gt;const int DAY = 1;&lt;br /&gt;&lt;br /&gt;class Date&lt;br /&gt;{&lt;br /&gt;	private:&lt;br /&gt;		string Month( void );&lt;br /&gt;&lt;br /&gt;	protected:&lt;br /&gt;		int m_month, m_day, m_year;&lt;br /&gt;&lt;br /&gt;	public:&lt;br /&gt;		Date( int month=1, int day=1, int year=1 );&lt;br /&gt;		Date( string d );&lt;br /&gt;		Date( const Date&amp;amp; d );&lt;br /&gt;		Date operator+( string &amp;amp;other );&lt;br /&gt;		bool set( int m, int d, int y );&lt;br /&gt;		bool set( const string&amp;amp; str, const string&amp;amp; delim = &amp;quot; &amp;quot; );&lt;br /&gt;		bool is_valid( void );&lt;br /&gt;		string get( void );&lt;br /&gt;		string get( int which );&lt;br /&gt;		virtual ~Date(){}&lt;br /&gt;		&lt;br /&gt;};&lt;br /&gt;&lt;br /&gt;#endif&lt;br /&gt;[/code]&lt;br /&gt;&lt;br /&gt;date cpp&lt;br /&gt;[code=cpp]&lt;br /&gt;///////////////////////////////////////&lt;br /&gt;/// &amp;#092;file date cpp&lt;br /&gt;/// &amp;#092;brief Date Class Module&lt;br /&gt;/// &lt;br /&gt;/// &amp;#092;author John &amp;#39;Ghost&amp;#39; Wicks&lt;br /&gt;/// &amp;#092;version 0.99.0&lt;br /&gt;/// &amp;#092;date 2007-09-14&lt;br /&gt;///&lt;br /&gt;/// &amp;#092;section History&lt;br /&gt;/// &amp;#092;brief Revision 0.99.0 14-Sept-2007 Initial release&lt;br /&gt;///&lt;br /&gt;///////////////////////////////////////&lt;br /&gt;&lt;br /&gt;#include &amp;quot;date.h&amp;quot;&lt;br /&gt;&lt;br /&gt;Date::Date( int month, int day, int year )&lt;br /&gt;{&lt;br /&gt;	this-&amp;gt;m_month = month;&lt;br /&gt;	this-&amp;gt;m_day = day;&lt;br /&gt;	this-&amp;gt;m_year = year;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;Date::Date( string d )&lt;br /&gt;{&lt;br /&gt;	Date::set( d , &amp;quot;/&amp;quot; );&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;Date::Date( const Date&amp;amp; d )&lt;br /&gt;{&lt;br /&gt;	this-&amp;gt;m_month = d.m_month;&lt;br /&gt;	this-&amp;gt;m_day = d.m_day;&lt;br /&gt;	this-&amp;gt;m_year = d.m_year;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;Date Date::operator+( string &amp;amp;other )&lt;br /&gt;{&lt;br /&gt;	return Date( other );&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;string Date::Month( void )&lt;br /&gt;{&lt;br /&gt;	static char m_months[13][10] = {&amp;quot;&amp;quot;, &amp;quot;January&amp;quot;, &amp;quot;February&amp;quot;, &amp;quot;March&amp;quot;, &amp;quot;April&amp;quot;, &amp;quot;May&amp;quot;, &amp;quot;June&amp;quot;, &amp;quot;July&amp;quot;, &amp;quot;August&amp;quot;, &amp;quot;September&amp;quot;, &amp;quot;October&amp;quot;, &amp;quot;November&amp;quot;, &amp;quot;December&amp;quot;};&lt;br /&gt;	string month(m_months[m_month]);&lt;br /&gt;	return month;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;string Date::get( void )&lt;br /&gt;{&lt;br /&gt;	stringstream d;&lt;br /&gt;	d &amp;lt;&amp;lt; Month() &amp;lt;&amp;lt; &amp;quot; &amp;quot; &amp;lt;&amp;lt; m_day &amp;lt;&amp;lt; &amp;quot;, &amp;quot; &amp;lt;&amp;lt; m_year;&lt;br /&gt;	return d.str();&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;string Date::get( int which )&lt;br /&gt;{&lt;br /&gt;	stringstream d;&lt;br /&gt;	switch( which )&lt;br /&gt;	{&lt;br /&gt;		case DAY: d &amp;lt;&amp;lt; m_day; break;&lt;br /&gt;		case MONTH: d &amp;lt;&amp;lt; m_month; break;&lt;br /&gt;		case YEAR: d &amp;lt;&amp;lt; m_year; break;&lt;br /&gt;		default:&lt;br /&gt;			d &amp;lt;&amp;lt; m_month &amp;lt;&amp;lt;&amp;quot;/&amp;quot;&amp;lt;&amp;lt; m_day &amp;lt;&amp;lt;&amp;quot;/&amp;quot;&amp;lt;&amp;lt; m_year;&lt;br /&gt;			break;&lt;br /&gt;	}&lt;br /&gt;	&lt;br /&gt;	return d.str();&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;bool Date::set( int m, int d, int y )&lt;br /&gt;{&lt;br /&gt;	m_day = d;&lt;br /&gt;	m_month = m;&lt;br /&gt;	m_year = y;&lt;br /&gt;&lt;br /&gt;	return is_valid();&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;bool Date::set( const string&amp;amp; str, const string&amp;amp; delim )&lt;br /&gt;{&lt;br /&gt;	vector&amp;lt;string&amp;gt; tokens;&lt;br /&gt;&lt;br /&gt;	string::size_type last = str.find_first_not_of( delim );&lt;br /&gt;	string::size_type pos = str.find_first_of( delim );&lt;br /&gt;	&lt;br /&gt;	while (string::npos &amp;#33;= pos || string::npos &amp;#33;= last)&lt;br /&gt;    {&lt;br /&gt;        tokens.push_back(str.substr(last, pos - last));&lt;br /&gt;        last = str.find_first_not_of(delim, pos);&lt;br /&gt;        pos = str.find_first_of(delim, last);&lt;br /&gt;    }&lt;br /&gt;    &lt;br /&gt;    this-&amp;gt;m_month = atoi(tokens.at(0).c_str());&lt;br /&gt;	this-&amp;gt;m_day = atoi(tokens.at(1).c_str());&lt;br /&gt;	this-&amp;gt;m_year = atoi(tokens.at(2).c_str());&lt;br /&gt;&lt;br /&gt;	//Corrects any two digit years&lt;br /&gt;	if(m_year &amp;lt; 100 &amp;amp;&amp;amp; m_year &amp;gt;= 80)&lt;br /&gt;		m_year += 1900;&lt;br /&gt;	else if( m_year &amp;lt; 100 &amp;amp;&amp;amp; m_year &amp;lt; 80 )&lt;br /&gt;		m_year +=2000;&lt;br /&gt;	&lt;br /&gt;	&lt;br /&gt;	return Date::is_valid();&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;bool Date::is_valid( void )&lt;br /&gt;{&lt;br /&gt;	bool ret_val = false;&lt;br /&gt;	int ny_days [13] = {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};&lt;br /&gt;	int ly_days [13] = {0, 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};&lt;br /&gt;&lt;br /&gt;	if( m_year &amp;gt;= 1900 ){&lt;br /&gt;		if( m_month &amp;gt;= 1 &amp;amp;&amp;amp; m_month &amp;lt;= 12 ){&lt;br /&gt;			if ( m_day &amp;gt;= 1 ){&lt;br /&gt;				if (&amp;#33;(m_year % 4))&lt;br /&gt;				{&lt;br /&gt;					if (m_day &amp;lt;= ly_days[m_month])&lt;br /&gt;						ret_val = true;&lt;br /&gt;				}&lt;br /&gt;				else{&lt;br /&gt;					if (m_day &amp;lt;= ny_days[m_month])&lt;br /&gt;						ret_val = true;&lt;br /&gt;				}&lt;br /&gt;			}&lt;br /&gt;		}&lt;br /&gt;	}&lt;br /&gt;	return ret_val;&lt;br /&gt;}&lt;br /&gt;[/code]&lt;br /&gt;&lt;br /&gt;product.h&lt;br /&gt;[code=cpp]&lt;br /&gt;///////////////////////////////////////&lt;br /&gt;/// &amp;#092;file product.h&lt;br /&gt;/// &amp;#092;brief Inventory Product header&lt;br /&gt;/// &lt;br /&gt;/// &amp;#092;author John &amp;#39;Ghost&amp;#39; Wicks&lt;br /&gt;/// &amp;#092;version 01.00.01&lt;br /&gt;/// &amp;#092;date 2007-10-16&lt;br /&gt;///&lt;br /&gt;/// &amp;#092;section History&lt;br /&gt;/// &amp;#092;brief Revision 0.99.0 03-Oct-2007 Initial release&lt;br /&gt;// JWW 2007-10-16 v01.00.01 Eliminated transform calls with string&lt;br /&gt;//                          since gnu fails to compile with them&lt;br /&gt;///&lt;br /&gt;///////////////////////////////////////&lt;br /&gt;&lt;br /&gt;#ifndef __PRODUCT_H__&lt;br /&gt;#define __PRODUCT_H__&lt;br /&gt;&lt;br /&gt;#include &amp;lt;iostream&amp;gt;&lt;br /&gt;#include &amp;lt;iomanip&amp;gt;&lt;br /&gt;#include &amp;lt;algorithm&amp;gt;&lt;br /&gt;#include &amp;lt;string&amp;gt;&lt;br /&gt;#include &amp;lt;sstream&amp;gt;&lt;br /&gt;#include &amp;lt;limits&amp;gt;&lt;br /&gt;#include &amp;lt;functional&amp;gt;&lt;br /&gt;#include &amp;lt;cctype&amp;gt;&lt;br /&gt;using namespace std;&lt;br /&gt;&lt;br /&gt;#include &amp;quot;date.h&amp;quot;&lt;br /&gt;&lt;br /&gt;const int maxStringSize = 1024;&lt;br /&gt;const unsigned int REC_FIELD_COUNT = 6;&lt;br /&gt;const unsigned int PRD_TYPE_WHOLESALE = 1;&lt;br /&gt;const unsigned int PRD_TYPE_RETAIL = 2;&lt;br /&gt; &lt;br /&gt;struct product {&lt;br /&gt;    product(){ date_added = new Date(); }&lt;br /&gt;    string id;&lt;br /&gt;	string description;&lt;br /&gt;	int quantity;&lt;br /&gt;	double wholesale;&lt;br /&gt;	double retail;&lt;br /&gt;	Date* date_added;&lt;br /&gt;    friend std::istream&amp;amp; operator &amp;gt;&amp;gt;( istream&amp;amp; is, product&amp;amp; p );&lt;br /&gt;};&lt;br /&gt;&lt;br /&gt;template &amp;lt;class oType, class iType&amp;gt;&lt;br /&gt;oType ioConv( const iType&amp;amp; _T )&lt;br /&gt;{&lt;br /&gt;	stringstream _S;&lt;br /&gt;	oType ret_val;&lt;br /&gt;&lt;br /&gt;	_S &amp;lt;&amp;lt; _T;&lt;br /&gt;	_S &amp;gt;&amp;gt; ret_val;&lt;br /&gt;&lt;br /&gt;	return ret_val;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;class prod_eq:public std::unary_function&amp;lt;product, bool&amp;gt;&lt;br /&gt;{&lt;br /&gt;private:&lt;br /&gt;	string m_id;&lt;br /&gt;public:&lt;br /&gt;	prod_eq( const string&amp;amp; n ): m_id( n ){}&lt;br /&gt;	bool operator()(const product&amp;amp; element )&lt;br /&gt;	{&lt;br /&gt;		bool ret_val = true;&lt;br /&gt;        typedef string::const_iterator SI;&lt;br /&gt;        SI p1 = element.id.begin();&lt;br /&gt;        SI p2 = m_id.begin();&lt;br /&gt;&lt;br /&gt;        while( (p1&amp;#33;=element.id.end() &amp;amp;&amp;amp; p2&amp;#33;=m_id.end()) &amp;amp;&amp;amp; ret_val )&lt;br /&gt;        {&lt;br /&gt;            if( toupper(*p1)&amp;#33;= toupper(*p2) ) ret_val = false;&lt;br /&gt;            ++p1;&lt;br /&gt;            ++p2;&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;	    if(&amp;#33;ret_val){&lt;br /&gt;		    SI p1 = element.description.begin();&lt;br /&gt;       	    SI p2 = m_id.begin();&lt;br /&gt;            &lt;br /&gt;            ret_val = true;&lt;br /&gt;            while( (p1&amp;#33;=element.description.end() &amp;amp;&amp;amp; p2&amp;#33;=m_id.end()) &amp;amp;&amp;amp; ret_val )&lt;br /&gt;            {&lt;br /&gt;                if( toupper(*p1)&amp;#33;= toupper(*p2) ) ret_val = false;&lt;br /&gt;                ++p1;&lt;br /&gt;                ++p2;&lt;br /&gt;            }&lt;br /&gt;	    }&lt;br /&gt;        return ret_val;&lt;br /&gt;	}&lt;br /&gt;};&lt;br /&gt;&lt;br /&gt;class save_product:public std::unary_function&amp;lt;product, bool&amp;gt;&lt;br /&gt;{&lt;br /&gt;private:&lt;br /&gt;	ostream* m_os;&lt;br /&gt;public:&lt;br /&gt;	save_product( ostream* os ){ m_os = os; }&lt;br /&gt;	bool operator()( const product&amp;amp; element )&lt;br /&gt;	{&lt;br /&gt;		bool ret_val = false;&lt;br /&gt;		// save element in tab delimited format&lt;br /&gt;		 &lt;br /&gt;		*m_os &amp;lt;&amp;lt; setprecision(2) &amp;lt;&amp;lt; fixed &amp;lt;&amp;lt; element.id.c_str() &lt;br /&gt;			&amp;lt;&amp;lt; &amp;quot;&amp;#092;t&amp;quot; &amp;lt;&amp;lt; element.description.c_str() &lt;br /&gt;			&amp;lt;&amp;lt; &amp;quot;&amp;#092;t&amp;quot; &amp;lt;&amp;lt; element.quantity &lt;br /&gt;            &amp;lt;&amp;lt; &amp;quot;&amp;#092;t&amp;quot; &amp;lt;&amp;lt; element.wholesale &lt;br /&gt;            &amp;lt;&amp;lt; &amp;quot;&amp;#092;t&amp;quot; &amp;lt;&amp;lt; element.retail &lt;br /&gt;			&amp;lt;&amp;lt; &amp;quot;&amp;#092;t&amp;quot; &amp;lt;&amp;lt; element.date_added-&amp;gt;get(2) // write date in month/day/year format&lt;br /&gt;			&amp;lt;&amp;lt; &amp;quot;/&amp;quot; &amp;lt;&amp;lt; element.date_added-&amp;gt;get(1) &lt;br /&gt;			&amp;lt;&amp;lt; &amp;quot;/&amp;quot; &amp;lt;&amp;lt; element.date_added-&amp;gt;get(3)&lt;br /&gt;			&amp;lt;&amp;lt; &amp;quot;&amp;#092;t&amp;quot;;&lt;br /&gt;		if(m_os)&lt;br /&gt;			ret_val = true;&lt;br /&gt;		return ret_val;&lt;br /&gt;	}&lt;br /&gt;};&lt;br /&gt;&lt;br /&gt;class load_product:public std::unary_function&amp;lt;product, bool&amp;gt;&lt;br /&gt;{&lt;br /&gt;private:&lt;br /&gt;    istream* m_is;&lt;br /&gt;public:&lt;br /&gt;    load_product( istream* is ){ m_is = is; }&lt;br /&gt;    bool operator()( product&amp;amp; element )&lt;br /&gt;    {&lt;br /&gt;        bool ret_val = false;&lt;br /&gt;	    char buffer[maxStringSize];&lt;br /&gt;	    unsigned int fieldCnt = 0;&lt;br /&gt;&lt;br /&gt;	    while(m_is &amp;amp;&amp;amp; fieldCnt &amp;lt; REC_FIELD_COUNT )&lt;br /&gt;	    {&lt;br /&gt;		    m_is-&amp;gt;getline(buffer,(streamsize)maxStringSize, &amp;#39;&amp;#092;t&amp;#39;);&lt;br /&gt;		    if(m_is)&lt;br /&gt;		    {&lt;br /&gt;			    switch( fieldCnt )&lt;br /&gt;			    {&lt;br /&gt;				    case 0: element.id = buffer; ++fieldCnt; break;&lt;br /&gt;				    case 1: element.description = buffer; ++fieldCnt; break;&lt;br /&gt;				    case 2: element.quantity = ioConv&amp;lt;int&amp;gt;(buffer); ++fieldCnt; break;&lt;br /&gt;				    case 3: element.retail = ioConv&amp;lt;double&amp;gt;(buffer); ++fieldCnt; break;&lt;br /&gt;				    case 4: element.wholesale = ioConv&amp;lt;double&amp;gt;(buffer); ++fieldCnt; break;&lt;br /&gt;				    default:&lt;br /&gt;                        element.date_added = new Date();&lt;br /&gt;					    element.date_added-&amp;gt;set(buffer, &amp;quot;/&amp;quot;);&lt;br /&gt;					    ret_val = true;&lt;br /&gt;                        break;&lt;br /&gt;			    }&lt;br /&gt;		    }&lt;br /&gt;	    }&lt;br /&gt;        return ret_val;&lt;br /&gt;    }&lt;br /&gt;};&lt;br /&gt;&lt;br /&gt;extern string get_string( const string&amp;amp; prompt, int maxSize );&lt;br /&gt;void gen_id( product&amp;amp; p );&lt;br /&gt;string get_product_id( void );&lt;br /&gt;bool is_valid_product_id( vector&amp;lt;product&amp;gt;&amp;amp; p, const string&amp;amp; id );&lt;br /&gt;&lt;br /&gt;void do_prod_descript( vector&amp;lt;product&amp;gt;&amp;amp; v, product&amp;amp; p );&lt;br /&gt;void get_prod_descript( product&amp;amp; p );&lt;br /&gt;bool is_valid_descript( vector&amp;lt;product&amp;gt;&amp;amp; p, const string&amp;amp; descript );&lt;br /&gt;&lt;br /&gt;void do_prod_quantity( product&amp;amp; p );&lt;br /&gt;void get_prod_quantity( product&amp;amp; p );&lt;br /&gt;bool is_valid_quantity( int quantity, const unsigned int min, const unsigned int max );&lt;br /&gt;&lt;br /&gt;void do_prod_cost( product&amp;amp; p , unsigned int type);&lt;br /&gt;void get_prod_cost( product&amp;amp; p, unsigned int type, const string&amp;amp; prompt );&lt;br /&gt;bool is_valid_cost( double cost, double min, double max );&lt;br /&gt;&lt;br /&gt;void do_prod_date_added( product&amp;amp; p );&lt;br /&gt;void get_prod_date_added( product&amp;amp; p );&lt;br /&gt;&lt;br /&gt;void create_product( vector&amp;lt;product&amp;gt;&amp;amp; p );&lt;br /&gt;void update_product( vector&amp;lt;product&amp;gt;&amp;amp; p );&lt;br /&gt;void show_product( const product&amp;amp; p );&lt;br /&gt;&lt;br /&gt;#endif __PRODUCT_H__&lt;br /&gt;[/code]&lt;br /&gt;&lt;br /&gt;product cpp&lt;br /&gt;[code=cpp]&lt;br /&gt;///////////////////////////////////////&lt;br /&gt;/// &amp;#092;file product cpp&lt;br /&gt;/// &amp;#092;brief Inventory Product Module&lt;br /&gt;/// &lt;br /&gt;/// &amp;#092;author John &amp;#39;Ghost&amp;#39; Wicks&lt;br /&gt;/// &amp;#092;version 01.00.01&lt;br /&gt;/// &amp;#092;date 2007-10-06&lt;br /&gt;///&lt;br /&gt;/// &amp;#092;section History&lt;br /&gt;/// &amp;#092;brief Revision 0.99.0 03-Oct-2007 Initial release&lt;br /&gt;// JWW 2007-10-16 v01.00.01 Eliminated transform calls with string&lt;br /&gt;//                          since gnu fails to compile with them&lt;br /&gt;///&lt;br /&gt;///////////////////////////////////////&lt;br /&gt;&lt;br /&gt;#include &amp;quot;product.h&amp;quot;&lt;br /&gt;&lt;br /&gt;///////////////////////// &lt;br /&gt;/// &amp;#092;fn gen_id( product&amp;amp; p )&lt;br /&gt;/// &amp;#092;brief Generate the Product&amp;#39;s identification &lt;br /&gt;/// &lt;br /&gt;/// &amp;#092;b SideEffects: None&amp;#092;n &lt;br /&gt;/// &amp;#092;b Output: None&amp;#092;n&lt;br /&gt;/// &lt;br /&gt;/// &amp;#092;param p - product structure for storage of data&lt;br /&gt;/// &amp;#092;return none &lt;br /&gt;///////////////////////// &lt;br /&gt;void gen_id( product&amp;amp; p )&lt;br /&gt;{&lt;br /&gt;	string temp;&lt;br /&gt;    typedef string::const_iterator SI;&lt;br /&gt;    SI p1 = p.description.begin();&lt;br /&gt;&lt;br /&gt;    while(p1 &amp;#33;= p.description.end() )&lt;br /&gt;    {&lt;br /&gt;        switch( toupper(*p1) ){&lt;br /&gt;            case &amp;#39;A&amp;#39;:&lt;br /&gt;            case &amp;#39;E&amp;#39;:&lt;br /&gt;            case &amp;#39;I&amp;#39;:&lt;br /&gt;            case &amp;#39;O&amp;#39;:&lt;br /&gt;            case &amp;#39;U&amp;#39;:&lt;br /&gt;                break;&lt;br /&gt;            default:&lt;br /&gt;                if( isspace( *p1 ) )&lt;br /&gt;                    temp += &amp;quot;_&amp;quot;;&lt;br /&gt;                else&lt;br /&gt;                    temp += *p1;&lt;br /&gt;                break;&lt;br /&gt;        }        &lt;br /&gt;         ++p1;&lt;br /&gt;    }&lt;br /&gt;    &lt;br /&gt;    temp += &amp;quot;_&amp;quot;;&lt;br /&gt;	temp += p.date_added-&amp;gt;get( YEAR );&lt;br /&gt;    temp += &amp;quot;_&amp;quot;;&lt;br /&gt;    temp += p.date_added-&amp;gt;get( MONTH );&lt;br /&gt;    temp += &amp;quot;_&amp;quot;;&lt;br /&gt;    temp += p.date_added-&amp;gt;get( DAY );&lt;br /&gt;	p.id = temp;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;///////////////////////// &lt;br /&gt;/// &amp;#092;fn get_product_id( void )&lt;br /&gt;/// &amp;#092;brief Gets a product id from user&lt;br /&gt;/// &lt;br /&gt;/// &amp;#092;b SideEffects : None&amp;#092;n &lt;br /&gt;/// &amp;#092;b Output : Prompt to enter product identifier&lt;br /&gt;/// &lt;br /&gt;/// &amp;#092;param none&lt;br /&gt;/// &lt;br /&gt;/// &amp;#092;return string with id number or decription entered&lt;br /&gt;//////////////////////// &lt;br /&gt;string get_product_id( void )&lt;br /&gt;{&lt;br /&gt;	string ret_val;&lt;br /&gt;&lt;br /&gt;	ret_val = get_string(&amp;quot;Enter product ID or FULL item description to modify: &amp;quot;, 1024);&lt;br /&gt;	&lt;br /&gt;	return ret_val;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;///////////////////////// &lt;br /&gt;/// &amp;#092;fn is_valid_product_id( vector&amp;lt;product&amp;gt;&amp;amp; p, const string&amp;amp; id )&lt;br /&gt;/// &amp;#092;brief Checks to make sure id is a valid product&lt;br /&gt;/// &lt;br /&gt;/// &amp;#092;b SideEffects : None&amp;#092;n &lt;br /&gt;/// &amp;#092;b Output : Error message if product not found &lt;br /&gt;/// &lt;br /&gt;/// &amp;#092;param c - Reference to vector of products&lt;br /&gt;/// &amp;#092;param id - string id to check against product id or description&lt;br /&gt;/// &lt;br /&gt;/// &amp;#092;return true if id or description is found in a product false otherwise&lt;br /&gt;//////////////////////// &lt;br /&gt;bool is_valid_product_id( vector&amp;lt;product&amp;gt;&amp;amp; p, const string&amp;amp; id )&lt;br /&gt;{&lt;br /&gt;	bool ret_val = false;&lt;br /&gt;	typedef vector&amp;lt;product&amp;gt;::const_iterator VCI;&lt;br /&gt;&lt;br /&gt;	VCI f = find_if( p.begin(), p.end(), prod_eq(id));&lt;br /&gt;	if(f &amp;#33;= p.end() ){&lt;br /&gt;		ret_val = true;&lt;br /&gt;	}&lt;br /&gt;	else{&lt;br /&gt;		cerr &amp;lt;&amp;lt; &amp;quot;Unable to locate Product with id OR description: &amp;quot;&amp;lt;&amp;lt; id &amp;lt;&amp;lt; endl;&lt;br /&gt;		cerr &amp;lt;&amp;lt; &amp;quot;Please try again...&amp;quot; &amp;lt;&amp;lt; endl &amp;lt;&amp;lt; endl;&lt;br /&gt;	}&lt;br /&gt;	return ret_val;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;///////////////////////// &lt;br /&gt;/// &amp;#092;fn do_prod_descript( product&amp;amp; p )&lt;br /&gt;/// &amp;#092;brief Handles getting and checking the product description &lt;br /&gt;/// &lt;br /&gt;/// &amp;#092;b SideEffects: None&amp;#092;n &lt;br /&gt;/// &amp;#092;b Output: None&amp;#092;n&lt;br /&gt;/// &lt;br /&gt;/// &amp;#092;param p - product structure for storage of data&lt;br /&gt;/// &amp;#092;return none &lt;br /&gt;///////////////////////// &lt;br /&gt;void do_prod_descript( vector&amp;lt;product&amp;gt;&amp;amp; v, product&amp;amp; p )&lt;br /&gt;{&lt;br /&gt;	do&lt;br /&gt;	{&lt;br /&gt;		get_prod_descript( p );&lt;br /&gt;	}while(&amp;#33;is_valid_descript( v, p.description ));&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;///////////////////////// &lt;br /&gt;/// &amp;#092;fn get_prod_descript( product&amp;amp; p )&lt;br /&gt;/// &amp;#092;brief Gets the Products description &lt;br /&gt;/// &lt;br /&gt;/// &amp;#092;b SideEffects: None&amp;#092;n &lt;br /&gt;/// &amp;#092;b Output: Prompts user to enter product description&amp;#092;n&lt;br /&gt;/// &lt;br /&gt;/// &amp;#092;param p - product structure for storage of data&lt;br /&gt;/// &amp;#092;return none &lt;br /&gt;///////////////////////// &lt;br /&gt;void get_prod_descript( product&amp;amp; p )&lt;br /&gt;{&lt;br /&gt;	p.description = get_string(&amp;quot;Enter product&amp;#39;s description: &amp;quot;, maxStringSize);&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;///////////////////////// &lt;br /&gt;/// &amp;#092;fn is_valid_descript( const string&amp;amp; description )&lt;br /&gt;/// &amp;#092;brief Checks to see if product description is valid &lt;br /&gt;/// &lt;br /&gt;/// &amp;#092;b SideEffects: None&amp;#092;n &lt;br /&gt;/// &amp;#092;b Output: Error message if description is invalid&amp;#092;n&lt;br /&gt;///&lt;br /&gt;/// &amp;#092;param description - current product description to check validity of&lt;br /&gt;/// &lt;br /&gt;/// &amp;#092;return ret_val - boolean true if description is valid and false otherwise &lt;br /&gt;///////////////////////// &lt;br /&gt;bool is_valid_descript( vector&amp;lt;product&amp;gt;&amp;amp; p, const string&amp;amp; description )&lt;br /&gt;{&lt;br /&gt;	bool ret_val = false;&lt;br /&gt;	typedef vector&amp;lt;product&amp;gt;::const_iterator VCI;&lt;br /&gt;&lt;br /&gt;	VCI f = find_if( p.begin(), p.end(), prod_eq(description));&lt;br /&gt;	if(f == p.end() ){&lt;br /&gt;		ret_val = true;&lt;br /&gt;	}&lt;br /&gt;	else{&lt;br /&gt;		cerr &amp;lt;&amp;lt; &amp;quot;That Product already exists in the database: &amp;quot;&amp;lt;&amp;lt; description &amp;lt;&amp;lt; endl;&lt;br /&gt;		cerr &amp;lt;&amp;lt; &amp;quot;Please try again...&amp;quot; &amp;lt;&amp;lt; endl &amp;lt;&amp;lt; endl;&lt;br /&gt;	}    &lt;br /&gt;&lt;br /&gt;	return ret_val;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;///////////////////////// &lt;br /&gt;/// &amp;#092;fn do_prod_quantity( product&amp;amp; p )&lt;br /&gt;/// &amp;#092;brief Handles getting and checking the product quantity &lt;br /&gt;/// &lt;br /&gt;/// &amp;#092;b SideEffects: None&amp;#092;n &lt;br /&gt;/// &amp;#092;b Output: None&amp;#092;n&lt;br /&gt;/// &lt;br /&gt;/// &amp;#092;param p - product structure for storage of data&lt;br /&gt;/// &amp;#092;return none &lt;br /&gt;///////////////////////// &lt;br /&gt;void do_prod_quantity( product&amp;amp; p )&lt;br /&gt;{&lt;br /&gt;	do&lt;br /&gt;	{&lt;br /&gt;		get_prod_quantity( p );&lt;br /&gt;	}while(&amp;#33;is_valid_quantity( p.quantity, (unsigned int)numeric_limits&amp;lt;unsigned int&amp;gt;::min(), (unsigned int)numeric_limits&amp;lt;unsigned int&amp;gt;::max() ));&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;///////////////////////// &lt;br /&gt;/// &amp;#092;fn get_prod_quantity( product&amp;amp; p )&lt;br /&gt;/// &amp;#092;brief Gets the Products quantity &lt;br /&gt;/// &lt;br /&gt;/// &amp;#092;b SideEffects: None&amp;#092;n &lt;br /&gt;/// &amp;#092;b Output: Prompts user to enter product quantity&amp;#092;n&lt;br /&gt;/// &lt;br /&gt;/// &amp;#092;param p - product structure for storage of data&lt;br /&gt;/// &amp;#092;return none &lt;br /&gt;///////////////////////// &lt;br /&gt;void get_prod_quantity( product&amp;amp; p )&lt;br /&gt;{&lt;br /&gt;	stringstream sTemp;&lt;br /&gt;	&lt;br /&gt;	sTemp &amp;lt;&amp;lt; get_string(&amp;quot;Enter product&amp;#39;s quantity on hand: &amp;quot;, maxStringSize);&lt;br /&gt;	sTemp &amp;gt;&amp;gt; p.quantity;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;///////////////////////// &lt;br /&gt;/// &amp;#092;fn is_valid_quantity( int quantity, const unsigned int min, const unsigned int max )&lt;br /&gt;/// &amp;#092;brief Checks to see if product quantity is valid &lt;br /&gt;/// &lt;br /&gt;/// &amp;#092;b SideEffects: None&amp;#092;n &lt;br /&gt;/// &amp;#092;b Output: Error message if quantity is invalid&amp;#092;n&lt;br /&gt;///&lt;br /&gt;/// &amp;#092;param quantity - current product quantity to check validity of&lt;br /&gt;/// &amp;#092;param min - minimum acceptable value&lt;br /&gt;/// &amp;#092;param max - maximum acceptable value&lt;br /&gt;/// &lt;br /&gt;/// &amp;#092;return ret_val - boolean true if quantity is valid and false otherwise &lt;br /&gt;///////////////////////// &lt;br /&gt;bool is_valid_quantity( int quantity, const unsigned int min, const unsigned int max )&lt;br /&gt;{&lt;br /&gt;	bool ret_val = false;&lt;br /&gt;&lt;br /&gt;	if( (quantity &amp;gt; (int)min) &amp;amp;&amp;amp; ((unsigned int)quantity &amp;lt; max) ){&lt;br /&gt;		ret_val = true;&lt;br /&gt;	}&lt;br /&gt;	else{&lt;br /&gt;		cerr &amp;lt;&amp;lt; &amp;quot;Error: Number entered must be between &amp;quot; &amp;lt;&amp;lt; min &amp;lt;&amp;lt; &amp;quot; and &amp;quot; &amp;lt;&amp;lt; max &amp;lt;&amp;lt; endl;&lt;br /&gt;	}&lt;br /&gt;&lt;br /&gt;	return ret_val;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;///////////////////////// &lt;br /&gt;/// &amp;#092;fn do_prod_cost( product&amp;amp; p, unsigned int type )&lt;br /&gt;/// &amp;#092;brief Handles getting and checking the product cost &lt;br /&gt;/// &lt;br /&gt;/// &amp;#092;b SideEffects: None&amp;#092;n &lt;br /&gt;/// &amp;#092;b Output: None&amp;#092;n&lt;br /&gt;/// &lt;br /&gt;/// &amp;#092;param p - product structure for storage of data&lt;br /&gt;/// &amp;#092;return none &lt;br /&gt;///////////////////////// &lt;br /&gt;void do_prod_cost( product&amp;amp; p, unsigned int type )&lt;br /&gt;{&lt;br /&gt;	if( type == 1 )&lt;br /&gt;		do{&lt;br /&gt;			get_prod_cost( p, type, &amp;quot;Enter product&amp;#39;s wholesale price: &amp;quot; );&lt;br /&gt;		}while(&amp;#33;is_valid_cost( p.wholesale, (double)numeric_limits&amp;lt;double&amp;gt;::min(), (double)numeric_limits&amp;lt;double&amp;gt;::max() ));&lt;br /&gt;	else&lt;br /&gt;		do{&lt;br /&gt;			get_prod_cost( p, type, &amp;quot;Enter product&amp;#39;s retail price: &amp;quot; );&lt;br /&gt;		}while(&amp;#33;is_valid_cost( p.retail, p.wholesale, (double)numeric_limits&amp;lt;double&amp;gt;::max() ));&lt;br /&gt;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;///////////////////////// &lt;br /&gt;/// &amp;#092;fn get_prod_cost( product&amp;amp; p )&lt;br /&gt;/// &amp;#092;brief Gets the Products cost &lt;br /&gt;/// &lt;br /&gt;/// &amp;#092;b SideEffects: None&amp;#092;n &lt;br /&gt;/// &amp;#092;b Output: Prompts user to enter product cost&amp;#092;n&lt;br /&gt;/// &lt;br /&gt;/// &amp;#092;param p - product structure for storage of data&lt;br /&gt;/// &amp;#092;return none &lt;br /&gt;///////////////////////// &lt;br /&gt;void get_prod_cost( product&amp;amp; p, unsigned int type, const string&amp;amp; prompt )&lt;br /&gt;{&lt;br /&gt;	stringstream sTmp;&lt;br /&gt;	&lt;br /&gt;	sTmp &amp;lt;&amp;lt; get_string(prompt, maxStringSize);&lt;br /&gt;	&lt;br /&gt;	switch( type )&lt;br /&gt;	{&lt;br /&gt;		case 1:&lt;br /&gt;				sTmp &amp;gt;&amp;gt; p.wholesale;&lt;br /&gt;				break;&lt;br /&gt;		default:&lt;br /&gt;				sTmp &amp;gt;&amp;gt; p.retail;&lt;br /&gt;				break;&lt;br /&gt;	}&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;///////////////////////// &lt;br /&gt;/// &amp;#092;fn is_valid_cost( double cost, const double min, const double max )&lt;br /&gt;/// &amp;#092;brief Checks to see if product cost is valid &lt;br /&gt;/// &lt;br /&gt;/// &amp;#092;b SideEffects: None&amp;#092;n &lt;br /&gt;/// &amp;#092;b Output: Error message if cost is invalid&amp;#092;n&lt;br /&gt;///&lt;br /&gt;/// &amp;#092;param cost - current product cost to check validity of&lt;br /&gt;/// &amp;#092;param min - minimum allowable product cost&lt;br /&gt;/// &amp;#092;param max - maximum allowable product cost&lt;br /&gt;/// &lt;br /&gt;/// &amp;#092;return ret_val - boolean true if cost is valid and false otherwise &lt;br /&gt;///////////////////////// &lt;br /&gt;bool is_valid_cost( double cost, const double min, const double max )&lt;br /&gt;{&lt;br /&gt;	bool ret_val = false;&lt;br /&gt;	unsigned long int ulInt = 0;&lt;br /&gt;	long int slInt = 0;&lt;br /&gt;&lt;br /&gt;	ulInt = (unsigned long int)(cost * 100);&lt;br /&gt;	slInt = (long int)(cost * 100);&lt;br /&gt;&lt;br /&gt;	if (ulInt == slInt &amp;amp;&amp;amp; ulInt &amp;gt; (unsigned long int)(min*100) &amp;amp;&amp;amp; (long int)ulInt &amp;lt; (max*100)){&lt;br /&gt;		ret_val = true;&lt;br /&gt;	}&lt;br /&gt;	else&lt;br /&gt;		cerr &amp;lt;&amp;lt; &amp;quot;Cost should be greater than &amp;quot; &amp;lt;&amp;lt; min &amp;lt;&amp;lt; &amp;quot; and less than &amp;quot; &amp;lt;&amp;lt; max &amp;lt;&amp;lt; endl;&lt;br /&gt;&lt;br /&gt;	return ret_val;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;///////////////////////// &lt;br /&gt;/// &amp;#092;fn do_prod_date_added( product&amp;amp; p )&lt;br /&gt;/// &amp;#092;brief Handles getting and checking the product date added &lt;br /&gt;/// &lt;br /&gt;/// &amp;#092;b SideEffects: None&amp;#092;n &lt;br /&gt;/// &amp;#092;b Output: None&amp;#092;n&lt;br /&gt;/// &lt;br /&gt;/// &amp;#092;param p - product structure for storage of data&lt;br /&gt;/// &amp;#092;return none &lt;br /&gt;///////////////////////// &lt;br /&gt;void do_prod_date_added( product&amp;amp; p )&lt;br /&gt;{&lt;br /&gt;	do{&lt;br /&gt;		get_prod_date_added( p );	&lt;br /&gt;	}while(&amp;#33;p.date_added-&amp;gt;is_valid());&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;///////////////////////// &lt;br /&gt;/// &amp;#092;fn get_prod_date_added( product&amp;amp; p )&lt;br /&gt;/// &amp;#092;brief Gets the Products date added &lt;br /&gt;/// &lt;br /&gt;/// &amp;#092;b SideEffects: None&amp;#092;n &lt;br /&gt;/// &amp;#092;b Output: Prompts user to enter product date added&amp;#092;n&lt;br /&gt;/// &lt;br /&gt;/// &amp;#092;param p - product structure for storage of data&lt;br /&gt;/// &amp;#092;return none &lt;br /&gt;///////////////////////// &lt;br /&gt;void get_prod_date_added( product&amp;amp; p )&lt;br /&gt;{&lt;br /&gt;	string sDate;&lt;br /&gt;	&lt;br /&gt;	sDate = get_string(&amp;quot;Enter the date item was added to inventory (MM/DD/YYYY): &amp;quot;, maxStringSize);&lt;br /&gt;	p.date_added = new Date( sDate );&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;//////////////////////// &lt;br /&gt;/// &amp;#092;fn create_product( vector&amp;lt;product&amp;gt;&amp;amp; p )&lt;br /&gt;/// &amp;#092;brief Gets new product data &lt;br /&gt;/// &lt;br /&gt;/// &amp;#092;b SideEffects: None&amp;#092;n &lt;br /&gt;/// &amp;#092;b Output: Prompts user to enter data for new product&amp;#092;n&lt;br /&gt;/// &lt;br /&gt;/// &amp;#092;param p - vector of product structures for storage of data&lt;br /&gt;/// &amp;#092;return none &lt;br /&gt;///////////////////////// &lt;br /&gt;void create_product( vector&amp;lt;product&amp;gt;&amp;amp; p )&lt;br /&gt;{&lt;br /&gt;	product* pProd = new( product );&lt;br /&gt;	product&amp;amp; rfProd = *pProd;&lt;br /&gt;&lt;br /&gt;	do_prod_descript( p, rfProd );&lt;br /&gt;	do_prod_quantity( rfProd );&lt;br /&gt;	do_prod_cost( rfProd, PRD_TYPE_WHOLESALE );&lt;br /&gt;	do_prod_cost( rfProd, PRD_TYPE_RETAIL );&lt;br /&gt;	do_prod_date_added( rfProd );&lt;br /&gt;	gen_id( rfProd );&lt;br /&gt;	p.push_back( *pProd );&lt;br /&gt;&lt;br /&gt;	delete pProd;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;///////////////////////// &lt;br /&gt;/// &amp;#092;fn show_product( const product&amp;amp; p )&lt;br /&gt;/// &amp;#092;brief Shows product record&lt;br /&gt;/// &lt;br /&gt;/// &amp;#092;b SideEffects: None&amp;#092;n &lt;br /&gt;/// &amp;#092;b Output: Displays information for the product&amp;#092;n&lt;br /&gt;/// &lt;br /&gt;/// &amp;#092;param p - const product structure&lt;br /&gt;/// &amp;#092;return none &lt;br /&gt;///////////////////////// &lt;br /&gt;void show_product( const product&amp;amp; p )&lt;br /&gt;{&lt;br /&gt;    cout &amp;lt;&amp;lt; endl &amp;lt;&amp;lt; endl;&lt;br /&gt;	cout &amp;lt;&amp;lt; &amp;quot;Your product id is: &amp;quot; &amp;lt;&amp;lt; p.id &amp;lt;&amp;lt; endl;&lt;br /&gt;	cout &amp;lt;&amp;lt; &amp;quot;Description: &amp;quot; &amp;lt;&amp;lt; p.description &amp;lt;&amp;lt; endl;&lt;br /&gt;	cout &amp;lt;&amp;lt; &amp;quot;Quantity on Hand: &amp;quot; &amp;lt;&amp;lt; p.quantity &amp;lt;&amp;lt; endl;&lt;br /&gt;	cout &amp;lt;&amp;lt; &amp;quot;Retail Cost: &amp;quot; &amp;lt;&amp;lt; p.retail &amp;lt;&amp;lt; endl;&lt;br /&gt;	cout &amp;lt;&amp;lt; &amp;quot;Wholesale Cost: &amp;quot; &amp;lt;&amp;lt; p.wholesale &amp;lt;&amp;lt; endl;&lt;br /&gt;	cout &amp;lt;&amp;lt; &amp;quot;Date Added: &amp;quot; &amp;lt;&amp;lt; p.date_added-&amp;gt;get() &amp;lt;&amp;lt; endl &amp;lt;&amp;lt; endl;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;///////////////////////// &lt;br /&gt;/// &amp;#092;fn istream&amp;amp; operator&amp;gt;&amp;gt;( istream&amp;amp; is, product&amp;amp; element )&lt;br /&gt;/// &amp;#092;brief Friend operator for extracting a tab delimited product&lt;br /&gt;///  from the stream&lt;br /&gt;/// &lt;br /&gt;/// &amp;#092;b SideEffects: None&amp;#092;n &lt;br /&gt;/// &amp;#092;b Output: None&amp;#092;n&lt;br /&gt;/// &lt;br /&gt;/// &amp;#092;param is - input stream &lt;br /&gt;/// &amp;#092;param element - product structure to fill from stream&lt;br /&gt;/// &amp;#092;return istream&amp;amp; is &lt;br /&gt;///////////////////////// &lt;br /&gt;std::istream&amp;amp; operator &amp;gt;&amp;gt;( istream&amp;amp; is, product&amp;amp; element )&lt;br /&gt;{&lt;br /&gt;    char buffer[maxStringSize];&lt;br /&gt;    unsigned int fieldCnt = 0;&lt;br /&gt;&lt;br /&gt;    while(is &amp;amp;&amp;amp; fieldCnt &amp;lt; REC_FIELD_COUNT )&lt;br /&gt;    {&lt;br /&gt;	    is.getline(buffer,(streamsize)maxStringSize, &amp;#39;&amp;#092;t&amp;#39;);&lt;br /&gt;	    if(is)&lt;br /&gt;	    {&lt;br /&gt;		    switch( fieldCnt )&lt;br /&gt;		    {&lt;br /&gt;			    case 0: element.id = buffer; ++fieldCnt; break;&lt;br /&gt;			    case 1: element.description = buffer; ++fieldCnt; break;&lt;br /&gt;			    case 2: element.quantity = ioConv&amp;lt;int&amp;gt;(buffer); ++fieldCnt; break;&lt;br /&gt;			    case 3: element.retail = ioConv&amp;lt;double&amp;gt;(buffer); ++fieldCnt; break;&lt;br /&gt;			    case 4: element.wholesale = ioConv&amp;lt;double&amp;gt;(buffer); ++fieldCnt; break;&lt;br /&gt;			    default:&lt;br /&gt;                    element.date_added = new Date();&lt;br /&gt;				    element.date_added-&amp;gt;set(buffer, &amp;quot;/&amp;quot;);&lt;br /&gt;                    ++fieldCnt;&lt;br /&gt;                    break;&lt;br /&gt;		    }&lt;br /&gt;	    }&lt;br /&gt;    }&lt;br /&gt;    return is;&lt;br /&gt;}&lt;br /&gt;[/code]&lt;br /&gt;&lt;br /&gt;&lt;!--sizec--&gt;&lt;/span&gt;&lt;!--/sizec--&gt;&lt;!--fontc--&gt;&lt;/span&gt;&lt;!--/fontc--&gt;</description>
			<pubDate>Sat, 10 Oct 2009 04:05:07 -0500</pubDate>
			<category>C++ Tutorials</category>
			<author>jwwicks</author>
         </item>
   </channel>
</rss>
