Hidden Secrets of the VFP IDE, Part 2

zhaozj2021-02-16  111

Hidden Secrets of the VFP IDE, Part 2 Cathy Pountney FoxPro has always had several different ways to do the same thing. How many times have you looked over the shoulder of another developer and said, "Hey! How did you do that?" In this article Cathy Pountney uncovers many ways to work within the IDE, especially those that are not so obvious or are not documented. You'll learn several different ways to improve your productivity. Even experienced developers are bound to learn something new. This is the second of two articles where I've been exposing several unknown secrets of the VFP IDE. In the first part, I discussed various designers, a few controls, the Property Sheet, the Document View, and the Find Dialog. Then I revealed some secrets of IntelliSense as well as several tools and utilities included with Visual FoxPro. In this article, I'll reveal secrets of the Command window, several commands, and wrap up with a potpourri of hidden secrets. Command window and commands The Command wi NDOW Is Another Place We spend a Lot of Our Day. Here Are Some Tips That Can Be Used in The Command WINDOW AS WELL AS Some Lesser-KNown Secrets About Some of VFP '

s commands. Command window Many people already know that you can highlight a line of code in the Command window, right-click, and choose Execute Selection to execute the highlighted code. But did you know that you can highlight multiple lines of code and execute them at once? However, you have to realize how this works or you might not get the expected results. When multiple lines of code are executed, a temporary program is created and then run. This means that variables can go out of scope after the Chunk of code has been run. this is real more of a "hidden gotcha" Than A "hidden secret"! Another Thing You can do in Command WINDOW IS Use the semicolon (;) AS A Continalization Character Just As you do in code . This is great when you're copying code from a program or when you're creating a giant SELECT statement that you want to be able to wrap. _CLIPTEXT The first extra is a system variable called _CLIPTEXT. This contains the contents of the VFP CLIPBOARD. You can use it to set oth er information based on what's in the clipboard, and you can use it to define what's in the clipboard. It's a two-way variable that you can take advantage of at design time and even at runtime within your application. To demonstrate, highlight a line of code in the Command window and press Ctrl C to save it to the clipboard. Now enter? _CLIPTEXT in the Command window and you'll see that the line of code you highlighted is printed on the screen. Another example is to run the FOLLOWING CODE TO CREATE A Program: _cliptext = '? "FOX ROCKS"' CHR (13) CHR (10) ; '? "VFP 8 is Great" chr (13)

CHR (10) ERASE JUNK.PRG MODIFY COMMAND Junk NOWAIT KEYBOARD '{CTRL V}' The preceding code fills the clipboard with two lines of code, creates a program file, and then pastes the contents of the clipboard into the newly created program . _VFP.DataToClip () The second extra that VFP has to help us with cut-and-paste functions is the _VFP.DataToClip () function. This function takes data from a table or cursor and puts it into the clipboard. from there, you can paste it anywhere else, including Microsoft Excel. The third parameter defines the format of the data. If you use a 1 in the third parameter, the data uses spaces to separate each field. However, if you use a 3 in the third column, tabs are used to separate each field, which makes it perfect for inserting into Excel or other applications. Printing the clipboard Another little-known feature in VFP is the fact that you can print what's in the clipboard. This is great when you want To Print A Chunk of Code from a Program, But Not The Enti . Re program Highlight the text you want to print and select File |. Print from the main VFP menu to invoke the Print dialog (you can also use Ctrl P to invoke the same dialog) From the Print dialog, select the Options button to . display the Print Options dialog By default the Print What - Type combo box is filled in with the current program However, you can select Clipboard, select OK, and then go back to the Print dialog to finish selecting your printing options BROWSE keystrokes.. .

Keystroke What it does Ctrl F Find Next Ctrl G Find Previous Ctrl Y Add a record Ctrl T Toggle Deletion flag Ctrl Home Edit a memo field Ctrl W Save and close Ctrl F10 Toggle between maximize and restore What's in a NAME? The NAME clause can be very helpful for passing data around. The SCATTER, GATHER, and INSERT INTO commands all honor the NAME clause. This makes these commands much more powerful than in earlier days when you were used to SCATTERing into MEMVARs. Now that you can SCATTER to a NAME, you can pass the data to another object as a parameter The following code shows an example of how to do this:. * - Open Tables CLOSE TABLES ALL USE MyTable1 IN 0 USE MyTable2 IN 0 EXCLUSIVE ZAP IN MyTable2 * - Copy records from MyTable1 to MyTable2 SELECT MyTable1 GOTO TOP SCAN SCATTER NAME oMyTable AddToTableGather ( 'MyTable2', oMyTable) AddToTableInsert ( 'MyTable2', oMyTable) ENDSCAN SELECT MyTable2 BROWSE * - Close tables CLOSE TABLES ALL RETURN ** *********************** FUNCTION ADDTOTABLE Gather *********************** LParameters Pctable, Pofields local LCALIAS LCALIAS = alias () SELECT (PCTABLE) Pofields.descr = Alltrim (Pofields.Descr ) 'G' append blank Gather Name Pofields Select (LCALIAS) Return *********************************************************************************************************** **************** LPARAMETERS PCTABLE, POFIELDS POFIELDS.DESCR = Alltrim (Pofields.descr) 'I' I 'I INSERT INTO (PCTABLE) from name Pofields Return Another Great Example of use the Name Clause Is With The Browse Command. In The Command Window, Enter the Following: Use MyTable1 Browse Name Obrowse Now In The Command WINDOW, ENTER THE STRING OBROWSE. (DON)

