Comment/Uncomment code to switch versions quickly without using macros

In a typical day, I write or debug programs in several languages: typically Foxpro, C#, VB, C++ and 32 bit assembly, with an occasional MSIL, IDL and 64 bit ASM thrown in.   Sometimes, I like to switch between one version of code and another. This is useful if I want to do side by…

7

Cartoon animation program

A cartoon can be thought of as a series of drawings. To simulate movement, the drawings can be slightly different from each other.   Remember drawing simple cartoons using a pad of paper? Simply flipping through the pages made the drawings come to life.   This was tedious work: a computer can help.   Just…

16

Overload Operator new to detect memory leaks

There are various leak detection methods for memory allocators. A popular one is to tag each allocation with some information about the caller. When there’s a memory leak, you just need to look at that tag info to find the line of code that allocated the memory.   However, this requires that the caller pass…

5

Make your code more maintainable: The evils of the Return statement

What does it mean to make code more maintainable? Certainly obfuscated code is hard to understand, by definition.   A big part of maintainability is making it easier for others to read and understand what the code is doing. Your code may have been working for years, but then somebody comes along and wants to…

9

Use a dictionary to help create a mnemonic

I was using a program that was yet another TLA and I wanted to create a mnemonic to help me remember what it was. One of the letters was “k”, so I wanted to find a word that starts with “k”   Simple: load a dictionary, search for words starting with “k” and browse through…

2

How fast is interop code?

How fast is interop code? If you’re in one kind of code and your calling another, what is the cost of the interop?   For example, .Net code can call native C++ code (like Windows APIs) and vice versa. Similarly with Foxpro and C++ code. .Net code is often referred to as Managed code because…

22

How to interrupt your code

I received a question:     Simply, is there a way of interrupting a vfp sql query once it has started short of closing down the process ? I am running some complex queries on very large datasets which can sometimes take many minutes to complete.     Typically, a program that runs on your…

6

Examine .Net Memory Leaks

Writing programs using .Net is very productive. One reason is because much of memory management is “managed” for you. In C, C++ and other “native” languages, if you allocate memory, you’re responsible for freeing it.  There were stopgap measures, like destructors, SmartPointers and reference counting, which helped, but were still cumbersome.   Foxpro manages memory…

8

Persist user form size and location settings per session

My prior post (Create your own Test Host using XAML to run your unit tests) shows how to create a form and present it to the user. The user can resize and reposition the form, even on a 2nd monitor.   When the user exits the form, we can persist or remember the form size…

1

Create your own Test Host using XAML to run your unit tests

A few days ago, somebody came into my office and plopped down a box. It seemed very light. He said that it was a new PC. I thought hmmm…. The box seems empty…Why am I getting a new PC?. Apparently an inventory was made and my current hardware was at the lower end of the…

8