I am having some problems with execute_command_line
My program launches in a folder in which I don't specify. I need to move around this root folder creating new sub-folders and moving between them and the root folder.
The variable 'root_folder' has the full path name for the root folder.If I am in a sub-folder of the root folder and use the Fortran code:
status = changedirqq(trim(root_folder))
It works and I move back to the root folder. However, if I use
command = 'chdir ..'
call execute_command_line(trim(command), exitstat=estat, cmdstat=cstat)
then estat and cmdstat are returned as zero but I do not move back to the root folder.
If I use the Command Prompt window, I can move around the the folders with standard Windows commands without any problems.
I am using the latest beta compiler.
The command line executed happens in a different process and doesn’t affect your current directory. Use changedirqq for this, or explicitly specify the path when creating the folder.
My problem is that changedirqq seems to need the full path; I can't specify, for example,
status = changedirqq('..')
The full path may contain non-ASCII characters, so I can't use that either. (This is related to my earlier posting about UNICODE in Fortran).
An additional technique you can use is to call MS CRTL function SetCurrentDirectoryW with the address of an INTEGER(2) array containing the desired path in UNICODE. If the kernal32.mod does not contain the interface, you may need to define your own interface using one of the other interfaces as a guideline.
You can use a UNICODE text editor to prepare a text file to be read by the Fortran program for use as file path\name