Hidden Secrets of the VFP IDE, Part 1

zhaozj2021-02-16  114

Hidden Secrets of the VFP IDE, Part 1

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 series of articles, Cathy Pountney will uncover 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.

In Part 1 of this two-part series, I'll uncover many hidden secrets in several areas of Visual FoxPro. I'll discuss various designers, a few controls, the Property Sheet, the Document View, the Find dialog, IntelliSense, and SEVERAL Tools and Utilities Included WITH VISUAL FOXPRO. IN Part 2 of this Series I'll Reveal Secrets of the Command Window and SEVERAL COMMANDS, AND WRAP UP UP UP UP UP UP UP UP Up

Report Designer

Of Course You Knew I Was Going to Start With My Favorite Designer, The Report Designer!

Navigate between objectsIn VFP 8, you can navigate between controls on a report simply by using Tab to go to the next control and Shift Tab to go to the previous control. In versions prior to VFP 8, you have to use Ctrl Tab to First Get Into Tab Mode, And The You Can Tab Through Objects with Tab and Ctrl Tab.

Edit An EXISTING LABELTO EDIT A Report, Simply Select The Object and the Press Ctrl E. This puts you in int the text on the label.

Forms Designervfp Has Some Tricks for Working with Containers.

Drilling into containersWorking with container objects, such as a pageframe, can be difficult sometimes. However, you can quickly edit an object inside of a container by using Ctrl Click over the object. This passes through the container and lets you edit the control inside of the container.When you have containers nested within containers, you can use Ctrl Shift Click to drill to the deepest level. For example, if you have an optiongroup on a page of a pageframe, you can position your cursor over one of THE OPTIONBUTTONS, PRESS CTRL SHIFT CLICK, AND VFP DRILLS THROUGH The PageFrame, And THROUGH THE PAGE

Listbox and comboBox Controls

THE "/" Character Has Special Meanings When Used In ListBoxes and ComboBoxes-See Table 1 for Details.

Table 1. Using the "/" Character in ListBoxes and ComboBoxes.

Charr

Description

/

IF the "/" is buy as the first character, the entire item is disabled.

//

BECAUSE A SINGLE BACKSLASH HAS SPECIAL MeANings, IF you truly Want A "/" in The item, you must use two twoslashes together.

/]

BECAUSE A SINGLE BAVASLASH AT ITHHOULD BE DISABED, IF YOULY HAVE A ITEM THATS WITH A BAVE AN ITEM THATS WITH A Backslash, You Have to Use "/]" To indeicate That this sales.

/ -

.

Grid Controls

Grids Have Always Been Somewhat Difficult To Work with, Especially For New Developers, Because Some Things Just Aren't Intuitive.

Adding controlsAs columns are added to a grid, you automatically get two controls-a header control called Header1 and a textbox called Text1. However, in many cases you need something other than a textbox. Unfortunately, it's not easy to figure out how to add and delete controls inside of columns.The first thing you have to do is drill into the grid. Place your mouse over one of the rows of the column you want to change and press Ctrl Click. Be sure you're on one of the Data Rows of the Grid and not the header row. You'mbelly to drag and drop the object you want into the color.

When you drop the object on the column, it does not look like anything happened. However, if you look at the Property Sheet and drill into the column, you'll see that the original Text1 textbox is there as well as the object you Just Added. The CurrentControl Property of The Column Is Still Set To Text1, Which is why you don't see your object.

If you were to change the CurrentControl property of the column to the name of the object you just added, the grid would show your object. However, if you do not really need the original Text1 textbox, you might as well get rid of it And Not Worry About Having to Set The CurrentControl Property.

Deleting controlsIf you thought adding a control was not very intuitive, I'm sure you're going to roll your eyes when you learn how to delete an unwanted control. It's about as unintuitive as it can get. First, select the control you want to delete in the Property Sheet. Next, use your mouse to click on a data row in the grid and then press the Delete key to delete the control. Even though nothing may have appeared visually in the grid, if you look at the Property Sheet, the object will be gone now.NavigationGrids present another interesting problem to end users. Users are trained that Tab takes them to the next control. However, when inside a grid, Tab moves between columns in the grid. So how does a user Get out of the grid? The answer is to use ctrl tab to navigate to the control after the Grid or Use Ctrl Shift Tab to Navigate to the Control Before The Grid.

The property sheet

There Area SEVERAL DIFFERENT Keyboard Shortcuts for Invoking, Navigating, and Setting Values ​​In The Property Sheet (See Table 2).

Table 2. Keyboard Shortcuts for Invoking, Navigating, and Setting Values ​​In The Property Sheet.

Keyboard Shortcut

Description

Alt DoubleClick

