Session E-SENSIntroduction to IntellisenseฎTed Roche
|
![]() | To "UnDo" an automatic expansion, Ctrl-Z twice followed by the End key. To prevent command expansion, use Ctrl+Spacebar instead of a plain space. |
Strong typing is a characteristic of many languages where a memory variable must be declared to be of one specific data type, and attempting to later change that type, or assign an inappropriate value to the variable, will generate an error. Visual FoxPro, by contrast, is a loosely typed language, where private variables don't even need to be declared, and the datatype of variable can be changed on the fly. While this features has its benefits, it is much more difficult for IntelliSense to provide a lot of support to a loosely-typed language.
In the next version of Visual FoxPro, support will be provided to define memory variables of a particular, strong, type by using the AS clause:
References to those variables within the code window will produce appropriate prompts for that type of datatype or object.
There are a couple of new files, new memory variables, and new menu commands to make Intellisense work. We'll detail them here.
_FoxCode: system memory variable that stores the path and location of the FoxCode table used to supply keyword expansion, macros, data types, and more
_CodeSense: system memory variable that points to the main FoxCodeAPP file an application that contains the routines for
_VFP.EditorOptions a string to enable, disable, or modify the behaviors of Intellisense features. Typically, for each entry, an uppercase letter enables the function. A lowercase letter indicated it would not appear automatically, but be available via a menu shortcut key. See Table 1
Editor Option | Function |
Notes |
---|---|---|
L | List Members | Upper case L causes List Members to appear automatically. Lowercase L means that the List Members will only appear when selected from the menu (Edit|List Members) or the menu shortcut (Ctrl+J). Omitting the L altogether means that the List will not appear and the menu option is disabled. |
Q | Quick Info | List the List Members function, a capital Q displays Quick Info (prompting for parameters) immediately, while a lowercase Q means that Quick Info will only appear if selected from the Edit menu or the Ctrl+I shortcut. |
K | Hyperlink | Case doesn't affect this one. If upper or lower case is present, typing in typical internet addressed (www. or http:// or many of the others) in a code editor or the Command Window creates an active hyperlink that can be clicked to start a session. Unlike the other options, this is meant to work within the runtime as well! |
W | Drag and Drop Between Words | The default behavior for dragging and dropping text has changed between different versions of VFP, and now you have control over how you think it should work. In the default behavior (W not included), dragged text can be dropped anywhere. If W is specified, either case, text can only be dropped at the beginning of a word, and not in the middle of it. |
Table 1: _VFP.EditorOption values and their meanings
The FoxCode.DBF table contains the meta-data that describes how Intellisense should work. See Table 2.
Fieldname | Datatype(Size) | Purpose |
---|---|---|
Type | C(1) |
Identifies which type of record this is. Different records can use the other fields in different ways. (C)ommand expansion (F)unction expansion. (S)cript to be called from other items COM (O)bject type info (P)roperty of a VFP object Data(T)pes (V)ersion information a special one-record entry in the FoxCode table.
|
Abbrev | C(24) | Abbreviation the minimum keystrokes that will uniquely identify this record, and invoke Intellisense. |
Expanded | C(26) | The command or function in ABBREV, expanded to its full text |
Cmd | C(15) | The command to execute. |
Tip | Memo | The Tool or Value Tip to display parameters? |
Data | Memo | A storage place for code or data used by a script to expand this item. |
Case | C(1) |
Whether the case is transmuted when returned: (U)ppercase the result (L)owecase the result (M)ixed (P)roper
|
Save | L(1) | According to Help, "specifies whether the record is saved when the field updated." |
TimeStamp | DateTime | At last! A powertool that saves timestamps using the datetime function! |
Source | Memo | Not sure about this one. It is undocumented, and only contains the word "RESERVED" in my early version |
UniqueID | C(10) | SYS(2015) generated ID |
User | Memo | Presumably a field left for developers. A place to hook in DBCX-like functionality, perhaps. |
Table 2: The fields of FoxCode.DBF and their functions.
Finally, the FoxCode object is an object passed to the script code to be executed (in type "S" records) and it exposes the parameters of the environment. All of the variables available in the FoxCode Record Abbrev, Case, Cmd, Data, Expanded, Save, Source TimeStamp, UniqueID and User are present, as are a few other properties.
CursorLocChar is a string that holds a single character used as a marker to reposition the cursor at the end of the operation. Like CEE, mentioned below, the default seems to be the tilde {~} character.
DefaultCase holds the case setting of the Version header record, and is the default if nothing else is specified.
Filename holds the name of the file being edited, blank if in the command window or snippet editor.
FullLine contains the complete line of code being edited.
Icon, ItemScript, Items, and ItemSort are used to store the items in the dropdown list, present an icon for them, script how they are to work, and sort the list of items.
MenuItem: stores the selected item number from the dropdown, for use in a post-selection script
ParamNum is used for tracking parameters within the script. The Help file says it
UserTyped has the original text typed in by the user.
Up to this point, we've looked at what is provided by Microsoft. But the good news is that the IntelliSense engine and the metadata driving it are open for developers to extend in a number of ways.
First, consider using the IntelliSense Manager (Figure 7, Figure 8, and Figure 9). The IntelliSense Manager is available off the Tools menu, the Wizard menu (under "All Wizards
") and by issuing the
command:
The Options tab allows setting the global settings for capitalization of commands and functions. It also is a place to perform routine maintenance:
Cleanup MRU Lists: removes files from the MRU lists if they no longer exist. Make sure that your network connections are running before you run this, or all of your network-based files will be removed.
Zap MRU Lists: removes all files from the list. The MRU lists are kept in the FoxPro resource table.
Cleanup FoxCode: "cleans up" the table. Presumably a PACK. Did not seem to do anything on my version.
Restore FoxCode: restores the developer's FoxCode table from the master table kept in the VFP root directory.
Import: allows the addition of more records to the FoxCode table. Records have a matching structure to the FoxCode table. See HOME() + "Tools\FoxCode" for some add-on tables.
View FoxCode: allows live editing of the table in a browse window.
The second tab on the IntelliSense Manager allows for the maintenance of the data type ("T") records. These include all of VFP's bases classes, as well as a types we may not be familiar with: Decimal, Boolean, Variant and VOID. Unchecking the box at the left of each column flags the record for deletion in FoxCode. Checking it again restores the record.
Finally, the Customize Tab on the IntelliSense Manager allows for the editing and maitenance of
While the next version of Visual FoxPro is still some ways off, you can have many of the features available in IntelliSense in the current version of FoxPro. Two programs are included on the conference CD: CEE and ISX
CEE, the Cob Editor Extensions, was written by veteran DevCon speaker Randy Wallin and co-worker Ryan Katri of COB System Designs, Inc. (http://www.cobsystem.com) and is available for free download from their website. CEE provides keyword expansion (although you have to fill in the table yourself), macro capabilities, recursive evaluation (so a macro can contain a macro that contains a macro, and so forth). Versions are available for FoxPro 2.x and each major version since.
dFPUG c/o ISYS GmbH Frankfurter Str. 21 b
D-61476 Kronberg |
per Fax an: +49-6173-950903 oder per e-Mail an: |
ฉ Texte, Grafiken und Inhalt: ISYS GmbH |