Wrox Programmer Forums
|
BOOK: Ivor Horton's Beginning Visual C++ 2010
This is the forum to discuss the Wrox book Ivor Horton's Beginning Visual C++ 2010 by Ivor Horton; ISBN: 9780470500880
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Ivor Horton's Beginning Visual C++ 2010 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old July 23rd, 2012, 11:53 PM
Authorized User
 
Join Date: May 2012
Posts: 66
Thanks: 0
Thanked 4 Times in 4 Posts
Default

Hi com64,

You're welcome. I am happy to be of assistance.

I have been surprised on a regular basis when I poke around in different areas of Windows and some of the programs I have installed on my various machines. There are quite a few features which are unknown to most users.

I am not quite sure I understand what you are attempting to do with the interfaces. Are you writing your own custom drivers?

regards,
drpepper
 
Old August 5th, 2012, 12:30 AM
Authorized User
 
Join Date: Jun 2012
Posts: 13
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Dear drpepper,

I thought I had a small win in receiving the Arduino board but that turned into a nightmare. The communication with the computer is erratic for the least with long periods being OK and longer periods with absolutely no way to make them talk to each other. Pity the system uses C++ to program the board and has great potential. I have been to their forums and unfortunately I am not the only one having the same problem.

Going back to the “Book”, it is more rewarding there. I did try to have the Line Numbers (Tools Options ->Fonts and Colors) but here I cannot implement the Line numbers. No big deal but when there is an error showing the line number it would help to have those numbers instead of having to count the lines. Have you been able to have the line numbers?

Following the “Book”, I did write and run several programs:
Ex3_05 (switch, page 135)
Ex3_06 (case, page 137)
Ex3_07 (loop, page 139)
And in each case, I had to add a line to hold the display:
cin >> xx ;
xx being one of variables already declared, so I did not have to declare a new variable ...(Lazy)
Did you need to add the same line in order to hold the display on the console?

Thank you, best regards

com64
 
Old August 5th, 2012, 08:05 AM
Authorized User
 
Join Date: May 2012
Posts: 66
Thanks: 0
Thanked 4 Times in 4 Posts
Default

Hi com64,

It is good to hear from you again. I am sorry to hear that you are experiencing problems with your project. My best guess is that the other forums you have visited are not populated with software engineers and developers, and that is the reason that you are finding no problem resolution. I will address line numbers and your current example code in the later portion of this reply.

I believe that I may understand part of the hurdles in front of you. (The key word here is may.) Bear with me because my explanation deals with the basics, not specifics. For the purpose of this explanation define basics as "how Windows works" and specifics as "what does the code look like". I really believe that this topic is graduate level programming --> far beyond what you and I are capable of right now in C++.

First and foremost Windows is written in a combination of C and C++; therefore, C++ is an appropriate language to use. Software and hardware drivers are written in either Assembly or C/C++. C++ does include the facility to embed Assembly code in a C++ program, but I am thinking that would make the code platform specific. My research of programming language history leads me to believe that both C and C++ were developed to facilitate cross-platform implementation of code. Editing or rewriting code from scratch to make it stable on different platforms is prohibitive.

The Windows operating systems do not directly execute code. Dynamic link libraries (dll) are used to automatically execute code. At my current level of understanding manually launching and executable file will not provide you with the results you desire because the various Windows processes (like svchost, for example) cannot provide dynamic, real time access to the code. I believe attempting to manually launch the code will result in either improper operation or crashes.

Because the specifics are beyond my knowledge base at present, the following is speculation based upon logical analysis of what I do understand. I believe that you may find it necessary to use one of the following to implement your code: .msi, .ini, or ,inf files.

You are modifying the Registry when using these files. Mistakes can result in a totally wrecked (bricked) operating system. Attempting to restore the computer using a System Restore point or a registry backup (like ERUNT) may not work for non-fatal errors. The safest method to attempt to install and debug programs like the one you wish to write is to mount a virtual machine (VM), and do your work within the VM until you are satisfied with the results. The VM protects the operating system from catastrophic failures. The VM can be restored from a snapshot much quicker and easier than reinstalling your operating system.

