Local vs Private variables

I received a question:   As you know most of variables in methods and procedures are local, not private. Its very tedious to declare them as local every time. Why don’t you do something like SET PRIVATE OFF in VFP? When it is on(by default) -all variables are private by default. otherwise they are local….


My toys over the years

At the Southwest Fox conference, I showed a slide titled “My Toys” I showed the computer, the processing speed and the amount of memory in a table:     Year     Machine           CPU Speed       Megabytes        Product (Mhz*MB) 1971     PDP-8              .066                  .004                  .000264 1981     IBM PC             4.77                  .25                    1.1925…


Customer question: detectan F10 keypress

I received this question:   Is there any way to detect an F10 keypress in the KeyPress() event? It looks like F10 is a system key of some sort (ALT?).     It’s similar to this post: How to hook command window keystrokes   I just modified the code a little to hook the WM_SYSKEYDOWN…


Tools->Options->Dump out settings changed

Try this:   ACTIVATE WINDOW “debug output”     Now choose Tools->Options. Shift-Click on OK   You’ll see the options dialog settings echoed to the Debug Output window. (in versions prior to VFP9, it will be echoed to the Command window)   The DoHistory is also echoed to the same window.   Try this:  …


Why did I get an error while publishing Photos?

I was publishing some photos/movies of my 27 month old son taking ski lessons (see Sharing Digital Pictures of your friend’s ) and I received an unexpected error. I narrowed down the code to this fragment:     CPATH= “c:\inetpub\wwwroot\” CREATE TABLE (CPATH+”temp”) (name c(10)) APPEND BLANK   DELETE ALL PACK     This is…


Database Events in Stored Procedures can have default code

Try running this code:   CLOSE DATABASES all CREATE DATABASE test MODIFY DATABASE nowait   Now choose Database->Properties (or Alt-Enter) to bring up the Database Properties dialog. This is where you can choose Database Events to fire. Try selecting a few and then hit the Edit Code button. Something like this will show in the…


Do you know everything about Factorials?

When I was in 7th grade at Amity Junior High School in Orange Connecticut, I gave a presentation on Factorial numbers.   Here’s some interesting code:     FOR i = 1 TO 80       ?i,Factorial(i),SQRT(2*PI()*i)*(i/EXP(1))^i ENDFOR   PROCEDURE Factorial(n)       IF n=1             RETURN n       ENDIF RETURN n*Factorial(n-1)         What do the…


Optimization question from a reader

I received a question:   …I’ve always been curious about code like this: IF wParam=ASC(“a”)     wParam=ASC(“b”) ENDIF Is it more appropriate to think of ASC(“a”) as the Fox equivalent of a C ‘a’, or is it an actual function call every time through?   It’s easy to test this. Try running this code:  …


How to hook command window keystrokes

A customer asked how to hook events for the command window.     The sample below uses BINDEVENT to hook the WM_KEYDOWN, WM_KEYUP and WM_CHAR messages. It changes all ‘a’ keystrokes to ‘b’.   * From C:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Include\winuser.h   #define GWL_WNDPROC         (-4) #define WM_KEYDOWN                      0x0100 #define WM_KEYUP                        0x0101 #define WM_CHAR                         0x0102…


A Visual Basic COM object is simple to create, call and debug from Excel

At the SouthWest Fox conference in Phoenix I asked “How many people have Visual Studio?” Almost everybody raised their hand. Then I asked “How many people have used it?” Very few hands were raised. Here’s a simple way to create some VB.Net code and call it from VFP or Excel   Start Visual Studio. Choose…