IntelliSense in Visual FoxPro
IntelliSense was advertised as something that would bring VFP up to the
level of Visual Basic but in typical FoxPro fashion the team went one
better.
IntelliSense provides a variety of services but I particularly like the
way that we can add our own entries to the FoxCode table. As an example,
if I type in a program now I get:
where the date is inserted automatically and the cursor is positioned
one space to the right of the '*--' on the first line, ready for me to
type my comments into the program. It's a big help when I'm editing
other people's code. I've always known that I ought to be commenting
my changes and I do it a lot more now that it's so easy.
How to use Intellisense
You can hack the FoxCode table directly but it's easier to start by
using the IntelliSense Manager. This is available on the
menu or by typing
DO FoxCode in the Command Window.
-
Select the Custom tab and type a new abbreviation - in this example
I've used for 'Changed By'.
-
Click the Script button and what looks like a procedure-editing
window will open.
-
Write this code in the window:
LPARAMETER
oFoxCode
LOCAL
lcDate
LOCAL
lcComment
lcDate =
DTOC(DATE())
IF
oFoxCode.Location = 1
oFoxcode.valuetype = 'V'
TEXT TO
lcComment
TEXTMERGE NOSHOW
ENDTEXT
ELSE
lcComment = oFoxCode.Abbrev
ENDIF
RETURN
lcComment
-
Save your changes by closing the edit window and the IntelliSense
Manager.
-
Open a program edit window and test the new entry by typing
. You
should see the 'CB' disappear and be replaced by the comments.
-
If it does not work, open the IntelliSense Manager and make sure that
is ticked on the
tab.
-
Debugging a script is difficult. You can insert
Set Step On
into the code to open the debug window and suspend execution but you
cannot Resume again. The best way of debugging
is to go back to the old technique of adding
DebugOut statements at crucial points.
Note that this piece of code used FoxPro's
text merge commands.
Other uses
I've also modified the IntelliSense table entries to help me write HTML. I'm
writing this page now in
VFP 7
and I've just inserted a pair of paragraph tags:
<p>
|
</p>
by typing the two-character code .
This inserts the tags then moves up a line and two spaces across so that
my text will be nicely formatted.
Further information
There's some help in VFP Help under 'IntelliSense' and 'Scripting' and
you can look at the sample entries on the IntelliSense Manager. There are more good
examples on the
VFP Wiki
under the CategoryIntelliSense heading.
|