gfxgfx
 
Please login or register.

Login with username, password and session length
 
gfx gfx
gfx
1617 Posts in 535 Topics by 779 Members - Latest Member: rhoronjeff@comcast.net November 27, 2022, 07:48:08 PM
*
gfx* Home | Help | Search | Login | Register | gfx
gfx
Absoft User Forum  |  Support  |  Windows  |  How to create a new folder using fortran under Windows
gfx
gfxgfx
 

Author Topic: How to create a new folder using fortran under Windows  (Read 8538 times)

wuran

  • Newbie
  • *
  • Posts: 2
How to create a new folder using fortran under Windows
« on: September 26, 2007, 11:36:24 AM »
I need to save some generated files into a folder named after the data, but I can not figure out a way to do it.  Please help, thanks.

Mike Linacre

  • Sr. Member
  • ****
  • Posts: 259
Re: How to create a new folder using fortran under Windows
« Reply #1 on: September 26, 2007, 05:13:23 PM »
How about "system" in the UNIX compatibility library? Something like ....
retcode = system("MKDIR "//char(34)//foldername//char(34))

wuran

  • Newbie
  • *
  • Posts: 2
Re: How to create a new folder using fortran under Windows
« Reply #2 on: October 30, 2007, 05:06:51 PM »
Thanks, but I am using absoft under window xp.  How should I do it?

Mike Linacre

  • Sr. Member
  • ****
  • Posts: 259
Re: How to create a new folder using fortran under Windows
« Reply #3 on: October 30, 2007, 07:23:11 PM »
The Unix compatibility library (unix.lib) is distributed with Absoft for Windows. Simply link it in.
Or you could code the Windows API directly. here is the system.f code from the Unix compatibility library:

      global define
       include "WINDEF.INC"
       include "WINNT.INC"
       include "WINBASE.INC"
       include "ERRNO.INC"
      end

      integer function SYSTEM(string)
      implicit none
      character*(*) string
      record/STARTUPINFO/si
      record/PROCESS_INFORMATION/pi
      integer iret
      integer dw
      integer dwExitCode

      dwExitCode  = -1

      si.cb = 68 ! sizeof(si)
      si.lpReserved = 0
      si.lpDesktop = 0
      si.lpTitle = 0
      si.dwFlags = 0
      si.cbReserved2 = 0
      si.lpReserved2 = 0

      ! VAL(LOC inhibits pushing string length on the stack
      iret = CreateProcess(
     &  VAL4(0),
     &  VAL(LOC(trim(string)//char(0))),
     &  VAL4(0),
     &  VAL4(0),
     &  VAL4(TRUE),
     &  VAL4(NORMAL_PRIORITY_CLASS),
     &  VAL4(0),
     &  VAL4(0),
     &  si,
     &  pi)

      if (iret .NE. 0) then
        dw = WaitForSingleObject(VAL(pi.hProcess),VAL(INFINITE))
        if (dw .NE. -1) then
           call GetExitCodeProcess(VAL(pi.hProcess),dwExitCode)
        end if
        call CloseHandle(VAL(pi.hThread))
        call CloseHandle(VAL(pi.hProcess))
      end if
      SYSTEM = dwExitCode;
      end


Absoft User Forum  |  Support  |  Windows  |  How to create a new folder using fortran under Windows
 

gfxgfx
gfx gfx
Powered by MySQL Powered by PHP Valid XHTML 1.0! Valid CSS!