Welcome To The Home Of The Visual FoxPro Experts  
home. signup. forum. archives. search. google. articles. downloads. faq. members. weblogs. file info. rss.
 From: Ken Murphy
  Where is Ken Murphy?
 Springhill
 Canada
 Ken Murphy
 To: Andy Kramek
  Where is Andy Kramek?
 Hot Springs Village
 Arkansas - United States
 Andy Kramek
 Tags
Subject: RE: #define versus assigning value to a public variable
Thread ID: 104562 Message ID: 104734 # Views: 2 # Ratings: 0
Version: Visual FoxPro 6 Category: Other
Date: Sunday, August 20, 2006 3:48:45 AM         
   


> > While debugging code I prefer to use variables and comments instead of #DEFINES any day. That way I can just hover my mouse over the code to see the actual value. With #Defines I have to look up the .h table or find out where the #DEFINE was defined to decipher the value.
> >
> > No #Defines anywhere in my code. Thank you.

>
> Nor mine - well apart from a couple of very special local ones - for instance I use #DEFINE CRLF for "CHR(13)+CHR(10)" so often that I have it set up in IntelliSense :)
>
> But ".h" files? Never! Nohow!
>
> I well remember spending about three hours (along with Marcia Akins, Steven Black and Alan Griver - imagine how much that little group cost the client!!) trying to find out why some previously working code had broken. We couldn't find what was wrong - kept getting a 'data type mismatch' error.
>
> Turned out that one of the "include" files referenced another and someone (who shall remain nameless) had "cleaned up the 'h' file" and inserted some definitions before the reference to the external file. Unfortunately one of these definitions relied on one that was only declared in the external file - hence the problem and hence the 12+ person-hour debug time!
>
> Regards
> Andy Kramek
> Microsoft MVP (Visual FoxPro)
> Tightline Computers Inc, Akron Ohio, USA


As a matter of preference, I will use #INCLUDE for things I absolutely KNOW are constants. I will use #DEFINE for CRLF, PI, LIGHTSPEED, etc. But it seems that there are actually very few things that remain constant. As soon as you decide that something should be a constant, you find out that it is actually quite variable. In my example to Dan, I showed him how I used to do mutiple languages - now I find that there are local variants. Parisian French isn't always the same as Quebec French - so I now need a third transalation, but only for certain things - so even languages are not constant.

The biggest problem that I have with #DEFINE is that you have to recompile. I don't want to have to send a user a new version of the app just because he calls "le camion" "le truck." I now use tables and if the user wants to change the caption of TruckLbl, I just update his LableCaptions table.

Ken
You shall know the truth - and the truth shall set you free. (John 8:33)

ENTIRE THREAD

#define versus assigning value to a public variable Posted by Dan Roche @ 8/17/2006 4:21:18 PM
RE: #define versus assigning value to a public variable Posted by Jim Winter @ 8/17/2006 4:40:56 PM
RE: #define versus assigning value to a public variable Posted by Brad Schulz @ 8/17/2006 5:53:53 PM
RE: #define versus assigning value to a public variable Posted by Ken Murphy @ 8/17/2006 6:03:43 PM
RE: #define versus assigning value to a public variable Posted by Dan Roche @ 8/17/2006 7:05:45 PM
RE: #define versus assigning value to a public variable Posted by Borislav Borissov @ 8/17/2006 7:40:52 PM
RE: #define versus assigning value to a public variable Posted by Andy Kramek @ 8/18/2006 11:58:15 AM
RE: #define versus assigning value to a public variable Posted by Borislav Borissov @ 8/18/2006 12:12:23 PM
RE: #define versus assigning value to a public variable Posted by Andy Kramek @ 8/18/2006 12:20:07 PM
RE: #define versus assigning value to a public variable Posted by Borislav Borissov @ 8/18/2006 1:05:49 PM
RE: #define versus assigning value to a public variable Posted by Bernard Bout @ 8/19/2006 5:37:30 PM
RE: #define versus assigning value to a public variable Posted by Andy Kramek @ 8/19/2006 8:27:20 PM
RE: #define versus assigning value to a public variable Posted by Ken Murphy @ 8/20/2006 3:48:45 AM
RE: #define versus assigning value to a public variable Posted by Bernard Bout @ 8/20/2006 6:57:01 PM
RE: #define versus assigning value to a public variable Posted by Bernard Bout @ 8/20/2006 6:59:14 PM