====================================== FoxPro Developers Network of San Diego ====================================== FoxDev TipsLetter #04-06 August 6, 2004 Website: Editor: ---------------------------------------------------------------------- CONTENTS: * Calendar * Tech Tips: Define Inside Quotes from ProFox FireFox: An Alternative Browser Dan Covill * Other Stuff: Software Engineering Practices The Elements of Programming Style Frankensoft: The Monster We Made Mark Gibbs * Knowledge Base Updates New/Updated KB articles on VFP * Links: Where Can I Find...? * Administrivia ====================================================================== CALENDAR: All meetings are at Sizzler unless specified otherwise. Thu - August 12 - Mike Stewart ---------------------------- Main Presentation - "Hooking Windows System Events" VFP 9.0 brings with it the ability to hook into Windows system events and run custom VFP code when those events occur. When a new drive, such as a USB memory drive, is plugged in, VFP 9.0 can fire code to copy files, import records, or anything else VFP can do. When a laptop begins to hibernate or go to standby, a developer can now save changes, close tables, or do any other cleanup work before the system goes to sleep. Developers can trap events that occur in custom windows or even windows in the VFP IDE. Mike will explain and demonstrate the basics of Windows messages, the windows procedures used to process messages, and hooking into system events to run custom event code. Thu - Sept 9 - Barbara Peisch ------------------------------ Topic: Client Relationships 101 Regardless of how much programming experience you have, going independent is a whole new world. The first step is creating a standard contract (usually called a "Consulting Agreement") that's fair to both you and your future clients. This session will cover essential elements of a good contract, plus some negotiation strategies. We'll also cover the pros and cons of charging by time and materials versus fixed price, as well as what makes a good design specification. Finally, we'll get into how to establish and maintain a good working relationship, as well as when and how to terminate a relationship that's gone sour. Thu - October 14 - Steve Settimi -------------------------------- Topic: A Simple Way to Make Your Desktop Apps Web-Aware For additional info, check out All meetings start at 6:30 pm. Back room of Murphy Canyon Sizzler: 3755 Murphy Canyon Rd Take I-15 to the Aero Dr exit (South of Balboa) Head west to first light west of freeway Turn right Sizzler is on the right almost immediately PLEASE TRY TO COME EARLY ENOUGH TO ORDER YOUR DINNER BEFORE 6:30! We'll have our Q&A session while we eat. ====================================================================== TECH TIPS ====================================================================== #DEFINE INSIDE QUOTES from ProFox Many folks have taken to using the [] square brackets as a general substitute for quote marks, especially when there's a chance the quoted string may already have single or double quotes embedded in it. (E.g., [He said, "It don't matter."]. With both single and double quotes, the brackets are very handy indeed.) Anthony Testi (who spoke here last winter) has found a gotcha, though, in the interaction between #DEFINEs and quote strings. Note the code below: #DEFINE TRUE 1 CLEAR ? "This is true." prints: This is true. ? 'This is true.' prints: This is true. ? [This is true.] prints: This is 1. <======= !!! #DEFINEs do NOT get replaced inside single or double-quoted strings. However, they DO get replaced inside bracketed strings. We surmise that this is due to the predominant use of brackets for subscripts (aStuf[AMAX]), where you would want the #DEFINE to work. So it's not a bug, but it's definitely a gotcha. ---------------------------------------------------------------------- FIREFOX - AN ALTERNATIVE BROWSER by Dan Covill Target IE: A look at Internet Explorer alternatives by Paul Thurott "Mozilla Firefox (originally titled Phoenix because it was rising out of the ashes of the Mozilla Internet Suite, and then renamed to Firebird, a name that was dropped because of another open source project with the same name) is, in my opinion, the ultimate Web browser on Windows, and one of the most successful software products of all time." .......... The above article describes the many intriguing features of FireFox, which I won't go into here. I've been using it for about six months now, and have completely abandoned IE (except for Windows Update, which uses IE whether you want to or not!). The more I use it, the better I like it. It's a free download, less than 5 MB (!), and it works like a charm. Read the article, then give it a try. You'll like it. Dan Covill dcovill@san.rr.com ====================================================================== OTHER STUFF ====================================================================== SOFTWARE ENGINEERING PRACTICE submitted by Nick Nikula GNS Information Technologies, Inc. recommends the following paper covering basic software engineering practices. Explanation of Basic Software Engineering Practices The benefit of following software engineering practices is producing a software system where the quality of the system has been controlled and engineered. The system can be engineered with the following quality attributes in mind: Reliability, Extendibility, Usability, Reusability, Compatibility, Efficiency, and Portability. If no software engineering practices are followed the quality attributes cannot be assured. Well-managed projects sometimes fail. Badly managed projects inevitably fail. [Sommerville99] You can find the complete paper on the Web at the University of Melbourne Bibliography [Pressman97] Software Engineering: A Practitioner s Approach, Roger Pressman, The McGraw-Will Companies Inc., 1997 [Sommerville99] Software Engineering, Ian Sommerville, Addison Wesley, 1999 ---------------------------------------------------------------------- THE ELEMENTS OF PROGRAMMING STYLE After the presentations by Anthony Testi and Art Bergquist, Nick Nikula also submitted these extracts from Kernighan and Plauger's "The Elements of Programming Style". [A small, easy-to-read book that paraphrases Strunk & White's "The Elements of Style". DC] 1. Format your code well. Make sure it's easy to read and understand. Comment where needed but don't comment obvious things it makes the code harder to read. If editing someone else's code, format consistently with the original author. 2. The single most important factor in style is consistency. The eye is drawn to something that "doesn't fit", and these should be reserved for things that are actually different. 3. Every program you write that you intend to keep around for more than a couple of hours ought to have documentation in it. Don't talk yourself into putting off the documentation. A program that is perfectly clear today is clear only because you just wrote it. Put it away for a few months, and it will most likely take you a while to figure out what it does and how it does it. If it takes you a while to figure it out, how long would it take someone else to figure it out? 4. Use temporary variables sparingly. 5. Parenthesize to avoid ambiguity. 6. Use Classes and or library functions. 7. Replace repetitive expressions by calls to a Class, Method or common function. 8. Choose variable names that won't be confused. 9. If a logical expression is hard to understand, try transforming it. 10. Choose a data representation which, makes the program simple. 11. Don't patch bad code - rewrite it. 12. Write and test a big program in small pieces. 13. Test input for plausibility and validity. 14. Make sure input doesn't violate the limits of the program. 15. Terminate input by end-of-file or marker, not by count. 16. Make input easy to prepare and output self-explanatory. 17. Make sure all variables are initialized before use. Use variable names that mean something. 18. Test programs at their boundary values. 19. Check some answers by hand. 20. Don't compare floating-point numbers solely for equality. 21. Make it right before you make it faster. 22. Make it fail-safe before you make it faster. 23. Make it clear before you make it faster. 24. To make it faster, change the algorithm not small details in the code. 25. Actually test code to see how fast it is. 26. Make sure comments and code agree. 27. Format a program to help the reader understand it. Always Beautify Code. When developing in VFP you should us the Beautify Tool and use MOCC setting. See the Fig below for proper setting [] 28. Don't just echo code in comments - make every comment meaningful. 29. Document your data structures. 30. Don't comment bad code - rewrite it. 31. Use data arrays to avoid repetitive control sequences. 32. Keywords and Variables need to be Mixed Case (Example: lcLastName) 33. Always Comment all user defined Property(s), Method(s) and Event(s). 34. When writing Com, Com+ or any OLE Public object make that object IntellSense a where if possible Note: in VFP 7 and higher you can use the ComAttrib[] array function 35. Save your code often and backup your code on a regular basis 36. Every application you write should be able to run on a Network. If using DBF files you will handle record locking not relying on the OS. Do not use hard coded paths in your code. Instead use a variable with path and drive letter information stored in it. From: The Elements of Programming Style, Brian Kernighan and P. J. Plauger,McGraw-Hill Book Company, New York, 1974. ---------------------------------------------------------------------- FRANKENSOFT: THE MONSTER WE MADE by Mark Gibbs By Mark Gibbs, Network World, 07/19/04 "We must also work to change a number of customer perceptions, including the views that older versions of Office and Windows are good enough, and that Microsoft is not sufficiently focused on security." - Microsoft CEO Steve Ballmer in a July 6 company-wide e-mail. Ballmer's words are hard to take without being cynical. As Owen Thomas quipped in a recent issue of his Ditherati newsletter, this was "Ballmer, addressing employees on the urgent need to deceive customers more aggressively." Microsoft has bent the rules of business, but we must be realistic: We created the monster. We wanted inexpensive software and there was Microsoft - the right company with the right products at the right time. We let ourselves be sold on its "vision" and its story. Of course its rose-colored glasses filtered its vision but it never actually fooled us, it just sold us the products and the stories we wanted. ..... So as much as we should like to be understanding and constructive with regard to the monster we made, that isn't possible because the monster hasn't matured, and we can't (and can't afford to) kill it off. Alas, it is still clumping around the countryside, grasping arms to the fore, dead-fish gaze seeing only what it wants to see, leaving chaos in its wake. But can Microsoft fix the problems with Internet Explorer? Some people contend that Explorer's architecture is fundamentally flawed and therefore can't be fixed. Others contend the layering of patches on patches can never produce a stable result. Whichever way you look at it, you have to ask, can we afford to continue using Explorer? ====================================================================== VFP KNOWLEDGE BASE UPDATES ====================================================================== Visual FoxPro (7 & 8) ~~~~~~~~~~~~~~~~~~~~~ 130507 How To Logical Values Must Be Sent to SQL Server as 1 or 0 131027 How To Encapsulate Data in the Form Builder 133451 How To Causing a Form or Formset to Time Out 135518 How To Copy Files from Cabinets on DMF-Formatted Disks 136075 How To Disabling Menu Titles and Bars 137946 How To Distribute Win32s Files w/ FoxPro 3.0 App on Network 137962 How To Have a Disabled Picture Command Button Look Enabled 138560 How to Disable Combo and List Boxes in Wizard-Generated Forms 138916 How To Backing Up Visual FoxPro Setup Disks 139291 How To Change the BackColor of a ToolBar When it is Docked 139626 How To Drag and Drop Between Two Containers 147199 How To Determine If Insert Was Successful 157522 How To Install Visual FoxPro 5.x or 6.0 on a Network 162076 How To Converting VFP Files from Version 3.0 to 5.0 and Back 162300 How To Converting VFP3 Source Control Projects to VFP5 164870 How To Apply, Remove a Filter from Form's DataEnvironment 167192 How To Create a Progress Indicator Using Threed Panel Control 169500 How To Call Driver Specific Functions in a Remote View 170127 How To Add Tables in a Database to Source Control 170146 How To Access ImageList from TreeView & ListView Control 172079 How To Closing a Running Application from Visual FoxPro for Mac 176655 How To Convert a Word Table to a FoxPro Table 186010 How To Calling the Splash Screen Foundation Class From Code 186094 How To Change the Data Series in MSGraph Using the PlotBy Prop 186913 How To Assign FoxPro Foundation Classes via Field Mapping 186920 How To Change the Report Designer Ruler Measurement 187982 How To Change Default Properties for Genhtml 191174 How To Create a Custom HTML Help Viewer in Visual FoxPro 191629 How To Create an MTS Component that Works with FoxIsapi 191758 How To Convert FoxPro Cursor into XML Data Format 191953 HOWTO: Use Coverage Profiler to Optimize App Performance 192304 How To Check for a Writeable Drive Under Windows NT 192343 How To Associating the Default ProjectHook Class to a Project 195613 How To Create a Simple Context-Sensitive HTML Help File 195620 How To Check for Component Gallery/Class Browser Version Visual FoxPro 6.0 ~~~~~~~~~~~~~~~~~ 165408 How To Append Menu to an Existing Top-Level Form Menu 165640 How To Customize the Comment and Uncomment Strings in VFP 166139 How To Display Graphic on Each Tab of SSTab at Runtime 166937 How To Programmatically Add Images to ImageList Control 168835 How To Add Copy and Paste Functionality to Grid Control 168895 How To Convert Numeric Dollar Amount to Character Form 171357 How To Get FoxISAPI Running Without Logging on to Server 172078 How To Enable Autorun for Applications Distributed on CD- ROM 172847 How To Cut and Paste from General Field into a Word Document 177304 How To Programmatically Copy the Current Record to a New Record 265261 How To Improve Speed of Word Automation 265731 How To Automate Excel 2000 Subtotals Function in Visual FoxPro 289904 How To Create a CD-ROM Setup Disk with the VFP 6.0 Setup Wizard How To Look Up These Articles: To get to a specific KB article: a. Go to support.microsoft.com. b. Click on "Knowledge Base Article ID Number Search" c. Enter the document number in the page that appears. d. Click on the green arrow. To Subscribe: Subscribe at . You can specify any MS product to receive alerts on. ====================================================================== LINKS ====================================================================== This is a (semi) permanent list of places to look for technical help when you get blind-sided by the latest urgent requirement. We don't give specific URLs for MSDN articles because (a) they're too long and (b) they change too often! ------------------------------- MSDN ON LINE: There's a ton of stuff here, look at the MSDN Magazine. Heavy on .NET, you'll have to dig to find the VFP stuff. ADO VFP and ADO - Part 1 of 2 FoxPro 2.6 procedure library: http://members.aol.com/FoxProResources/fpfp.htm ODBC: MSDN Library: "Using Visual FoxPro to Access Remote Data" ODBC drivers are part of MDAC - Microsoft Data Access Components - and are available for download at: "www.microsoft.com/data" VFP Publications: www.advisor.com FoxPro Advisor www.pinpub.com FoxTalk magazine www.hentzenwerke.com Hentzen Publishing (Books, discussion, and downloads) VFP Run-Times: FTP library with complete VFP run-times from 3 thru 8. VFP General: msdn.microsoft.com/vfoxpro Microsoft's official VFP home page www.foxcentral.net Joint effort by Microsoft, West-Wind, and the Universal Thread Lots of news and development info. The History of FoxPro (submitted by Steve Settimi) www.foxprohistory.org The Universal Thread http://www.universalthread.com The "Wiki" fox.wikis.com fox.wikis.com/wc.dll?Wiki~FoxForumWiki fox.wikis.com/wc.dll?Wiki~VisualFoxProLinks Here's another extensive set of FoxPro links: http://www.cetus-links.org/oo_visual_foxpro.html Private websites with useful free info and downloads: www.prolib.de/foxlinks.afp wOOdy Wondzinski www.gatwicksoftware.com Allen Pollard www.ukfug.org.uk British user group www.lafox.org LA user group www.pinter.com/ Les Pinter www.vfug.org/ Virtual Fox User Group www.leafe.com Ed Leafe, ProFox listserve www.jamesbooth.com white papers and tutorials www.foxforum.com www.foxite.com (registration required) A group of Dutch developers - refreshingly geeky. (Don't be put off by the registration - they're not selling anything.) www.stevenblack.com INTL Toolkit and lots more www.craigberntson.com the Crystal Reports guru WEB Development: These products all work well with VFP. AFP www.afpweb.com and www.afpages.com DotFox www.elsoftware.com FoxWeb www.foxweb.com Web Connection www.west-wind.com X-WORKS www.x-works.com Windows General Win32 API (with VFP examples) [Contributions solicited. DC] --------------------------Administrivia------------------------------- This newsletter is a service to all FoxPro developers, provided without charge by the FoxPro Developers Network of San Diego (FPDN). Anyone may subscribe (or unsubscribe) at our web site . The link is on the home page. The Resources button on the website will take you to the back issues of the newsletter. The editor (Dan Covill) is solely responsible for the content. E-mail him with YOUR tips, comments, or complaints. Editor: Dan Covill 858-272-2448 dcovill@san.rr.com Board of Directors: Eric Lendvai - President 760-734-4929 eric@elsoftware.com Art Bergquist - Vice Pres 760-740-0428 abergquist@sbcglobal.net Thad V'Soske - Secretary 619-544-9900 tvsoske@yahoo.com Barbara Peisch - Treasurer 760-729-9607 barbara@peisch.com Dan Covill - Director 858-272-2448 dcovill@san.rr.com Claude Nikula - Director 619-615-6318 crndev@verizon.net ----------------------------------------------------------------------