Freelance Writing Jobs | Today's Articles | Sign In

 

Guy Lecky-Thompson's Blog

Dec 15, 2006

Posted by Guy Lecky-Thompson

Intercepting Windows messages is always fun. Some programs, such as WinSpy can look at any message queue for any application. However, this is only useful in debugging. More useful is the possibility to pull messages off your own thread (windows associated with it), and take a sneak preview of them before they are actually processed.

For example, they can be used to change the appearance of the application if a mouse cursor moves into a hot spot, or to aid in computer based training applications. They can even be used to trap screen updates and other interesting system events.

The article can be found at:

computerprogramming.suite101.com/article.cfm/intercepting_messages_in_win32




Dec 8, 2006

Posted by Guy Lecky-Thompson

I discovered that the conditional sum plug-in for Microsoft Excel does not always do what I want. It fails to behave exactly as I expected, and since the help files were not very illuminating, I decided to make my own solution in Visual Basic for Applications.

It turned out that this solution required that I relearn how to build VBA macros in Microsoft Excel, as well as creating a reasonably flexible implementation. Being a good exercise for non-programmers and programmers prototyping algorithms and applications, I thought I'd share it with you.

The premise is that I needed to sum rows of data conditionally, based on the contents of those rows. One cell was the number to be added to the rolling sum, and the other three or four cells were used to decide whether or not to update the total or not.

The crunch was that the Active Sheet contained the source data for making those decisions. So, each cell had to contain a total that was conditionally arrived at by examining neighboring cells (luckily fixed as the first cell in the row, and column headings). To cap it all, only certain areas of the Active Sheet needed to be updated, so the user had to be queried at the start of the process.

I'll give an example:

The Active Sheet contains (let's say) fruits down the left hand side – 'Apples', 'Oranges', 'Pears' and so on. The column headings give sizes of the fruits – 'Small', 'Medium', 'Large' and so on. The Data sheet contains sales entries – the date, number, type and size.

If we want to sum sales entries for all the small, medium, and large apples, from a list of varying entries, using Excel, I found it best to use a VBA macro. Conditional sum doesn't work, for a variety of reasons.

The solution to this is explained in computerprogramming.suite101.com/article.cfm/starting_with_vba_for_ms_excel. Have fun!




Dec 1, 2006

Posted by Guy Lecky-Thompson

I notice in my search stats that readers have been looking for string token handling, and general calls to string.h, part of the standard C header files.

Since I've vowed to act on this kind of information, I decided to write a little piece about the strtok function. This can be used to tokenize strings in C, and is really quite handy. Not without it's caveats, however, principlally in the area of memory management.

If anyone has a nicer strtok implementation, that behaves in a similar fashion, but is somehow safer to use, then let me know. The article, by the way, looks at a very simple CSV cracker; this has to be one of the most common uses for strtok, so that's always a good place to start.

Here's the link. Enjoy!

String Tokenizing in C Programming




Nov 24, 2006

Posted by Guy Lecky-Thompson

You'd have thought it would be reasonably easy to supply curses emulation under DOS, wouldn't you. Surprise!! It's not.

Ok, so what's curses? It's a nice library added to Unix (Linux, Minix & HP-UX for all I know) that enables you to play with the mouse and screen. Make windows, change the color of text, that kind of thing.

In BASIC days, it used to be really easy, but it seems that the more powerful a system becomes, the harder it is to actually program it. Hence, adding colored text, windows and mouse support to plain old command line Unix becomes a complex interaction between libararies, direct hardware manipulation, and so on.

Which means that porting to DOS is easy for those who know how, but has resulted in something that I persoanlly find quite hard to fathom. For all of you wanting to follow the examples in the Understanding Unix Curses article you'll need to find a curses library for your compiler.

I'll post the ones I find as comments below, but feel free to add your own.

In the mentime, happy cursing!




Nov 10, 2006

Posted by Guy Lecky-Thompson

I've been really busy. On the one hand I've been evaluating a new programming language implementation. Well, it was new for me; I gather that BB4W (BBC BASIC for Windows) has been around for a while. The review can be found on these very pages (permanent link : computerprogramming.suite101.com/article.cfm/bbc_basic_for_windows_programming), and you can expect a tutorial set to follow in the weeks to come, as I get more proficient with this excellent tool.

The short version - it is the easiest way to get into programming; be it command line, graphical, or GUI (Windows) programming. For those of you dying to service lucrative RentACoder contracts, it could be your entry into the field of contract programming - at least for building proof of concept prototypes.

For real work, though, C will still be one of the languages of choice, and I'm proud to present, as a footnote here, my new book 'Just Enough C'. I finally got around to finishing it. Anyone who would like a free PDF version can have one, just so long as they promise to send me feedback.

Email computerprogramming@suite101.com for a copy.





;