Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
'CD' Command
Message
From
18/05/2001 15:06:04
David Fluker
NGIT - Centers For Disease Control
Decatur, Georgia, United States
 
 
To
18/05/2001 13:58:51
Patrick O'Neil
American Specialty Information Services
Roanoke, Indiana, United States
General information
Forum:
Visual FoxPro
Category:
Other
Title:
Miscellaneous
Thread ID:
00508322
Message ID:
00508937
Views:
18
>try:
>
>LOCAL gcPath
>gcPath = "C:\Program Files\MyProgram\"
>CD "'" + &gcPath + "'"
>
>or
>
>LOCAL my_command_string
>my_command_string = "CD 'c:\Program Files\MyProgram\'"
>&my_command_string



Patrick,
You don't need the extra quotes. CD "&gcPath" or CD (gcPath) will work fine. Here's why. In the command CD Path, the argument Path is not a variable, but a name expression. At compile time, a token is created for CD and a representation of the argument. You can see what this looks like if you open an FXP file with a Hex editor or NotePad. At runtime FoxPro parses the tokenized lines and sends the token and what follows to the interpreter.

So:
CD c:\windows -- c:\windows is sent to the interpreter and you change to the c:\windows directory.
CD c:\program files -- sends c:\program, because FoxPro stops at the space, and unless there is a c:\program directory, an error occurs.
CD "c:\program files" -- sends c:\program files because FoxPro Evaluates "c:\program files" as a string.

Now, if cDir = "c:\program files"...
CD cDir -- sends cDir to the interpreter and, unless there is a cDir directory, an error occurs.
CD (cDir) -- sends c:\program files because the parentheses tells the interpreter to evaluate cDir before acting on it.
CD &cDir -- sends c:\program because it after FoxPro expands the macro it looks exactly like CD c:\program files.
CD "&cDir" -- sends c:\program files because after FoxPro expands the macro it looks exactly like CD "c:\program files"

Finally,
CD "'" + &gcPath + "'" -- doesn't work because "'" + &gcPath + "'" isn't a directory.

my_command_string = "CD 'c:\Program Files'"
&my_command_string works because after the macro is expanded and the line tokenized, the line looks like CD 'c:\Program Files' to the parser and it so it sends c:\program files to the interpreter after the CD token.

Whew!
David.
Previous
Reply
Map
View

Click here to load this message in the networking platform