====================================== FoxPro Developers Network of San Diego ====================================== FoxDev TipsLetter #02-07 1 July, 2002 Website: Editor: ---------------------------------------------------------------------- CONTENTS: * Calendar * Editor's Note * Tech Tips: Knowledge Base Updates What Does "Linked" do? Andy Davies XML Changes in SP1 Dan Covill VFP7 - Shortcuts in the IDE * Other Stuff: Fix Your Own Hard Drive the Handyman VFP vs Visual Basic Wanted - Cheap Client-Server ProFox Consulting on Site ProFox * Links: Where Can I Find...? * 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). ====================================================================== EDITOR'S NOTE I've made a couple of format changes in this issue. a. The Knowledge Base updates are now permanent (relatively speaking) as the first tech tip each month. b. The links section is now at the end of the newsletter. It's gotten pretty large, and it doesn't change that often. Since I'll be on vacation for three weeks starting July 8, I'm not planning to put out an August issue. I would, however, be the last person to try to dissuade anyone else from jumping into the breach! Dan Covill ====================================================================== TIPS ====================================================================== VFP KNOWLEDGE BASE UPDATES by Dan Covill The following KB articles are new or updated, per KBAlertz.com Received 6/23: Q191923 PRB: COPY TO ARRAY Causes Insufficient Memory Error How To Look Up These Articles: To get to a specific KB article: 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. ---------------------------------------------------------------------- WHAT DOES "LINKED" DO? by Andy Davies [There was a discussion on ProFox about the NAME and LINKED options for the DO FORM command. Andy came in with this.] OK, I wasn't too sure about 'linked' so I tried it: * Build a simple form (myForm.scx) do form myForm activate screen && keep things tidy ? myForm.caption && Form1 ? Form1.caption && && (it's just the value in the Name property) myForm.caption = 'aNewCaption' ? myForm.caption && aNewCaption myForm = null && form does *not* disappear ? myForm.caption && ? myForm.release() && * click on the X box - form disappears do form myForm NAME oFrm activate screen && keep things tidy ? myForm.caption && ? oFrm.caption && Form1 ? Form1.caption && oFrm.caption = 'aNewCaption' ? oFrm.caption && aNewCaption oFrm = null && form does *not* disappear ? oFrm.caption && ? oFrm.release() && * click on the X box - form disappears ** so this is basically the same as the normal Do Form, but with a ** different object name do form myForm NAME oFrm LINKED activate screen && keep things tidy ? myForm.caption && ? oFrm.caption && Form1 ? Form1.caption && oFrm.caption = 'aNewCaption' ? oFrm.caption && aNewCaption oFrm = null && form *DOES* disappear Andy Davies ---------------------------------------------------------------------- XML IMPROVEMENTS IN SP1 You may have missed [I know I did] a significant enhancement of the XMLtoCursor() function in VFP 7 SP1. Adding 8192 to the flag allows you to specify an existing table or cursor, instead of having XMLtoCursor invent one for you. (It also cuts the execution time in half, because they only make one pass thru the XML instead of two.) The following is from the SP1 documentation: ----------------------- A new nFlag setting has been added to specify existing table or cursor as target for XML: XMLTOCURSOR(XMLSource eExpression | cXMLFile [, cCursorName [, nFlags ]]) nFlag Description 8192 cCursorName refers to an existing table or cursor, or the alias of an existing table or cursor. The following script can be used to update your IntelliSense file. Paste the following code into a new PRG program file and run the program file. --------------------- * Script to updated IntelliSense FoxCode table with new XMLToCursor * with new nFlag setting. Ensure the script appears in your PRG file * as it does below. Copying the text from your Web browser might add * extra empty lines (spacing within TEXT...ENDTEXT is critical). LOCAL lcSaveArea,lcTipStr lcSaveArea=SELECT() SELECT 0 USE (_FOXCODE) SHARED TEXT TO lcTipStr NOSHOW XMLTOCURSOR() nFlags Parameter (additive): 4 - Preserve white space in data. Overrides the xml:space attribute of the XML data. 512 - The first parameter is a literal file name or memvar containing same that represents a valid XML file. Otherwise, it is an expression that returns XML or memory variable containing an XML string. 1024 - Character and Memo fields in the resultant cursor will be created with the NOCPTRANS option, and the text/xml values in the incoming elements will be inserted into the Character/Memo field on an untranslated, byte for byte basis. 2048 - Map xsd:decimal types with totalDigits="19" and fractionDigits="4" to Currency field instead of default Numeric one. 4096 - Disable base64 decoding for Memo Binary fields. 8192 - cCursorName refers to an existing table or cursor, or the alias of an existing table or cursor. ENDTEXT UPDATE (_FOXCODE) SET tip = lcTipStr WHERE ALLTRIM(Expanded)=="XMLTIP4" USE SELECT (lcSaveArea) ----------------------- When an nFlag value of 8192 is set (additively), the following rules apply: ú If cCursorName cannot be found, return error 1 - "File '' does not exist." ú If cCursorName already contains data, the data being imported from the XML file will be appended to the existing data. ú If cCursorName is the empty string (""), XML will be imported into the table or cursor open in the current work area. ú If empty string or no param is passed and if no table or cursor is open in the current work area, return error 52 - "No table is open in the current work area." ú Element names in the XML file will be mapped to the column names in cCursorName. ú Data will only be imported into columns that match the element names in the XML file. ú The cursor or table can have fewer columns than contained in the corresponding XML file, but must have at least one matching column. ú The cursor or table can have additional columns that do not correspond to an element in the XML file. ú The data types in cCursorName will be enforced. For example, if the column is defined as Logical and the corresponding XML element contains incompatible values, such as date, dateTime, float, numeric, currency, and so on, attempting to import this data will result in an error. Visual FoxPro will return the error "Data type mismatch." The following restrictions apply to data types: ú Character, Character Binary, Memo, and Memo Binary - accept any data. Data that exceeds the length of a character column will be truncated. ú Numeric, Float - accept numeric data, with or without decimal portion. Numbers outside the Visual FoxPro range for these types will be truncated according to current Visual FoxPro rules or replaced with the numeric overflow indicator "*************." ú Double - accept numeric data that is within the range of the Visual FoxPro Double type. Numbers outside the Visual FoxPro range for these types will be truncated according to current Visual FoxPro rules. ú Currency - accept numeric data that is within the range of the Visual FoxPro Currency type. Numbers outside the Visual FoxPro range for these types will be truncated according to current Visual FoxPro rules. ú Integer - accept integer data that is within the range of the Visual FoxPro integer type. Numbers outside the Visual FoxPro range for these types will be truncated according to current Visual FoxPro rules. ú Logical - accept the values true, false, 1, and 0, as well as the Visual FoxPro form .T. and .F.. ú Date - accept XML format date and dateTime values. Visual FoxPro will convert the XML date/dateTime format to the corresponding Visual FoxPro date. Only the M/D/Y portion of the XML date or dateTime value will be preserved. ú DateTime - accept XML format date and dateTime values. Visual FoxPro will convert the XML date/dateTime format to the corresponding Visual FoxPro date. Precision beyond that supported by the Visual FoxPro dateTime data type will be discarded. ú If the XML contains or references a schema and the data types in the schema conflict with the data types of the cursor or table, the data type of the cursor or table will be used. ---------------------------------------------------------------------- VFP7 - SHORTCUTS IN THE IDE [When Drew Speedie was here in May he gave us several tips on using VFP 7 effectively. Here's one of them.] There are several new keyboard shortcuts available in the visual tools, including the Form Designer. a. Remember the drill to get to a control on a pageframe? RtClick, pick Edit from the menu, then click on the control? In VFP7: Ctl-Click will put you directly in the Pageframe. Ctl-Shft-Click will put you directly in the control. b. In the Properties window, with some control selected: Ctl-Home will take you to the top-level form Ctl-End will take you to the last control These and others are documented in the on-line help, under "Visual FoxPro IDE Enhancements" Dan Covill ====================================================================== OTHER STUFF ====================================================================== FIX YOUR OWN HARD DRIVE [from Fred Langa's LangaList ] - First, you need a clean room, so make sure the garage door is closed before you begin. Move those old lawnmower parts off the bench. Disassemble the sealed unit and carefully wash all parts with paint thinner. Bend the read/write heads out of the way, and then disassemble the platter stack. - VERY CAREFULLY buff the platter surfaces with the #4/0 steel wool. This will remove any existing data, level out any surface defects, and help to redistribute the magnetic media and fill in those pesky "bad sectors" that most drives have. - Reassemble the platter stack, and using a .015" feeler gauge, bend the read/write heads back to the platter surface, using the feeler gauge to set the gap. This is slightly higher gap than the factory uses, but it reduces the chance of head collisions with any flotsam you neglected to remove. - Give the heads and platters a good shot of WD-40 and reassemble the unit. If your drive has a filter, replace it with a clean section of gauze pad. All that's left is to low level and DOS format the drive, and you're back in business. I haven't tried this myself, but my friend's wife's sister-in-law's husband knows a technician that does it all the time.... ---------------------------------------------------------------------- VFP vs VISUAL BASIC "The following information was copied from a newsgroup archive for the group Comp.Lang.Visual.Basic." 1. VFP is a desktop RDBMS itself with an extense and rich OOP programming language; VB is easy and powerful develop environment for external RDBMS. 2. All of the most important ways to access and manipulate data available for VB (ADO, RDO, ODBC) can also be used within VFP. This means that the same code you write in VB to run a query on a remote table will work also in VFP. 3. VFP has a full native SQL language implementation: SELECT-SQL, DML, DDL; VB has not. 4. VFP OOP implementation is far better than VBs. In fact, in VFP you can subclass any native visual and non-visual control. The only way to do this in VB is using ActiveX. 5. Almost any ActiveX control that can be used in VB can be also used in VFP 6. VFP apps is as fast as VB apps, and VFP string handle is faster than VBs. 7. VFP has an incredible collection of functions to process dates, strings, numbers, objects, arrays; most of then aren't available in VB. 8. Report management in VFP is far better than in VB and you do not need any external software. 9. VFP is integrated with Internet as well as VB is. In fact, there are native controls to jump to URLS, send an receive mails, etc. Plus, you can instantiate an MS Explorer window in for your form. 10. And the most important point, something that VB programmers can only dream about: VFP supports macro-substitution, which means that you are able to run dynamically-generated code in runtime. In fact, you can run commands, create forms, class libraries and reports on-the-fly! [Attributed to Victor Espina] ---------------------------------------------------------------------- WANTED - CHEAP CLIENT-SERVER [Another dreamer appeared on ProFox the other day. DC] Anonymous request: > I would like to have a really robust DBMS for the back end for client-server, without having to have a DBA, or the expense of SQL Server. Andy Davies reply: Yes, we've been getting a lot of trouble with mid-air pig collisions as well Dan Covill comment: Or you could pick up a copy of my new book, "How to Administer a Client-Server Database Without Knowing Nothing". It's free, and worth it. Lou Syracuse added: ... and it comes with a FREE copy of MSDE! ---------------------------------------------------------------------- CONSULTING ON SITE [Here's some good advice for you independents. DC] ----------------- "I think that during the initial application design, it is critical to be onsite to talk to the people who will be using the app in order to get their input. It is also critical to be onsite during installation, because there are just too many factors to be effectively monitored remotely. But for most of the development period, and for the inevitable upgrade/debug phases, physical presence is no advantage at all. I've done most of my projects on a remote basis, and can certainly vouch for its effectiveness." Ed Leafe ----------------- "The people that work with your app need to know who you are, how you work, what your personality is, etc. Once that is accomplished, like you said at the beginning of the dev process, they are fine dealing with you over the phone, email, etc. and using some sort of remote product. Then, if you visit them once a year or so, it is usually good for a very nice lunch or dinner in a very nice restaurant with all the key people who are happy to see you in person again!" Paul McNett ====================================================================== 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 Leafe, 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] --------------------------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 ----------------------------------------------------------------------