Tuesday, December 09, 2008

VFP: File and folders via indirection

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.

Labels: , ,