Pressing this Combination from The Forms Designer Activates The Property Sheet, Even if it isn't displayed.

RightClick (Property Sheet)

Pressing RightClick on an unused area of ​​the Property Sheet brings up a menu with additional options. The Non-Default PEMs Only option toggles between displaying all PEMs and only those with non-default values.

RightClick (property)

Pressing RightClick ON A Property with a Menu with the zoom option. Select zoom to display a larger edit window for the character value of the protection.shift uparrow / downarrow

..........................

.

WHEN ON A Logical Property, a period Toggles Between .t.

Ctrl Pageup / Pagedown

..............

Ctrl home / end

THIS Combination Goes To The First Or Last Object In The Property Sheet.

Ctrl alt

.

Editor

.

Document ViewThe Document View is a great tool that lets you navigate through the various procedures and functions. But did you know that you do not have to activate the Document View window to take advantage of this feature? As long as the Document View window is open, you can press Ctrl PageUp and Ctrl PageDown to navigate through the items in the list. you do not have to jump to the Document View window, do your navigation, and then jump back to the program.

Caseif You're A Stickler About Uppercase and LowerCase, You Can Use Ctrl U To Convert The Highlight Text To Lowercase and Ctrl Shift U to Convert To Uppercase.

BookmarksBookmarks are great when you're working with a lot of code. You can read through some code and see a reference to another method or function. Of course, you need to go look at that code and then jump back to where you are right now when finished. This can be done more quickly with a bookmark. Just bookmark the existing location by pressing Alt Shift F2. now go to the other code you need to look at, and when you're finished, use F2 or Shift F2 to go back to the previous code. When you have to jump among several sections of code, this can really be a time-saver if you mark each section with a bookmark.Find dialog-escapingTable 3 shows the effects that using the " / "Character Has in the Find Dialog. It doesn't actually search for the backslash character; instead, it triggers the find dialog to find Other Special Characters.

Table 3. Using the "/" Character in The Find Dialog.

Charr

Description

/ t

FINDS TAB Characters

/ r

FINDS the end of it line

/ N

FINDS the Beginning of Each Line

//

FINDS THE "/" Character

Both the "/ r" Search and the "/ n" Search Have Some Quirks. Enter "/ R" INTO The Find Dialog and Press The Find Next Button. At First It May Not Appear as if anything is happensing; however, Keep Pressing The Find Next Button and Eventually You'll See The Highlight Square in your code at the first blank line.

What's happening is that as the find goes to the end of each line of code, the cursor is not highlighted-but it really is sitting at the end of the line. Each time you press Find Next, it goes to the end of the NEXT LINE, But you don't have a.com.............................................................................................................................................. IS TRUE WHEN DOING A Search for "/ n" Except The Cursor Goes To The Beginning of Each Line. However, When Searching with "/ N" You "//" Search Treats The First " / "as an escape and then treats the second" / "as the character being searched for. Therefore, searching for" // "will find single backslashes. However, this really is not necessary because a single backslash in the Find dialog will Find all the backslashes.

Find Dialog-Wildcardsone of The Checkboxes on The Find Dialog Is Use Wildcards. Checking this option allow for Wildcard Matching. Table 4 Shows What's Available.

Table 4. Using Special Characters for Wildcard Matching in The Find Dialog.

Charr

Wildcard Match

?

Single Character

*

Multiple Characters

#

SINGLE DIGIT

<

Match Beginning Characters

>

Match Ending Characters

[]

Character List

[!]

Exception List

THE "?", "*", And "#" Are Pretty self-evlantory, but some of the other iplanatory, but some explanation. Searching for "" FINDS ONLY Those Items That End with "fox". Therefore, it Would Find The Lcfox Variable, IT WOULD FIND THE LCFOX VARIABLE , But it's won't find a variable named lcfox1.the "[" and "]" Characters Can Be buy. for example, "lcfox [1-2]" Will Find Variables named LCFOX1 and LCFOX2 .,...................................

Using the "!" ALONG WITH THE SQUARE BRACKETS CHANG WITH THE BE An Exception List Rather Than The List You're Looking For. Searching for "LCFOX [! 2]" Will Find LCFOX1, LCFOX3, LCFOX4, AND SO ON, But IT Won't find lcfox2. Similarly, "LCFOX [! 2-3]" Will Find LCFOX1 and LCFOX4, But it't Find LCFOX2 and LCFOX3.

IntelliSense

IntelliSense was introduced with VFP 7, and I can easily say that it's worth the price of the upgrade for just this one feature. Personally, I can not live without IntelliSense anymore. If I have to work on a pre-VFP 7 project, IT Drives ME NUTS. IN FACT, I Usually Do All My Editing In VFP 7 or 8 and the use the Older Version Just To Compile IT.

