Calvin Hsia's WebLog

thoughts from a professional developer

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

    String Optimization. How does it work?

    • 5 Comments
    In this post: Quiz: String performance optimization , I showed some very similar code with drastically different performance. When VFP sees an assignment statement like this: var = <something> here’s what happens. The variable on the...
  • Calvin Hsia's WebLog

    Quiz: String performance optimization

    • 7 Comments
    This code takes .03 seconds to run on my computer Try running it on yours. ns= SECONDS () x="" FOR i = 1 TO 30000 x=x+"OneTwoThree" ENDFOR ? SECONDS ()-ns ? LEN (x) Modified slightly, it takes 15 seconds. That's 500 times...
  • Calvin Hsia's WebLog

    Get the available paper bins from a printer

    • 5 Comments
    Sometimes you might want to find out how many paper bins a printer has. (Thanks to Barbara P for original question, code.) lcPrinterName = GETPRINTER () nPrinters= APRINTERS (laAvailPrinters) FOR i = 1 TO nPrinters IF UPPER (laAvailPrinters...
  • Calvin Hsia's WebLog

    GetLastError: how does it work with DECLARE DLL ?

    • 6 Comments
    Many Windows APIs can fail for various reasons. For example FormatMessage indicates failure by returning 0. (see GetLastError is a number. What does it mean? ) To get further information about the failure, call the GetLastErrror API, which queries the...
  • Calvin Hsia's WebLog

    GetLastError is a number. What does it mean?

    • 5 Comments
    A customer asked I'm getting an error 12 back from a GetLastError call, and I've seen a number of sites that tell me I can figure out what that error is by sending it to SysErrorMessage. But nothing I've seen shows how to declare SysErrorMessage...
  • Calvin Hsia's WebLog

    How to filter out unwanted sounds via Fourier Transform

    • 7 Comments
    In this post about The Fast Fourier Transform , I described how simple it was to create a filter to remove unwanted sound from a WAV file. In order to do that, I needed some code to read and write a WAV file. Then I used the FFT to convert to the frequency...
  • Calvin Hsia's WebLog

    The Fast Fourier Transform

    • 8 Comments
    A long time ago in college, I learned a lot about signal processing. A microphone produces a signal, and a speaker processes that signal back into sound. Why is CD quality sound sampled at 44 Khz ? Because human hearing ranges from 20-20 Khz and the Nyquist...
  • Calvin Hsia's WebLog

    A difficult debugging scenario

    • 2 Comments
    A customer had a problem with printing. I don’t know all the details about the setup. Trevor had a repro scenario in his office in North Carolina, and I used Remote Desktop to access it. It was composed of 3 virtual machines. One was a Citrix domain controller...
  • Calvin Hsia's WebLog

    Getting parameters from inherited classes

    • 0 Comments
    Visual Foxpro allows you to create a class that inherits behavior from another class. This includes properties, events and methods. The base class could have a method like this: PROCEDURE FooBar LPARAMETERS strParm as string , nParm2 as Integer...
  • Calvin Hsia's WebLog

    Creating a quick report from any cursor

    • 1 Comments
    For probably more than a decade, Fox can create a “quick report” from any table or cursor. CREATE CURSOR TEST ( name c( 10 )) CREATE REPORT dummy FROM test This will create a default quick report that can be used for any purpose. It...
  • Calvin Hsia's WebLog

    Binding to Internet Explorer Instances

    • 7 Comments
    A customer wanted to run code whenever a user started Internet Explorer. A possible solution is to use a timer to check the Running Object Table periodically: ox= CREATEOBJECT ("monitor") ox. show DEFINE CLASS monitor as Form AllowOutput...
  • Calvin Hsia's WebLog

    Strongly typed methods and properties

    • 12 Comments
    VFP allows you to generate COM servers using the OLEPUBLIC keyword. These objects can have custom properties. For example, a Customer object can have an Address property of type string. Other client applications (VFP, Excel, VB.Net, VB Script) can...
  • Calvin Hsia's WebLog

    How to use DEVMODE

    • 8 Comments
    I received a question about how to use DEVMODE . Below is some sample code that retrieves the screen’s current width/height screen resolution and rotates it for a few seconds if supported by your machine (mostly on Tablet PCs) The user’s question...
  • Calvin Hsia's WebLog

    Computer music on the radio

    • 4 Comments
    If you listen to an AM radio that’s placed near a computer, you can hear interference. I can put my radio next to my tablet and hear all the calculations being done as my ink handwriting is being converted to text. The AM frequency range is from...
  • Calvin Hsia's WebLog

    The .Object member

    • 0 Comments
    If you have an ActiveX control and you want intellisense to show just the control’s members, you can use the virtual “object” member. A control is hosted in a container, which has ambient properties For example, type this in the command window:...
  • Calvin Hsia's WebLog

    What printers are available to your program?

    • 1 Comments
    The APRINTERS function allows you to enumerate all the printers to which your application can print. ?"Printer info" ShowPrinters( 0 ) ?"More printer info" ShowPrinters( 1 ) PROCEDURE ShowPrinters(nMode) n= APRINTERS (aa,nMode...
  • Calvin Hsia's WebLog

    How do I backup files that are still in use without shutting down the application?

    • 0 Comments
    In my prior post ( Puzzle: Why does backing up a data file require web application shut down? ) the customer wanted to keep the application running while doing a backup of the data files The reason the code seemed to work in the VFP IDE is because...
  • Calvin Hsia's WebLog

    Puzzle: Why does backing up a data file require web application shut down?

    • 3 Comments
    A customer reported a problem: Customer has a VB/ASP .NET web app that uses VFP data via the provider. When they do a nightly backup of the VFP data (via a simple .CMD with XCOPY), the web app starts tossing errors as it processes SQL commands....
  • Calvin Hsia's WebLog

    Inheritance levels

    • 1 Comments
    The program below generates code to demonstrate 1000 levels of inheritance of VFP objects. The code looks like this: DEFINE CLASS c1 as c2 ENDDEFINE DEFINE CLASS c2 as c3 ENDDEFINE DEFINE CLASS c3 as c4 ENDDEFINE That...
Page 13 of 18 (434 items) «1112131415»