Silverfrost Forums

Welcome to our forums

GET_MULTIPLE_FILENAMES bug - ROOT folder of a drive

14 Mar 2016 10:49 #17301

I ran the example given in the HELP file to assist me with another issue. What I got was a very odd behavior.

The code is:

     WINAPP
     INCLUDE <windows.ins>
     LOGICAL L,next
     CHARACTER*256 filename,filter,defpath
     filter = 'Free Fortran files (*.f90)'//char(0)//'*.f90'//char(0) &
               //'All files (*.*)'//char(0)//'*.*'//char(0)//char(0) 
     defpath = char(0) !Gives the current working directory
     L = .TRUE.
     next = .FALSE.
     DO WHILE(L)
       filename = char(0)
       L=GET_MULTIPLE_FILENAMES@(0,'Dialog Title',filename,256,filter,defpath,next) 
       next = .TRUE. 
       IF(L) PRINT*, trim(filename)
     END DO 
     END

When run against my D: drive (and I've selected a few files), I get:

D:\\MISCSTMT001.FXS
D:\\msdia80.dll
D:\\Multiple transfer.psd

The doubled backslash should not be there. I have put a check in my code to prevent this for occurring.

15 Mar 2016 8:42 #17302

Funny... I use the following code without problems - perhaps you may try it?

      WINAPP
      program test

      include <windows.ins>

      logical*2      l,n
      character*120  cpath,cfile,filter

      filter = 'Image files (*.JPG)'//char(0)
      cpath  = char(0)
      l = .true.
      n = .false.
      do while (l)
        cfile = '*.JPG'//char(0)
        l = GET_MULTIPLE_FILENAMES@(0,'Select',cfile,120,filter,cpath,n)
        if (l) print*,cfile
        n = .true.
      end do
      end

Wilfried

15 Mar 2016 2:03 #17303

Yep, does it here, two different Windows 10 machines.

When you ran this, were your files at the root (i.e. C:\ or D:\)?

Works fine if not at the root.....

15 Mar 2016 7:11 #17304

Also occurs under Windows 2000, and, like Windows 10, only when selecting root level of the drive.

16 Mar 2016 2:48 #17306

Indeed, the same behaviour at my PC when searching for files in the root directory. So you may use a trick - the changes are marked with !!!:

      WINAPP
      program test

      include <windows.ins>

      logical*2      l,n
      integer*4      root
      character*120  cpath,cfile,curdir@,filter

      filter = 'Image files (*.JPG)'//char(0)
      cpath  = char(0)
      root   = 0                             !!!
      if (leng(curdir@()) == 3) root = 1     !!!
      l = .true.
      n = .false.
      do while (l)
        cfile = '*.JPG'//char(0)
        l = GET_MULTIPLE_FILENAMES@(0,'Select',cfile,120,filter,cpath,n)
        if (root == 1) cfile = cfile(1:3)//cfile(5:)//char(0)   !!!
        if (l) print*,cfile
        n = .true.
      end do
      end

Wilfried

16 Mar 2016 6:12 #17307

This is fine when you are not changing the folder. However, you can use this function to go wherever you please to find files, then return the names.

The more general case is something like:

	      nnn = index(PATTERN,':\') ! look for the odd behavior 
	      if(nnn.ne.0) PATTERN = PATTERN(1:nnn+1)//PATTERN(nnn+3:) ! remove the :\\ and replace with :\

where PATTERN is the pathname returned.

Please login to reply.