Operator expansionWith IntelliSense came a lot of keystroke-saving features, such as operator expansion. How many times have you typed lnCount = lnCount 1? I swear that I've done it a million times by now. But these days, I can cut That Typing to Lncount , Press the Spacebar, And That's it. VFP will expand it out to what i want. Table 5 shows all of the operator expected options available.table 5. Operator Expans Options.

This ...

Expands to this

Cvar

CVAR = CVAR 1

Cvar -

CVAR = CVAR - 1

Cvar =

CVAR = CVAR

Cvar- =

Cvar = CVAR -

CVAR / =

Cvar = CVAR /

Cvar * =

CVAR = CVAR *

IntelliSense hotkeysI've seen a lot of developers start typing, take advantage of IntelliSense, and then realize they made a mistake. What they do next is start backspacing until they get back to the "." However, that's not necessary. Ctrl J will list the members of the object without backing up to the period. You can also use Ctrl J after the equal sign to list the values ​​associated with a particular property. And Ctrl I can be used to display Quick Info.

Put The Following Sample Code Into a Program and Then Position Your Cursor As Instructed and Press The Appropriate Ctrl J Or Ctrl I to See How this Works.

* - IntelliSense

Local Loform As Form

* - Ctrl J to List Members

* - (Position Cursor After the Period)

Loform.

* - Ctrl J to List Values

* - (Position Cursor After the Equal Sign)

Loform.Alwaysontop =

Loform.BorderStyle =

* - Ctrl I for Quick Info

* (position cursor on any of the parameters)

Seek (CMYVALUE, CMYTABLE, CINDEX)

Predefined "U" recordsIntelliSense is completely extensible because everything is stored in a DBF table. You can view this table by entering USE (_FOXCODE) SHARED into the Command window. If you scroll near the bottom of this table, you'll see several records with a type of "U". The VFP team has preloaded several examples of how you can cut down on your keystrokes by entering records of these types. you can copy these records into new records and start adding your own for things you do on a Regular Basis.Table 6 Shows The Predefined "U" Records in VFP 8. Some of these Work in The Command Window and Others Work WITHIN THE Editor for Programs and Method Codes.

Table 6. Predefined "U" Records IN VFP 8.

This ...

Expands to this

MF

MODIFY FILE

MC

Modify Command

DC

Define Class

ZDEF

Show #defines

Zloc

Show local variables

DOCASE

Do Casecase PortHerwiseEndcase

Dowhile

Do Whilenddo

IFend

IFENDIF

IFELSE

IFELSEENDIF

Trynd

TrycatchFinalLinAndtry

Foreach

For eachendfor

Forend

Forendfor

Scanend

Scanendscan

TEXTEND

Text to Noshow TextMergeEndtext

Withend

Withendwith

I encourage you to create your own "U" records to simplify your daily typing. It's probably no surprise to you that I've added a record to my _FOXCODE table to expand MR to MODIFY REPORT. Another change I make is to change the MF Record to Say Modify Form Instead of Modify File.

VFP Tools and Utilities

Visual FoxPro is full of many native tools and utilities to help you be more productive each and every day. Some of these have been around for years and years, and some are new to VFP 8. I'm not going to go to great lengths to describe how to use each of these tools, because each one could be an article in itself. I just want you to be aware of these tools so you can use them.Class browserThe class browser has a few Most Recently Used (MRU) lists ................... ..

Using RightClick with the View Class Code button changes the behavior slightly. The editor window that appears with the code is smaller and fits within the right frame of the class browser. In fact, you can click on the View Class Code button to bring up the Code for one class, and then use rightclick to bring up the code for a second class.

One of the most useful and lesser-known features of the class browser is its drag-and-drop abilities. Highlight a class in the class browser, and then drag the icon that appears in the upper left corner of the class browser to a form . The max! You can.

DebuggerDid you know that you can drag and drop from within the debugger? You can highlight a variable in the Trace window and then drag it to the Watch window. This can save you time since you do not have to type out long variable names, And it reduces the chances of a type. You can also Drag a variable from the watch or local window to the command window or the editor.

Another great feature of the editor is that you can change the values ​​of variables at will. Once a variable is in the Watch window or Local window, you can highlight the Value of the variable and type in whatever you want. This is great when you realize that something is set wrong and you want to continue running the program to see if the rest of it runs okay. In addition to typing the new value, you can also type an expression that gets evaluated immediately. For example, on a date variable You can type date () and as soon as you press Return, the variable is set to the capital date.code references-new to

8.0

I

n my opinion, this tool is not named properly because it's really a giant search tool-one that works way beyond "just code." This tool lets you search through an entire project for a certain string. It can search programs, classes, Reports, And All of The Different Files in a project. It also search..

