====================================== FoxPro Developers Network of San Diego ====================================== FoxDev TipsLetter #01-01 January 1, 2001 Website: Editor: ---------------------------------------------------------------------- CONTENTS: * Calendar * Tech Tips: Sending E-Mail With VFP Dan Covill MakeSure of Your Project John Baird Hacking FRX Files When You Need to Lose Focus Dan Covill Where Can I Find...? * Other Stuff: VS7 Beta Available Programming Classes at UCSD Making the Case for VFP Joel on Tools DLL Hell Who Does the Refund? * Administrivia ====================================================================== CALENDAR: ****************************************************** ALL MEETINGS ARE NOW IN ESCONDIDO !!! ****************************************************** *** NOTE: NEW MEETING TIME *** ****************************************************** Our regular meetings are now at 6:30 pm, since we have to vacate our meeting place by 9:00. Jan 3 - Escondido(!) (6:30!) --------------------- Eric Lendvai will demonstrate how to debug code using VFP COM objects running under ASP. Feb 7 - Escondido ----------------- Nick Nikula will show us how to use Remote Automation Server running in asynchronous mode. March - Escondido (probably) --------------------- Barbara Peisch will discuss some of the basics of using views, the limitations of the view designer, how to build views in code, and the advantages of keeping view in a separate DBC. April - Escondido ----------------- Dan Covill will show us how to create an audit trail using XML. -------------------------------------------------------------------- Escondido meetings are at Bergelectric, 2222 Meyers Avenue. Take the Nordahl exit from Highway 78 (west of I-15). Head South. Right on Meyers Ave, first right past Mission. It's a one-story building on the right (there's no sign). ====================================================================== TIPS ====================================================================== SENDING E-MAIL FROM VFP by Dan Covill Want to send an email from VFP? The easiest way is via the free ASPeMail component, which is a COM object using an SMTP server. www.aspemail.com ASPeMail is a 131k .dll (which you have to install). It's very easy to work with, but unfortunately the examples are for VB programmers. ProFox to the rescue! Allen Pollard, a ProFox regular, put a VFP sample program on his web-site (www.honeypass.com). I made some tweaks to the error handling, because ASPeMail doesn't return an error code directly. The following sample works: *-------------------------------------------------------- Function SendEmail LParameters MailTo, MailFrom, MailSubject, MailBody Local oMail, isok isok = "OK" on error isok = "Error with object" oMail = CreateObject("Persits.MailSender") && ASPeMail if isok == "OK" oMail.Host = "smtp-server.myisp.com" *-- change this to the name of your SMTP host oMail.AddAddress(MailTo) oMail.AddReplyto(MailFrom) oMail.From = "dcovill@myisp.com" && change this to suit oMail.FromName = "Dan Covill" && change this to suit oMail.Subject = MailSubject oMail.Body = MailBody on error do SendErr && trap error messages oMail.Send on error endif return isok *----------------------------------- procedure SendErr *-- There is a table of error types in the ASPeMail documentation ? 'Error:', error() ? 'Message:', message() aerror(aErrInfo) for I = 1 to 7 ? 'aerror(1,'+str(I,1)+'):', aerrinfo[1,I] *-- What you need is in there somewhere endfor cancel *----------------------------------- ---------------------------------------------------------------------- MAKESURE OF YOUR PROJECT John Baird Several problems arise because some files are automatically included in a project, while others (like config.fpw, for instance) have to be added manually. If you rebuild your project, and forget one of the additions, your .EXE will work on your machine, but will crash on your client's! Not good. So how do you remember everything you need? At 01:32 PM 12/8/2000 -0500, John Baird wrote: < To get around this issue, I've included a program called < makesure.prg into my project which is nothing more than a list of < all of the progs, menus, forms, etc. used in the project. When I < have to rebuild because the project gets corrupted, I am sure that < all of the non-referenced items are included. My reply: Damned good idea, John. I plan to plagiarize it! ---------------------------------------------------------------------- HACKING FRX FILES The solution to many print problems lies in hacking the .FRX files, mainly to remove the hard-coded printer assignments. Here are some sources: ** These URLs wrap !! Markus Egger's article on the .FRX structure: http://www.eps-software.com/isapi/ eps.dll?KnowledgeBase~DisplayKBDocument~9 John Koziol's article based on writing Frx2Word: http://www.pinnaclepublishing.com/FT/FTMag.nsf/WebIndexOfFreeTips/ F9FA874556FBE8768525692E007B8459?opendocument ---------------------------------------------------------------------- WHEN YOU NEED TO LOSE FOCUS by Dan Covill A couple of months ago I was wrestling with a strange problem. My (read-only) grid form has a set of command buttons across the bottom, each of which has a 'Hot key' in the caption. Everything works. But the user has to press Alt + the hot key, which isn't nice. So I set KeyPreview = .T., and wrote a KeyPress() method that checked for the hot-key letters by themselves. Neat. Except that the 'A'dd button misbehaved. The Add function (in a code file) creates a new record and calls my Edit form to enter the data. The new record got created, but the Edit form showed the record we were on in the grid, instead of the new one. Now it gets weird. This happens ONLY when we get there through the keypress event. Clicking on the Add button, or pressing Alt-A, works just fine. Even weirder, if I trace the code with the debugger, then the problem doesn't happen! I brought this up at the FoxDev meeting and somebody pointed out that when you use the debugger the focus changes; but when I executed the Add from the Keypress() method the grid still had focus. !! That was it!! I added a line in the Keypress() method that set focus to the exit button and the problem went away. Apparently, since the grid and the edit form share the datasession, while the grid has focus the edit can't look at any other record. The moral: Get the focus OFF any data-based control before going off to do other things. ProFox discussion pointed out that changes in data are not visible from other processes until the control that entered the change loses focus. ---------------------------------------------------------------------- WHERE CAN I FIND...? 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 Magazines tab, and read some of the regular columns. MSDN Library Look in Technical Articles | Visual Studio | Visual FoxPro 3-Tier Apps: MSDN Library: "Building Three-Tier Client/Server Applications with Visual FoxPro" ADO MSDN Library: ADO Jumpstart for Microsoft Visual FoxPro Developers John V. Petersen, April 1999 DNA (Distributed interNet Architecture): MSDN On-line: "Top Windows DNA Performance Mistakes and How to Prevent Them" MTS: Microsoft Transaction Server MSDN Library: "Microsoft Transaction Server for Visual FoxPro Developers" ODBC: MSDN Library: "Using Visual FoxPro to Access Remote Data" VS Installer: MSDN Library: a. "Using Visual Studio Installer for VFP 6.0 Applications" b. "VFP 6.0 and VS Installer Tutorial" Windows General XML - What's New in XML for Microsoft Windows 2000 [Contributions solicited. DC] ====================================================================== OTHER STUFF ====================================================================== VS 7 BETA AVAILABLE Visual Studio.Net Beta1 Available November 13 11:22 From Microsoft: "Microsoft Visual Studio.NET Beta 1 is now available. This release is the first chance for customers to take a look at the forthcoming innovations of Visual Studio.NET, which establishes a complete development environment for building applications on the Microsoft .NET Framework, Microsoft's next generation Web application development platform." http://msdn.microsoft.com/vstudio/nextgen/beta.asp [Everything I read says to treat this like any other Beta; do NOT install it on your production system! DC] ---------------------------------------------------------------------- PROGRAMMING CLASSES AT UCSD The following classes (among others) will be offered at UCSD next quarter, beginning January 8: 1) Internet Appliance Design - NEW - *HANDS ON* section 027384 2) Embedded Controller Programming I and II (Embedded C Programming) sections 027365, 027366, 027367, 027368 3) Real Time Programming - *UPDATED* - Now includes Real Time C sections 027380, 027381 4) Embedded Controller Hardware Design is On-Line sections 027375, 027376 More information is available at: http://www.netburner.com/ucsd/ http://courses.ucsd.edu/extension/engsci/ecpi/ http://www.hte.com/uconline/rtp http://www.hte.com/uconline/ecd ---------------------------------------------------------------------- MAKING THE CASE FOR VFP A discussion on the ProFox forum last month centered on the old topic of "What can I show clients to help convince them that VFP is the best tool for the job?". "wOOdy" (Juergen Wondzinski) sent in this list of resources: JFAST applications article: "http://www.advisor.com/Articles.nsf/ID/FA9806.RUBEM67" Two Les Pinter articles with his point of view: ftp://ftp.prolib.de/public/why_vfp/VFP-Secret_e.doc ftp://ftp.prolib.de/public/why_vfp/Economics_e.doc Beth Massi (from Flash) on VFP versus VB: http://members.home.net/bmassi/index.html And on the Prolib website: ftp://ftp.prolib.de/public/why_vfp/ShootOut.ppt This is a 30 page Powerpoint Presentation that was given at a seminar at Microsoft in Waltham MA. It is an extensive set of notes showing screen shots and descriptions of the differences between Visual Foxpro and Visual Basic. This can be used to show clients who are thinking of using VB on a database applications where VFP would be a better choice. ---------------------------------------------------------------------- TESTING "All that testing takes time, but it's worth it, because sooner or later your customers will find every error on your site anyway, so why don't you beat them to it?" ---------------------------------------------------------------------- JOEL ON TOOLS "When I sit down to architect a system, I have to decide which tools to use. And a good architect only uses tools that can either be trusted, or that can be fixed. "Trusted" doesn't mean that they were made by some big company that you're supposed to trust like IBM, it means that you know in your heart that it's going to work right. I think today most Windows programmers trust Visual C++, for example. They may not trust MFC, but MFC comes with source, and so even though it can't be trusted, it can be fixed when you discover how truly atrocious the async socket library is." from "Joel on Software", www.joel.editthispage.com [For myself, I trust FP DOS 2.6, but I don't really trust VFP. DC] ---------------------------------------------------------------------- DLL HELL [This was read by Art Bergquist at the Chistmas Dinner.] Editor's Forum [Windows Developers Journal ] December 2000 First, there was the Windows API and DLL Hell. Revolution # 1 was DDE - remember how hot links let us create status bars showing the current price of Microsoft stock? About that time, Microsoft created the VERSIONINFO resource, which eliminated DLL Hell. But another group within Microsoft discovered a fatal flaw in DDE: they didn't write it! To solve that problem, they created OLE (which was like DDE, only different), and I fondly remember a Microsoft conference speaker proclaiming that the Windows API would soon be rewritten as an OLE API, and every control on the screen would be an OCX. OLE introduced interfaces, which eliminated DLL Hell. Remember "in situ" fever, and how we dreamed of the day that our applications would all be embedded in a (apparently very large) Word document? Somewhere in there, Microsoft got the C++ religion and MFC emerged and solved all our problems again, but with inheritance. Well, OLE wasn't going to take that sitting down, so it re-emerged as COM, and suddenly we realized what OLE (or was it DDE?) was really meant to be all along - and it even included an elaborate component version system that eliminated DLL Hell. Meanwhile, a renegade group within Microsoft discovered a fatal flaw in MFC: they didn't write it! They forthwith corrected that problem by creating ATL, which is like MFC, only different, and tried to hide all those fascinating details that the COM group was trying so hard to teach us. This stimulated the COM group (or was it OLE?) to rename themselves ActiveX and issue hundreds of pounds of new interfaces (even new versioning interfaces, which eliminated DLL Hell), along with the ability to make all our code downloadable via web browsers, complete with user-selectable viruses (ha - try to keep up with that, you ATL weenies!). Like a neglected middle child, the operating systems group cried out for attention by telling us all to "get ready for Cairo", some weird crud that they could never really explain, let alone ship. To their credit, however, the operating system group did introduce the concept of "System File Protection", which eliminated DLL Hell. Meanwhile, another group inside Microsoft discovered a fatal flaw in Java: they didn't write it! That was remedied by creating J, or Jole, or ActiveJ (honestly, I can't remember the name), which was like Java, only different. That was very exciting, but Sun sued Microsoft under some archaic law that limits the amount of crapulence any one company can ship in a year. This was clearly an attempt to stifle Microsoft's freedom to create products that are like other products, only different, and resulted in the creation of The Microsoft Freedom to Stuff Money in the Trousers of Congressmen Network (newsletter and $14.75 T-shirts available). Remember the J/Jole/ActiveJ program manager pounding his shoe on the table and insisting that Microsoft would never abandon his product? Silly wabbit! All this could mean only one thing - too little attention for the ActiveX (or was it COM?) group. This incredibly resilient herd of API gushers came back strong with COM+ (shouldn't that have been ActiveX+?), and MTS. (I have no idea why there's no "COM" or "Active" or "X" or "+" in "MTS" - they totally shocked me with that one!) They also threatened to add yet another "+" onto all their buzzwords in the very near future. Around that time, someone was yelling about "Windows DNA" and the "Windows Washboard" for a while, but that died out before I ever figured out what it was. At this point, Microsoft had been watching the Internet for several years with growing unease. Recently, they came to the realization that there was a fatal flaw in the Internet: well, you probably know what it was. And that brings us up to date with .NET (pronounced like "doughnut", only different), which is like the Internet, only with more press releases. Let's be very, very clear about one thing: .NET will eliminate DLL Hell. .NET includes a new programming language called C# (turns out there was a fatal flaw in Active++Jspresso, so just as well it died). .NET includes a virtual runtime machine that all languages will use (turns out there's a fatal flaw in relying on Intel CPUs). .NET includes a single logon system (turns out there's a fatal flaw in not storing all your passwords on Microsoft's servers). In fact, it's probably easier to list all the things that .NET does not include. .NET is absolutely going to revolutionize Windows programming... until next year. Ron Burk, Editor ---------------------------------------------------------------------- WHO DOES THE REFUND? [Another gem from the ProFox forum.] Here's an excellent example of how case can change meaning. The GetWhoRefunds method is used to determine which party will generate a refund. In the code it's referenced in MixedCase, but in the Class Browser it looks like this: accountingcontainers::custpaycontainer.getwhorefunds ^^^^^^^^^^^^^ --------------------------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@acm.org Board of Directors: Eric Lendvai - President 760-734-4929 eric@elsoftware.com Art Bergquist - Vice Pres 760-740-0428 abergquis@cs.com Claude Nikula - Secretary 619-615-6318 nikula@worldnet.att.net Barbara Peisch - Treasurer 760-729-9607 barbara@peisch.com Dan Covill - Director 858-272-2448 dcovill@acm.org Thad V'Soske - Director 619-544-9900 tvsoske@hanoverdirect.com ----------------------------------------------------------------------