1

これは、Fortran プログラムの私の 1 つのサブルーチンです。

subroutine selfile(name)

  ! call Window dialog to select file

  use dfwin

type T_OPENFILENAME
sequence
real lStructSize,hwndOwner,hInstance,lpstrFilter,lpstrCustomFilter,nMaxCustFilter,nFilterIndex,lpstrFile,nMaxFile,nMaxFileTitle
real lpstrInitialDir,lpstrTitle,Flags,lpstrDefExt,lpfnHook,lpTemplateName
 end type T_OPENFILENAME





  type(T_OPENFILENAME):: ofn
  character*100 filter_spec
  character*512 file_spec
  integer status
  character*(*)name

  ! set filter specification and string to return the file specification.

  file_spec=''C
  filter_spec = 'Data Files'C//'*.dat'C// &
                'Text Files'C//'*.txt'C// &
                'All files'C//'*'C//''C
  ofn%lStructSize = SIZEOF(ofn)
  ofn%hwndOwner = NULL
  ofn%hInstance = NULL
  ofn%lpstrFilter = loc(filter_spec)
  ofn%lpstrCustomFilter = NULL
  ofn%nMaxCustFilter = 0
  ofn%nFilterIndex = 1
  ofn%lpstrFile = loc(file_spec)
  ofn%nMaxFile = sizeof(file_spec)
  ofn%nMaxFileTitle = 0
  ofn%lpstrInitialDir = NULL
  ofn%lpstrTitle = loc('D Y N S I M'C)
  ofn%Flags = OFN_PATHMUSTEXIST
  ofn%lpstrDefExt = loc('dat'C)
  ofn%lpfnHook = NULL
  ofn%lpTemplateName = NULL
  end 
  ! Call GetOpenFileName and check status

  status = GetOpenFileName(ofn)
  if (status == 0) then
     name=''
  else
     name=file_spec
  endif
end subroutine selfile

しかし、私は..のようなエラーが発生しています

定数「DYNSI M」の不正使用
loc への引数の数または型が不正です
定数「dat」の不正使用
ENDSUBROUTINE ステートメントが一致しません
4

1 に答える 1

1

このloc()関数は非標準ですが、簡単に検索すると、その引数をリテラル定数にすることはできないことがわかります。

于 2011-10-20T14:07:20.530 に答える