Home » Uncategorized » VFP: File and folders via indirection
Dec
09

Last night one of my clients was implementing their vertical market application half way around the world. The onsite support people were reporting an error when the app was started: “Invalid path or file name.”

Thanks to the new error handler we implemented in the app I tracked this problem down to a single line of code:

CD &lcDataPath;

Looking at the value of lcDataPath it became instantly apparent what the problem was, spaces in the folder name. The tech support person right away explained to me the standard for the install is no spaces in the folder names. This site deviated from the standard folder name recommended by my customer. Now she knows exactly why the original developers proclaimed this “requirement” years ago.

I have not been burned by spaces in code for a long time because I always use indirection in my code whenever I deal with file names or folders.

CD (lcDataPath)
USE (lcFileName) IN 0 SHARED AGAIN
DELETE FILE (lcFileName)

I posted this issue on Twitter earlier today and Andrew MacNeill noted this is probably a great rule to add to Code Analyst up on VFPX. I agree. I am now curious how many developers do not test their applications in folder structures with spaces in the name. I just checked my development machine and all my test folders are space free. But I do install my applications on a virtual machine in the Program Files folders and this tests out the space problem.

Yet one more reason why we have standards at White Light Computing and why the adoption of industry best practices gives us more solid deployments and apps in production. Fortunately the onsite tech people were okay with renaming the folder, otherwise my customer would have been hiring us to review the application for other macro expansion gotchas.

, ,

3 Responses to “VFP: File and folders via indirection”

  1. January 22nd, 2009 at 16:03 | #1

    I find a lot of them, even among developer tools. Usually I spot them right away since at least on my XP machines my projects are all stored in C:\Documents and Settings\name\My Documents\Projects. There’s three spaces in there. With this structure I also run into the maximum path length of 260 when copying some of the sample provided by Microsoft into the projects folder provided by… Microsoft. No wonder on Vista it’s now C:\users\name\documents… ;)

  2. March 10th, 2009 at 09:22 | #2

    I was a convert from macro expansion years ago. Initially it was due to speed but also because of needing to escape periods in file names, etc. Using the parenthesis also executes faster. I’m amazed at how many programmers still default to using macro expansion. Old habits I guess.

  3. April 8th, 2009 at 00:03 | #3

    Curiously, I’ve always intentionally used folders with embedded spaces — both because I find them more readable and also because that means that the problem will always have to be solved on my machine first anyway.

Add reply