Category Archives: C++ programming

Van Winkle’s Bridge

I had a miserable holiday season. I was busy trying the Rip Van Winkle approach to learning programming, and not accomplishing much. The further I got in to Petzold, the more the behavior of programs diverged from what was described in the text. The programs would compile….but they wouldn’t work. The C language, the compilers (Visual Developer) and Windows itself have all changed since 1999, and the preconditions and and postconditions for Windows function calls that worked in the original, and those that apply now have changed in ways that I don’t have the resources to follow. And that’s if I haven’t committed any typos in entering the programs.

Although many beginning programmer’s texts start with a command-line approach, they don’t facilitate a transition to the Windows environment. I’ve finally found one that does: “Introduction to Windows and Graphics Programming With Visual C++”. by Roger Mayne. This looks like the bridge I have been looking for.

We’ll see how this goes.

One piece at a time

Like the old Johnny Cash song. My attempts to work through Petzold are hitting snags, because there have been changes to Windows since he wrote the book, and the programs as written don’t work anymore. I don’t have an instructor or a decent guide to the complexities. I have finished the first eight chapters, about a quarter of the way through the book, which I still think is respectable progress, although I had hoped for more.

Sapience Knowledge Explorer

I’ve been concentrating on getting my computer programming moving, still concentrating on the early chapters of Windows Programming. I’ve been spreading my efforts out over the first few chapters, since typing programs in is a boring activity and I like to shift my focus to create a little variety. I’m almost through the chapter on text input, well into the chapter on the mouse, and almost through the chapter on the timer. There’s a bug in the program that’s supposed to draw dots of an analog clock face, and I can’t quite figure it out. Also, I’ve found that Visual Studio 2015 is finicky and unforgiving about creating resources (*.rc files, for those in the know), and has different behavior than the earlier version Petzold used in his book, so the description in the book doesn’t quite match. Once I’ve reached the point where my programs can actually can read the keyboard, I will be in a position to begin integrating this with other textbooks.

I’ve also begun working on a Windows Version of a program I’ve been puttering about with for some time; the Sapience Knowledge Explorer. I had begun an old style Command line version and made considerable progress working through a couple of textbooks for examples when I set this aside. My intention is that by working through a Windows version, I can make it more commercial, or at least more useful.

So far it’s quite embryonic. It doesn’t do much besides ask if it’s OK to continue and displays a greeting message if not. But–it’s my own work, not copied or derived.

Rip Van Winkle

I’ve been away from attempts to program Windows for some 20 years, and it has almost, but not quite, entirely moved beyond me. I’ve mostly been copying in the sample programs, trying to get a handle on the most basic concepts of input and output. As before, I note that things that were easy in the console approach are much harder in Windows, and thing that were hard in the console approach are much easier in Windows. So far, I’m still in the “Basics” part of the book, but I’ve gotten sample programs in the first 10 chapters (after some debugging due to typos) to compile and run. I can’t say that I entirely understand what I’m doing, and I’m not yet doing much original programming, but I am making progress.

Playing with pebbles

Today I started adding stubs to the structure of matter section of physics. It’s important to get to these structure of matter stubs, because these are on the boundary between chemistry and physics, and will let me start to connect the two sciences.

I created a new ChemSubst class, which is supposed to be a parent class for ChemElement, but it has no detail yet.   I added a new function to my graphics Object class, and expanded a little development of Arithmetic.  I have added (but not yet tested) predecrement and postdecrement  operators for the Tiny Whole Numbers class, and an addition operator for Tiny Whole Numbers.  I want to rewrite the test driver functions to refer to Tiny Whole Numbers. I would also like to include a calculator program: I have done a version of this before and could do it again, but I need to get back to the books and continue the programming exercises.

 

Collision test

I finally sat down and worked through the collision test function of  physical systems. In the process, I discovered and fixed a few bugs and added a couple of desirable features, such as tweaking the display of objects and including reminders of which object in a system I am working with.  Before I can make much more progress in physics, I need to work on some mathematical functions, and go back to review of the programming texts.

Divided up

I got most of my basic physics functions divided up and separated out. Physics is divided into subfunctions: The first is mechanics, which deals with motion of bodies and its causes.  The simplest subdivision is particle mechanics which deals with particles in which internal motions and rotations are unimportant.  The simplest division of particle mechanics is mechanics, which deals with the motion of particles regardless of their causes. So far, Kinematics includes position and velocity. I want to include acceleration, but this requires more mathematics. The next division of particle mechanics is dynamics: The only function I have associated with this involves setting mass. This will eventually include considerations of momentum, impulse, and force.  Energetics will involve work and kinetic energy, which also needs more work in mathematics. Particle systems include my examination of collisions

Rigid-body mechanics, deformable body mechanics, and gravitation require better development of systems.  Thermodynamics, electromagnetism, and the structure of matter are present, but I still need fundamentals of mechanics.

Physics Systems Setup

I decided to concentrate my efforts on the setup of physical systems, and gather the procedures into functions that can be called from other places in the program. This should leave me free to concentrated on other parts of the program.  The next step will be to do the same for the procedures of mechanics.

Inch by inch

I have been throwing most of my limited energy into expanding the demonstration program.  Most of the functions I have in system setup are or need to be duplicated in other areas, mostly mechanics. Some of these can be distributed to specific areas of mechanics, and several developments belong specifically to particle mechanics.  I cannot make much progress in other sciences without a solid foundation in physics.

However, in order to make progress in physics, I need to make more progress in mathematics, so I am continuing to develop room for the tiny whole numbers, approximate arithmetic, and algebraic functions.

 

Slow going

I’ve had a hard time being able to concentrate on programming for the past few days.  I think I have resolved the naming problem, but in the physics section, the mechanics interface is still clunky. Moving a couple of the setup routines into distinct functions created some linker errors, because of the various assumptions involved, but I have those cleared up.  I also have stubs for three of the four primary subdivisions of mechanics, and I am ready to start including functions for thermodynamics, electromagnetism, and the structure of matter.  Chemical substances is set up to include more stubs, and so is Personal Studies.