====================================== FoxPro Developers Network of San Diego ====================================== FoxDev TipsLetter #02-06 15 June, 2002 Website: Editor: ---------------------------------------------------------------------- CONTENTS: * Calendar * Tech Tips: Knowledge Base Updates Dan Covill VFP7 and External Stored Procedures Steve Settimi Initializing Arrays Dan Covill * Links: Where Can I Find...? * Other Stuff: Monday Morning A.J. Axline XML and Content Jerry McGovern * Administrivia ====================================================================== CALENDAR: Wed - July 10 - Victor Campos ------------------------------ Business Objects in VFP: A lot of speakers tend to present this topic with examples pulled from their framework - unfortunately, in order to utilize the examples and learn from them you have to buy the framework. Victor's presentation is put together with code that is not part of any framework and therefore can be put into practice directly, or may be used to learn from. It's not any code to begin building enterprise applications, but, it's a perfect way to get started on the learning curve that many VFP Developers are still struggling with. Thus - August 15 - Mike Feltman -------------------------------- Visual Fox Express Mike will be showing an overview of F1 Technology's VFP framework, Visual Fox Express. Thurs - Sept 12 - Rick Strahl ----------------------------- Integrating Visual FoxPro with .NET Find out how you can access VFP data and logic in .NET. Rick will demonstrate data access with OleDb, using COM objects from .NET, accessing NET objects from Visual FoxPro and how to share data over Web Services. ------------------------------- Escondido meetings are at Bergelectric, 2222 Meyers Avenue. All meetings are at 6:30 pm. Take the Nordahl exit from Highway 78 (west of I-15). Head South, cross Mission at the lights. Next right onto Meyers Ave. Berg Electric is a one-story building on the right, just before Oper Street (there's no sign). ====================================================================== TIPS ====================================================================== VFP KNOWLEDGE BASE UPDATES by Dan Covill The following KB articles are new or updated, per KBAlertz.com 05/02: ------ Q304576 HOWTO: Troubleshoot the Windows Component Update for Visual Studio .NET Q288863 PRB: ASP/COM+ Solutions Using VFP ODBC Driver May Fail Under Stress Q250334 PRB: MSDN Library Unable to Display Help from Within Visual Studio Programs 05/08: ------ Q318992 FIX: Fatal Exception Can Occur in Edit Box When You Use Microsoft Active Accessibility Q318982 FIX: Fatal Exception Occurs When You Activate the Properties Window with Accessible Event Watcher Q318999 FIX: Fatal Exception Occurs When You Start Object Browser with Microsoft Active Accessibility Q318969 FIX: Second Instance of STDLL Object Causes Exception Error Q319282 FIX: SETFLDSTATE() Does Not Work for Field with Default Value Q319002 FIX: Toolbar May Cause Incorrect Control Focus with Microsoft Active Accessibility How To Look Up These Articles: The links included in the e-mail from KbAlertz are indirect links thru their website, so I didn't reproduce them here. The easiest way to get to a specific KB article is as follows: a. Go to support.microsoft.com. Search is at left of the page. b. Select "Visual FoxPro" on the drop-down. c. Enter the document number in the textbox below it. d. Click on the green arrow. To Subscribe: Subscribe at . You can specify any MS product to receive alerts on. ---------------------------------------------------------------------- VFP7 AND EXTERNAL STORED PROCEDURES by Stephen Settimi In VFP7, you don't have to have Stored Procedures (SPs) internal to the DBC itself in order to execute them globally. Any procedure file can be set as a DBCEventsFile; with DBCEvents on it will act as an application-wide Stored Procedure. You do not need to "set procedure to". Here's the required code: DBSetProp("MyDBC", "Database", "DBCEvents", .T.) DBSetProp("MyDBC", "DataBase", "DBCEventFileName", ; "MyProcFile.prg") Note that you can COMPILE the external SP code just before calling on any stored procedure. In this way you can actually swap-out an SP on-the-fly. Note also that you cannot access these same tables from VFP 6 if DBCVENTS is still on. Advantage of an External File: I believe it's always better to have an external file as an SP, even if it's only a pass-through to something else. That way you never find yourself locked out of the DBC. How can you get locked out? For instance, let's say you want to restrict access to your data. In VFP7 any DBC-bound table can only be opened with the DBC being opened first. For security, you can validate access before allowing DBC or the table to be opened. If the validation code is in the DBC procedure file itself, and validation fails, not only can you not open the DBC and table(s) but you can't MODIFY PROCEDURE to change the validation script either, because it will always fail to open and you have to open the DBC to modify anything. With DBCEVENTS set ON and with DBCEventFileName pointing to "my_sp.prg", you can modify the validation, recompile and the DBC will open. Here's some simple code for access validation: Procedure dbc_OpenData(cDatabaseName, lExclusive, lNoupdate, lValidate) * Runs immediately after DBC is opened. If Type('_screen.oApp') != "O" _Screen.Newobject('oApp','app','MyLib.vcx') Endif If Type('_screen.oApp')="U" ; or not _Screen.oApp.AccessOK(() Messagebox("ACCESS DENIED",0,Program(),2000) Return .F. Endif Endproc Stephen Settimi GNS Information Technologies, Inc SSettimi@GNSInfoTech.com Editor's Addendum: I asked Steve, "Can this external procedure file contain ONLY DB event code, or could it contain other functions?" He said, "Good question." We tried some experiments, and here's what we found. Any procedure in an Event File is accessible, whether it's an Event method or not. We think this may be an accident. Bug 1: You cannot override SP code in the DBC with a procedure of the same name in an Event File. The code in the DBC is always executed. Bug 2: Closing the DBC doesn't close the Event File. It remains open, as a general procedure file. Setting DBCEvents to .F. doesn't close it, "Close Procedures" doesn't close it, "Close All" doesn't close it. Only "Clear Program" will close it. Dan Covill ---------------------------------------------------------------------- INITIALIZING ARRAYS by Dan Covill As you have doubtless found out, arrays are easy to declare but a lot less fun to initialize. The brute force method is this: dimension aStuff[4] aStuff[1] = "Alice" aStuff[2] = "Gertrude" etc. It's tedious, and rearranging the values means changing all the numbering. There's got to be a better way. In fact, there are a couple of them. 1. Using TEXT TO: ---------------- FoxPro Advisor, April 2002, carried a tip showing how to eliminate the subscripts using TEXT TO (new in VFP 7): dimension aStuff[4] text to cTempList noshow Alice Gertrude etc endtext alines(aStuff, cTemplist, .T.) The "alines()" separates the list at each CRLF; the .T. trims the elements. ** Gotcha: if you indent with tabs, the trimming will leave the tab characters in the array. Not good. 2. But Wait, There's More: -------------------------- As usual, Juergen Wondzinski (wOOdy) knows another way, using alines() all by itself: alines(aStuff, ; strtran("Alice;Gertrude; ....", ';', chr(13))) You just type a delimited list of your values, then translate the delimiter to a CR. Neat! And it works in VFP6. ** Gotcha: don't include spaces, because they won't get trimmed. 3. But Wait, There's More: -------------------------- For VFP 7, wOOdy's trick gets even better. Alines() has two new parameters, so all you need to do is: alines(aStuff, "Alice; Gertrude; ...", .T., ";") The second parameter says trim the values, and the third one tells what your delimiter is. Alines does the translation. In all three variations, Alines() is the key. I wish I'd noticed it a few years ago. Dan Covill dcovill@san.rr.com ====================================================================== 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 Magazines tab, and read some of the regular columns. MSDN Library Look in Technical Articles | Visual Studio | Visual FoxPro 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" FoxPro 2.6: http://members.aol.com/FoxProResources/fpfp.htm MTS: Microsoft Transaction Server MSDN Library: "Microsoft Transaction Server for Visual FoxPro Developers" 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" VS Installer: MSDN Library: a. "Using Visual Studio Installer for VFP 6.0 Applications" b. "VFP 6.0 and VS Installer Tutorial" VFP Publications: www.advisor.com FoxPro Advisor www.pinpub.com FoxTalk magazine www.hentzenwerke.com Hentzen Publishing (Books, discussion, and downloads) 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. MS Developer Applications Forum on Compuserve http://go.compuserve.com/msdevapps The History of FoxPro (submitted by Steve Settimi) www.foxprohistory.org The Universal Thread http://www.universalthread.com The "Wiki" www.wikis.com fox.wikis.com fox.wikis.com/wc.dll?Wiki~FoxForumWiki Here is the most complete set of FoxPro links you're likely to find: 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.honeypass.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 Leave, ProFox listserve www.jamesbooth.com www.foxforum.com www.foxfolk.com www.stevenblack.com www.craigberntson.com 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) XML - What's New in XML for Microsoft Windows 2000 See also OLE DB drivers for XML in MDAC 2.6 at "microsoft.com/data" [Contributions solicited. DC] ====================================================================== OTHER STUFF ====================================================================== MONDAY MORNING by A.J. Axline [Following is an excerpt from the CramSession e-mail newsletter I get weekly. I think the guy is funny. If you're sick too, you can subscribe at www.cramsession.com. DC] It began when I walked through the door on Monday morning, and the monkey ran past me into the elevator. It was a sharply dressed monkey, tricked out in a sequined black vest and black leather pants. The elevator doors slid shut just as our receptionist elbowed me out of the way, obviously in hot pursuit. She was carrying a small red fez with a braided gold tassel attached to its top. The tassel waved frantically as she hammered on the down button of the elevator. "Shareholders meeting?" I asked her. ---------------------------------------------------------------------- Reestablishing the Value of Content by Gerry McGovern [Fragments from an article in the ACM on-line magazine, Ubiquity.] http://www.acm.org/ubiquity/views/g_mcgovern_1.html "Excuse me for a moment, just when did XML become a technology? Extensible Markup Language (XML) is a major step on from Hypertext Markup Language (HTML). The last I understood, neither of these were technologies. Rather, they were -- are -- publishing markup languages." "It takes editors to describe that content, not programmers. One of the key jobs of editors over the years has been to figure out how a document should be structured. XML is a tool for editors. It is they who need to figure how to "tag" the document; the programmer can then create the code for these tags." --------------------------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 abergquist@sbcglobal.net Claude Nikula - Secretary 619-615-6318 crndev@cox.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 ----------------------------------------------------------------------