My complete ignorance of hardware interfaces leaves me with a big question. Do you need to know anything about compatible and incompatible ports? If so, you may need to research the ports available.

Let's move on to an answer you can take to the bank. Line numbers can be included in both the text editor and in printed code. I really like to have a hard copy to examine. The hard copy allows me to scribble, highlight, you name it during the debugging process before typing any corrections.

in the text editor:
Navigate tools> options> text editor> all languages> general. In the right pane under display, tick the line numbers box. Click OK.

for printed code:
Navigate file> print. In the window that opens, find print what. Check the box for include line numbers.

one more trick:
When you encounter a compiler error, you can double click the error in the output pane. Visual C++ will take you to the line of code with a cursor shown on the far left side of the test editor.

I have experienced no problems with the examples you asked about. Your problems with the console window are hard to address without seeing your code or know the method you use to open a new project. I can tell you what I do. That may make it unnecessary for your to post your code.

First I print the code and compare it to the book example, making corrections where I find errors. Some of the exercises have required modifications, but not the ones you listed.

My method for opening a new project is not exactly what the book recommends. I use methods I learned in my intro to programming class plus book instructions. Using the methods I list here resolved problems I encountered in some of the early book example code.

instructions not included in the book:
To begin with, navigate tools> settings. Check expert settings. You only have to do this once.

When opening a new Win32 project, do this every time.
  • file> new> project
  • After entering all info in the window and clicking OK, a new window opens.
  • Click next, not finish.
  • Choose console application and empty project.
  • Click finish.
  • Your work space opens.

continue with instructions form the book:
  • Right click source files.
  • Choose add and new item.
  • A window opens.
  • Choose C++ File (.cpp) and name it.
  • Click add.
Go back to the left pane.
  • Right click the first bold entry, and choose properies.
  • In the right pane under project defaults, find character set.
  • Click the right column, and you will see a down arrow.
  • Click the down arrow amd choose not set.
  • Click OK.

Try the steps I use for new project t see if it resolves your window open problem. If it does not, post you code for my examination.

A quick heads-up for you --> In about a week and a half I will be starting classes in a new semester. I have loaded myself pretty heavy and may not be able to provide timely replies. Be patient. I will reply as time allows.

regards,
drpepper

Last edited by drpepper; August 5th, 2012 at 08:10 AM..
 
Old August 11th, 2012, 03:00 AM
Authorized User
 
Join Date: Jun 2012
Posts: 13
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Dear drpepper,

Thank you for your last posting. For some reasons, I received it as an email but could not read it on the Forum.

Thank you for all the tips and information. I did print them and will keep them as reference. I understand you will be busy very shortly.

I had some fun and frustration with the Arduino board. Sometimes there was no communication between the computer and the board (COM8). Lots of users also had problems as the Forums are full of requests for advice. Programming is very much like “classic” C++. But the programs are not programs as such as they do not have “main()”, they are called “sketches” and in fact are just a series of commands written in C++ for the board. When successfully compiled and ‘uploaded’ on the board, the sketch can run autonomously (if the board is powered, of course), without the computer. Lots of potential. Also a great help and incentive to learn all the details of C++. I use it with a breadboard . At the moment, I only switch LEDs, etc, looking a bit childish but more will come.

Wishing you good luck for the new semester.

Best regards

com64
 
Old August 11th, 2012, 12:11 PM
Authorized User
 
Join Date: May 2012
Posts: 66
Thanks: 0
Thanked 4 Times in 4 Posts
Default

com64,

Thanks for the well wishes. Please do not let the fact that school will keep me busy prevent you from continuing to keep me up to date with your progress. I can learn from providing answers and hearing about your progress. I am putting "the Book" on hold for now. My course load will include learning a new operating system (Linux), a new programming language (XHTML), and a prep course for Comp TIA A+ certification. It amounts to the the equivalent of 12 semester hours because one of the courses is presented in an eight week session as opposed to the standard sixteen week semester.

