Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Articles
Search: 

Spaces in file and directory names
Dragan Nedeljkovich, December 2, 2002
This FAQ describes some considerations to take care of when using spaces in directory names when being used with macro substitution.
Summary
This FAQ describes some considerations to take care of when using spaces in directory names when being used with macro substitution.
Description
Why doesn't this work:
cInputDir = "C:\Program Files\Quote.com\QCharts\Symbols\"
cd &cInputDir
Because it's a macro substitution of a filename with spaces. What Fox does when it sees the & sign, is to simply replace the value of the variable with its content, inline. So the command which it actually tries to execute is
cd C:\Program Files\Quote.com\QCharts\Symbols\
The runtime parses this until the first space in the file/directory name, and concludes that the command is "cd c:\Program" and that there's an extra string, "Files\Quote.com\QCharts\Symbols\" which means nothing to it, and errors out. There are at least two ways out of this. The less good and the right way. The less good is to surround the macro with quotation marks:
cd "&cInputDir"
This works, but is not entirely elegant - we're using such a powerful thing as a macro, to convert string... into string. Since we already have that string in a variable, Fox can use it as a name expression:
cd (cInputDir)
This works with any situation where Fox needs a name of anything: in various Set ... to (cFilename) commands, in Use (cTable) alias (cAlias), in create table/cursor (cName), in Select .... from (cFromFile) into cursor/table (cToFile), in Set Printer to [name] (cPrinterName) etc etc. And it doesn't care if there are spaces in it or not, it simply works, and actually works faster than macro.
Dragan Nedeljkovich, Now officially retired
After (and/or along with) playing with Sinclair ZX Spectrum and Atari ST, I left teaching in 1986 and went through a series of machines and operating systems: CP/M (Cobol, Turbo pascal, CB-80 Basic), PDP and VAX (Cobol, Basic Plus 2, scripts), DOS 3.1 through 7.0, Windows 3.1 through XP. Ran several (almost) forgotten networks - RPTI, Lantastic, WFWG, Novell 2.x, 3.x, 4.x, Windows peer-to-peer and eventually NT and just plain IP (Win/Lin mix). After a brief flirt with Clipper in 1988, discovered Fox and went through mFoxplus 2.1 (DOS), Foxplus (Xenix), FP 1.01, 1.02, 2.0, 2.6, VFP 3.0 (briefly), 5.0, 6.0 (SP 1 to 5), 7.0 SP1, 8SP1 and now 9. Maintained one framework, created another (in DOS Fox), helped create yet another one, then used a few more - bought or in-house - frameworks. Always too lazy to type the same sequence more than four times, I'd rather write a builder or some Intellisense. Along the way, promoted a dozen beginners into experienced programmers. IOW, been there, done that, the T-shirts are recycled already, and it's still interesting and fun way to live. Retired in 2019 and finally found time for those pet projects... in Dabo/Python.
More articles from this author
Dragan Nedeljkovich, January 31, 2007
Generally, datasessions serve this purpose - they create an isolated environment where our code can run and use tables, cursors etc as it pleases, without disturbing other code. Sometimes wee need a little more granularity - to have a routine which may create any number of cursors, open additional t...
Dragan Nedeljkovich, November 1, 2006
In this article, Dragan Nedeljkovich talks about how to rebuild from Class Browser's export functionality. Ever since Visual FoxPro 3, we have had the object browser. It has this nice feature to export a class or a form as code. Five versions later, it is still there. But, it still produces out code...
Dragan Nedeljkovich, November 27, 1999
As described in the help, padr('abc',20) will give a string with 17 trailing blanks - but try padc(12, 13), or padl(date(), 20) - you will get a string containing the string representation of number 12 or today's date, padded with blanks (or any other string you choose) on the side of your choice. ...
Dragan Nedeljkovich, November 5, 2000
There's a problem of the DataEnvironment which exists in the .scx but not in the .vcx, so when a form is createobject()ed, it has no DE. There are several ways to create one - either in the form designer, or using a session class, or simply opening the tables in code and avoiding the DE altogether (...
Dragan Nedeljkovich, September 1, 2006
Following a thread on the Universal Thread, Dragan Nedeljkovich wrote this article on how to make the totals below the grid scroll horizontally together with the grid. Sometimes, we only wish we wrote this much earlier. This article describes a way to calculate those totals, creating fields in some ...