I am a novice in WinRunner. Can anyone explain about single-, double-, triple- and
so on backslashes e.g. C:\\\...,C:\...
When to use apropriate one.
There are only single and double backslashes (and any combination of it).
If you want to open a file named C:\foo.txt:
file_open( "C:\\foo.txt" );
A double backslash means one backslash within the resulting text.
If you want to make up a string containing doublequotes (or make some special charactes), use a single backslash:
static command = "del \"C:\\foo.txt\"";
You might use it to delete the file:
dos_system( command );
Or, of course, shorter:
dos_system( "del \"C:\\foo.txt\"" );
Those are the most important things.
Just to help clarify, the back-slash within a string means to interpret the very next character literally, ignoring any special meanings it might normally have. Therefore, as in the prior response, if you want a quote character within a quoted string, you precede it with a back-slash to indicate it as the literal character and not as the end-of-string character:
"sample \"string\" with embedded quotes"
Since back-slash is a special character, if you want to use it in a string, you need to precede it with a back-slash. This is why you see double back-slashes in file pathnames, e.g.:
Hope this helps.
[This message has been edited by Charles Reace (edited 01-08-2002).]
[i]...Sound trumpets! Every trumpet in the host! / Sixty thousand, on these words, sound, so high the mountains sound, and the valleys resound.</i] (The Song of Roland)
Thanks a lot for a clear explanation!