Calvin Hsia's WebLog

thoughts from a professional developer

October, 2005

  • Calvin Hsia's WebLog

    Local vs Private variables

    • 3 Comments
    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...
  • Calvin Hsia's WebLog

    My toys over the years

    • 8 Comments
    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...
  • Calvin Hsia's WebLog

    Customer question: detectan F10 keypress

    • 2 Comments
    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...
  • Calvin Hsia's WebLog

    Tools->Options->Dump out settings changed

    • 7 Comments
    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...
  • Calvin Hsia's WebLog

    Why did I get an error while publishing Photos?

    • 3 Comments
    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...
  • Calvin Hsia's WebLog

    Database Events in Stored Procedures can have default code

    • 3 Comments
    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...
  • Calvin Hsia's WebLog

    Do you know everything about Factorials?

    • 3 Comments
    When I was in 7 th 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 ...
  • Calvin Hsia's WebLog

    Optimization question from a reader

    • 1 Comments
    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? ...
  • Calvin Hsia's WebLog

    How to hook command window keystrokes

    • 2 Comments
    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...
  • Calvin Hsia's WebLog

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

    • 8 Comments
    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...
  • Calvin Hsia's WebLog

    Balloons and Planes: cabin pressure

    • 6 Comments
    Next time you’re on a plane (or a submarine!), take along some scotch tape and a balloon. While you’re on the ground, waiting for take-off, inflate the balloon. Wrap the balloon with the tape around the equator and note how the tape constricts the...
  • Calvin Hsia's WebLog

    Replace VFP Native dialogs with your own

    • 4 Comments
    I wrote a sample while developing the MENUHIT feature that shows how to replace a native VFP dialog. The code below replaces the Add Property dialog, adding such features as preserving user CaSe for properties and adding to the Favorites tab using the...
  • Calvin Hsia's WebLog

    Ctrl-C to capture MessageBox and dialogs

    • 4 Comments
    There was a tip at SouthWest Fox conference attributed to Drew Speedie . Ctrl-C on an error dialog captures the text of the dialog including the error message to the clipboard. Try this: Type x=y in the command window and hit enter to cause...
  • Calvin Hsia's WebLog

    Run the wizards modelessly

    • 0 Comments
    Most of the wizards that are shipped with FoxPro are modal forms. You can run them Modelessly, which means you won’t be in the “Wizard” mode and so you can go to the command window and type a command, or inspect some of the wizard variables. ...
  • Calvin Hsia's WebLog

    Why can't I browse my table?

    • 3 Comments
    You can open a table with a UNC path in it, such as USE \\myserver\myshare\path\table or USE \\123.456.123.123\myshare\path\table or USE h:myshare\path\table && where h is mapped to a network drive or USE \\www.myserver...
  • Calvin Hsia's WebLog

    That was the worst natural disaster to hit the US

    • 7 Comments
    A coworker’s family was hit hard by Katrina. She’s collecting donations in our cafeteria today and tomorrow. Don’t be surprised if you see more Foxpro conference bags/backpacks/t-shirts in Mississippi ! Here’s her blog post about it: Save Waveland...
  • Calvin Hsia's WebLog

    Find out when your password expires

    • 2 Comments
    I didn’t like to get the warning that my password expires 14 days before. I like to wait til the last minute, cuz then I’ll have to change it less often. Thus I’d like to make the warning come up later. Just change this registry value: HKEY_LOCAL_MACHINE...
  • Calvin Hsia's WebLog

    What is the workarea alias when a trigger is executed?

    • 3 Comments
    When a trigger fires, VFP code is executed. What is the workarea while executing that code? CREATE DATABASE xx CREATE TABLE temp ( name c( 10 )) CREATE TABLE AnotherTemp ( name c( 10 )) CREATE TRIGGER ON temp FOR INSERT as name !=ShowAlias...
  • Calvin Hsia's WebLog

    DynamicBackColor

    • 2 Comments
    A customer asked about how to change the colors in a grid dynamically. The code below changes the 3 rd column’s backcolor if the row is selected. You can change the code to be based on a value in the row too. PUBLIC ox USE ( SET ("Resource...
  • Calvin Hsia's WebLog

    String Optimization: More detail

    • 3 Comments
    In the prior post ( String Optimization. How does it work? ) I described an optimization of how the Assignment statement calls the expression evaluator for string concatenation statements. There are certain limitations with this optimization. For example...
Page 1 of 1 (20 items)