- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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:
integer status
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.
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thanks Steve.
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).
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Can you write a C/C++ routine that you call from Fortran to perform the UNICODE change directory?
Jim Dempsey
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I guess that's what I'll have to do.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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
Jim Dempsey
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Can I double-check something please: changedirqq(path) needs the full path name?

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page