I have installed a virtual machine (VM) and am attempting to get a Linux version running on it in prep for one of the classes. Using a VM is a new experience for me. It is really cool. If you have time, you may wish to get some experience with using VMs.

I am allowing my engineering mindset (How does it work? Why does it work? What are the limitations? Can it be modified?) take over here. Your description of uploading code and the board running autonomously without the computer makes me wonder about a couple of things.

How is the board designed? Does it have some sort of volatile memory like RAM which holds instructions and executes them until power is interrupted? Alternately does the board retain memory after powering off and only require an instruction set to enable it again?

From the programming standpoint:

Does any of the code depend upon the Standard Template Library (STL) or any of the libraries or headers which the code uses via #include or define commands? If so, you may find it necessary to find a method to export them with the code when "uploading" to the board.

It is possible that the proper use of classes, inheritance, polymorphism, and overloading may be necessary.

Since the "sketches" are independent of the computer, you may be dealing with embedding. Some research of the hows and whys of embedding may provide insight for you.

As for the "childish" nature, as you call it, that is a necessary component of learning. Take a close look at how trivial the programs in the book are. They are intended to provide an understanding of how things work, which is an excellent foundation for more advanced projects.

Take the time to dissect the code you have already written using pencil and paper to "play computer" with the code and reason out every line of code. Oftentimes you can uncover a logical error which unveils the source of undesired results.

Best of luck to you. Please keep me informed.

regards,
drpepper
 
Old August 11th, 2012, 10:11 PM
Authorized User
 
Join Date: Jun 2012
Posts: 13
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Dear drpepper,

Thank you for your reply. I see you are going to be very busy with the Comp TIA A+ Certification and XHTML. I have never tried XHTML. The garden variety of HTML plus PHP and MySql filling my internet needs, including publishing a Database on the Net.

I did try Linux but I had to give up, I could not get the results I did expected. At the time, I was looking for a replacement for GWBasic and I tried Gambas on Umbutu. Perhaps I did not try hard enough…

To answer your questions on the Arduino board, there is a memory on the board that keeps the sketch. The commands are not lost when the computer is disconnected and when the power is removed and as soon as some outside power is restored, whatever is in the sketch starts to run again. I think the C++ that is available in the running software contains a lots of specific ‘dll’ as some of the syntax is not (as far as I can see) standard C++ syntax. With commands like:
pinMode, digitalRead, digitalWrite, delay, etc.

I think this little board will allow me to do things I could not do before, thinking of ‘hardware’ solutions when they can now be done easily with ‘soft’ solutions. Great fun ahead. I plan to add to it a Real Time Clock, so I could use the ‘time.h’ without using the computer clock.

Regards

com 64
 
Old August 12th, 2012, 12:19 AM
Authorized User
 
Join Date: May 2012
Posts: 66
Thanks: 0
Thanked 4 Times in 4 Posts
Default

com64,

It looks like you have some fun ahead of you. After mastering the concepts in this book, you may wish to check out Programming Principles and Practice Using C++ by Bjarne Stroustrup. (Stroustrup is the author of C++.) The book includes a little over 50 pages on embedded systems.

Keep me updated. ... As always I am available to help with whatever is within the universe of my exposure to computer stuff.

regards,
drpepper





Similar Threads
Thread Thread Starter Forum Replies Last Post
Date Time Field not displaying Date and Time webmeister Access 2 January 31st, 2011 12:49 AM
Extracting Time from Date/Time Navy1991_1 XSLT 2 June 3rd, 2008 12:03 PM
date and time in EST time zone anboss XSLT 1 May 21st, 2008 01:42 PM
How to retieve only the date not date and time debjanib ASP.NET 1.0 and 1.1 Professional 2 July 25th, 2006 01:10 PM
insert system date. no date and time jimmy Access VBA 6 November 20th, 2003 01:11 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.