Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.
28446 Discussions

how to retrieve DOUBLE QUOTES from arguments?

Xj_Kong
Novice
549 Views

I just encountered a problem to get the sub-strings that were originally and correctly input as argument below:

foo.exe file.dat ""Time " "Fx " "xPos ""

I need to retrieve the arg2 containing three variables to be 3 sub-strings, however, I got 6.

Is there any trick behind the input?

Thanks,

Kong

Ps: I found the below, but not TRUE on my pc.

https://msdn.microsoft.com/en-us/library/system.environment.getcommandlineargs%28v=vs.110%29.aspx

gives MyApp \\\\\"alpha \"beta ==>> MyApp, \\"alpha, "beta

0 Kudos
3 Replies
Arjen_Markus
Honored Contributor I
549 Views

I think you will have to use GET_COMMAND to retrieve the entire command-line without any interpretation and parse it yourself. The problem you see is likely due to the command-line parser not seeing the nested doubled quotes as nested.

0 Kudos
Xj_Kong
Novice
549 Views

Yes, I tried GET_COMMAND in Cygwin, but it still strips off the inner double quotes.

In MS-Dos, it succeeds by typing this, but obviously too lengthy...

foo.exe file.dat """"Time """ """Fx """ """xPos """"

Thanks a lot.

0 Kudos
Arjen_Markus
Honored Contributor I
549 Views

Try this instead: 

program "'Time ' 'Fx ' 'xPos '"

The shell/command window will leave the inner single quotes as they and considers everything a single argument. Within your Fortran program you can use list-directed input (read(string,*)) to retrieve the individual parts.

I tried this in a command window under Windows and in a shell window under Cygwin. Both remove the outer double quotes, but leave the inner single quotes intact

 

 
 

0 Kudos
Reply