Hi all,
I'm trying to write a ExecuteCommand to trigger a DOS xcopy in the Epilog. My original filepath and destination filepath both contain spaces.
Filepath = 'z:\Folder A\';
Filename = 'export.csv';
Filepathname = Filepath | Filename;
FilepathNew = 'z:\Folder B\';
Can you kindly advice when it is necessary to use double quotes and single quotes? Do I use it when I'm using variables like Filepathnew in the first parameter in the ExecuteCommand function because the parameter is supposed to be encased in a pair of single quotes? Or is it because, after resolving the FilepathNew, the actual path contains space?
Thanks.
When to use double and single quotes in TI?
-
- Regular Participant
- Posts: 226
- Joined: Thu Apr 02, 2009 2:51 pm
- OLAP Product: IBM Planning Analytics
- Version: Latest version
- Excel Version: 2003 to 2019
When to use double and single quotes in TI?
Planning Analytics latest version, including Cloud
-
- Site Admin
- Posts: 6667
- Joined: Sun May 11, 2008 2:30 am
- OLAP Product: TM1
- Version: PA2.0.9.18 Classic NO PAW!
- Excel Version: 2013 and Office 365
- Location: Sydney, Australia
- Contact:
Re: When to use double and single quotes in TI?
Single quotes are what you use to surround literal strings in TurboIntegrator. That distinguishes the text contained within those quotes from function names and variable names. Therefore Filepath has no single quotes around it because it's a variable name. 'z:\Folder A\' on the other hand, does have to be surrounded by quotes, because it's a literal string.harrytm1 wrote: I'm trying to write a ExecuteCommand to trigger a DOS xcopy in the Epilog. My original filepath and destination filepath both contain spaces.
Filepath = 'z:\Folder A\';
Filename = 'export.csv';
Filepathname = Filepath | Filename;
FilepathNew = 'z:\Folder B\';
Can you kindly advice when it is necessary to use double quotes and single quotes? Do I use it when I'm using variables like Filepathnew in the first parameter in the ExecuteCommand function because the parameter is supposed to be encased in a pair of single quotes? Or is it because, after resolving the FilepathNew, the actual path contains space?
Double quotes have no meaning within TI itself (not in its syntax anyway), so disregard them in that sense. The only place that they matter is in the command line that you pass to Windows. Consequently what you need to do is create the command line just as if you were running it directly in a command line window, and build the string accordingly. Don't think about TI at all when you do this.
If you run the command directly in the command line window it would need to be as follows. (I'm using Y:\Temp where you used Z:\; also the batch file that I created to execute the command is Y:\Temp\XCopyExport.bat):
Code: Select all
Y:\Temp\XCopyExport.bat "Y:\Temp\Folder A\Export.csv" "Y:\Temp\Folder B\"
This means that you need to embed double quotes into the string that you pass to the ExecuteCommand function.
Now me, I don't like doing that using a literal string for the double quotes. I find that it makes the code too hard to read and debug. ("Is that a double quote and a single quote? Three single quotes, maybe?") So what I do instead is to assign the double quote character (drawn from the Char() function) to a variable and use that variable wherever I need a double quote. Like so:
Code: Select all
SC_QUOTE_DOUBLE = Char(34);
Filepath = 'Y:\Temp\Folder A\';
Filename = 'Export.csv';
Filepathname = Filepath | Filename;
FilepathNew = 'Y:\Temp\Folder B\';
s_Command = 'Y:\Temp\XCopyExport.bat ' | SC_QUOTE_DOUBLE | Filepathname | SC_QUOTE_DOUBLE | ' ' | SC_QUOTE_DOUBLE | FilepathNew | SC_QUOTE_DOUBLE;
ExecuteCommand ( s_Command, 0 );
For the sake of completeness the batch file is:
Code: Select all
xcopy %1 %2
Code: Select all
"Y:\Temp\Folder A\Export.csv"
Parameter 2 will receive:
Code: Select all
"Y:\Temp\Folder B\"
"To them, equipment failure is terrifying. To me, it’s 'Tuesday.' "
-----------
Before posting, please check the documentation, the FAQ, the Search function and FOR THE LOVE OF GLUB the Request Guidelines.
-----------
Before posting, please check the documentation, the FAQ, the Search function and FOR THE LOVE OF GLUB the Request Guidelines.
-
- Regular Participant
- Posts: 226
- Joined: Thu Apr 02, 2009 2:51 pm
- OLAP Product: IBM Planning Analytics
- Version: Latest version
- Excel Version: 2003 to 2019
Re: When to use double and single quotes in TI?
Oh Alan, I'm not worthy!!!!
Thank you so much for your help!
Thank you so much for your help!
Planning Analytics latest version, including Cloud