Besides being a search tool, it's also a replace tool. You can actually tell it to replace all of the occurrences it found, or even specific occurrences. This makes massive changes to your application much simpler!

Task Pane-new to 8.0The Task Pane is a portal to many different aspects of Visual FoxPro, including the Solutions Samples and the Visual FoxPro Community. As with many tools in Visual FoxPro, you can customize this tool until your heart's content. The customization Can Be Passed Back and Forth Between Others by Exporting and Importing Simple XML Files. It's Expected That Many Third-Party Tool And Utility Developers Will Offer Own Add-ins to the task pane.

Toolbox-new to 8.0The Toolbox can be considered a replacement for the Form Controls toolbar-on steroids! You can add all of your commonly used classes to this tool so that you can more easily design your forms. But it has some other advantages that are not as well-known.One category in the Toolbox is text Scraps. It's meant to let you predefine a set of text and then paste it to your programs and method code. It's not just limited to VFP, though. you can also Paste these text scraps to Other Applications, Such as Microsoft Word.

One of the items you can add to the Toolbox is a file. However, you can use this feature to add some things that are not really files. For example, add a dummy file and then change the properties to a URL. When you select this item from the Toolbox, Internet Explorer (or whatever browser you have set up) pops up and attempts to go to that URL. So if there are a few Web sites you visit on a regular basis during development, put them in the Toolbox For Quick and Easy Access.

Another thing you can do with the file option is point to a directory. You have to first define a dummy file and then change the properties to go to the directory instead of the file. When you choose this option from the Toolbox, Explorer pops up .

Foundation classesTake a look in the FFC directory within VFP's home directory (DIR HOME (1) 'ffc /*.*') and you'll see tons of classes already defined for you. These classes were created by the VFP team to help you with your applications. Some of the classes are just subclasses of the VFP base classes. However, many others are classes that you can use within your applications, such as the class to display a progress thermometer.Solutions samplesEnter the following command in the Command Window and you may be surprised by what happens:

Do Home (2) 'Solution / Solution.App'

As you navigate through the tree structure, you'll see tons of examples of things you might want to do in your application. The user interface gives you the ability to run the sample or look at the code to see how it's done. This is A Great Learning Tool for Figuring Out How To Do THINGS IN VFP.

HexEditIf you've ever needed to use a hex editor to hack a file, you'll know what a lifesaver this program can be. Or if your curiosity is driving you nuts, you can use the HexEdit program to peek at a DBF file and See Exactly How It Stores The Data. This Can Be a Great Learning Experience!

You Can Find this at C: / Program Files / Microsoft Visual FoxPro 8 / Tools / Hexedit / Hexedit.prg.

GenDBCWhen you run this program, it creates all the code necessary to re-create your DBC. This can be great for helping you get a new application installed and created. No need to send all the data files. Instead, when you're ready to deploy your application, run this program on your machine and put the newly created program with your project. Have your installation program run the program generated by GenDBC, and the new installation will be up and running in no time.It's also a great way to get one or two files copied into another DBC and retain everything about them. Run GenDBC on the original DBC. Then modify the program it created and strip out everything except the code that generates the few files you want. Change the name of the DBC In the program and reer it to add these files to a different dbc.

You can Find this at C: / Program Files / Microsoft Visual FoxPro 8 / Tools / gendbc / gendbc.prg.

xSourceSometimes the best to way to learn about something is to dive into the code behind it. Many of the tools and utilities of VFP are actually written with VFP itself! The source code for all of those tools is included in a zip file stored in the C: / Program Files / Microsoft Visual FoxPro 8 / Tools / xsource directory When you have some time, unzip this file and start diving in to see how the VFP team has accomplished many great things in the native VFP tools and utilities..

"AH HA"

I always enjoy writing about "tips and tricks" such as the ones in this article. Even experienced developers are bound to have some of those "ah ha" moments. There's so much in FoxPro that it's hard for any one person to know everything. In the next article of this series I'll cover the Command window, some commands, and a whole array of miscellaneous ideas.To find out more about FoxTalk and Pinnacle Publishing, visit their Web site at http://www.pinpub.com /

Note: this is not a Microsoft Corporation Web Site. Microsoft Is Not Responsible for ITS Content.

This article is reproduced from the thismonth 2004 issue of FoxTalk. Copyright 2004, by Pinnacle Publishing, Inc., unless otherwise noted. All rights are reserved. FoxTalk is an independently produced publication of Pinnacle Publishing, Inc. No part of this article may be used or reproduced in any fashion (except in brief quotations used in critical articles and reviews) without prior consent of Pinnacle Publishing, Inc. To contact Pinnacle Publishing, Inc., please call 1-800-788-1900.

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

New Post(0)