t forget the trailing period) and you'll see IntelliSense kick in as soon as you type the period. This is great-the browse window is now an object you can manipulate. Start picking some properties, such as fontbold or rowheight, from IntelliSense and you can manipulate the browse window right from the Command window. Implicit TRANSFORM () In VFP 8, a few commands have implemented an implicit TRANSFORM () feature. This means that you can use data types that are not character, and the command will TRANSFORM it automatically for you. If the item being transformed is an object, the text "(Object)" is used. Try the following commands and you'll be pleasantly surprised that they do not throw an error! WAIT WINDOW DATE ( ) MESSAGEBOX (500) DEBUGOUT DATE ()? _VFP Potpourri Here are a few more hidden secrets that are scattered throughout Visual FoxPro. Shifty tricks Using the Shift key before selecting a menu option can change the options on the menu. For example, pressing Shift And Selecting the Fi . Le menu changes the Close option to Close All Using Shift along with the Window menu changes Hide to Hide All Normally, the Format |. Font option changes the font in the Command window However, using the Shift key with the Format menu changes the. Font Option to Screen Font, Which Changes The Font of The VFP Screen. Another Feature That's BEEN Around for Years and Years in FoxPro and VFP is The Outshow Feature. Pressing Ctrl Alt

Shift hides all the windows except the one accepting output. They stay hidden as long as you continue pressing the key combination. As soon as you let go, all the hidden windows appear again. This is extremely useful when you display something from the Command window with the question mark (?) character and the results end up getting shown behind a bunch of other windows. Copy a class At first, it appears that there is not a way to copy an existing class in VFP. You can subclass it- but there does not seem to be any way to copy a class Well, with the use of the Project Manager it can be accomplished quite quickly with the following steps:.. 1 Drag the source class from one library to another.

2. Rename The Class in The New Library.

3. Drag the newly named class back to the Original Library.

4. DELETE The Class from The Temp Library.

Of course, it would be nice if there was a copy button on the right-click menu or somewhere else. But heck, we can not have everything! Drag and drop In VFP 8, the Project Manager was improved by allowing you to add multiple files at once. Prior to this version, you could only add one file at a time. However, you can use drag and drop to add multiple files, and this feature has been around for quite a while. Open the Project Manager and then open Explorer. Select some files in Explorer and drag them to the Project Manager. An added benefit is that the Project Manager is smart enough to figure out what tab to put each of the different files on based on their file extensions. _VFP.SetVar ( ) This little-known function can be used to set variables in situations where you can not execute a command but you can call a function. A perfect example of when to use this is in the Report Designer. I use it all the time in The OneNTry and Onexit Expressions of The Various Bands. for Example, In The Onexi t expression of a Group Footer, you can use _VFP.SetVar ( 'rnRecordCount', 0) to clear the value of the rnRecordCount variable. Or you can use _VFP.SetVar ( 'rnCountDataGroups', rnCountDataGroups 1) to increase a variable that tracks the number of data groups processed. wildcards Some commands accept wildcards, and although this can be great to work with, it can also be dangerous. There's not much harm in entering MODI COMM myProg *. All it's going to do is open up all The Programs That Are Named Starting with MyProg. However, Issue Delete File MyProg * .prg and "danger! danger! danger!"

flashes across my mind. Be careful in how you use wildcards! Just for fun Whew! This has been an article full of information. By now your brain is probably getting fuzzy, so I'm going to end with a few fun things. Filer Years ago, Filer was what most FoxPro developers used to search and find files. After VFP 3.0, this disappeared and many developers screamed. Well, the Fox Team has listened and decided to bring back a little nostalgia. Enter the following in the Command window To See an Example of How IT Runs: Do Form (Home (1) 'Tools / Filer / Filer.scx') Search THROUGH THE NEW File and Read Up on the New Filer, Because this One is Object-Oriented and you can interact with it and implement it in your own applications. I guess you could call this FilerX! Puzzle Here's another long-lost feature of FoxPro that has been brought back in VFP 8. Enter the following in the Command window. However, be forewarned That this May Severely Reduce Your Productivity At Work! Activate Window Puzzle Error-free programs Did you know that writing error-free programs is a cinch with VFP? Just enter the following line of code in your startup program and you're all set.ON ERROR * Of course, this does not mean that your PROGRAM IS BUG Free. It Only Means That You Won't get Any Error Messages! Love your work! i know you love vfp so much thing you never want to leave it. Well, no problem. when you start up vfp, enter the FOLLOWN * NO MATTER HARD YOUTDOWN * No Matter How Hard You Try, You Can't Get Out of VFP Now. This is get-you can to let! okay, okay, i guess this Isn't Such a Great Idea. I Guess You '

转载请注明原文地址:https://www.9cbs.com/read-10661.html

New Post(0)