Welcome to MSDN Blogs Sign in | Join | Help

September 2005 - Posts

String Optimization. How does it work?

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 left is analyzed,
Posted by Calvin_Hsia | 5 Comments
Filed under:

Quiz: String performance optimization

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 slower! ns= SECONDS () x="" FOR
Posted by Calvin_Hsia | 7 Comments
Filed under:

Get the available paper bins from a printer

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[i,1]) = UPPER
Posted by Calvin_Hsia | 5 Comments

GetLastError: how does it work with DECLARE DLL ?

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
Posted by Calvin_Hsia | 6 Comments

GetLastError is a number. What does it mean?

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. It doesn't
Posted by Calvin_Hsia | 5 Comments

How to filter out unwanted sounds via Fourier Transform

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
Posted by Calvin_Hsia | 5 Comments
Filed under:

The Fast Fourier Transform

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
Posted by Calvin_Hsia | 7 Comments
Filed under:

A difficult debugging scenario

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,
Posted by Calvin_Hsia | 2 Comments
Filed under:

Getting parameters from inherited classes

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 When designing
Posted by Calvin_Hsia | 0 Comments
Filed under:

Creating a quick report from any cursor

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’s similar to choosing
Posted by Calvin_Hsia | 1 Comments
Filed under:

Binding to Internet Explorer Instances

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 = .f. left =
Posted by Calvin_Hsia | 7 Comments

Strongly typed methods and properties

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 see
Posted by Calvin_Hsia | 10 Comments
 
Page view tracker