|
forums.silverfrost.com Welcome to the Silverfrost forums
|
View previous topic :: View next topic |
Author |
Message |
aebolzan
Joined: 06 Jul 2007 Posts: 229 Location: La Plata, Argentina
|
Posted: Tue Aug 17, 2010 3:40 pm Post subject: How can I open several files at the same time? |
|
|
I want to open several data files at the same time in order to plot all data at once and compare different experimental data on a single graph. However, I do not see how it could be done using Clearwin facilities. Usually, graphing softwares allow to select several files using Ctrl+mouse click and import all data, but after reading the Clearwin Help I did not find any clue about this. Maybe is not possible at all.....?
Agustin |
|
Back to top |
|
|
LitusSaxonicum
Joined: 23 Aug 2005 Posts: 2388 Location: Yateley, Hants, UK
|
Posted: Tue Aug 17, 2010 4:04 pm Post subject: |
|
|
Hi Agustin,
The Clearwin routine GET_FILTERED_FILE@ is merely a mechanism for getting a filename (perhaps it would be better to call it GET_FILTERED_FILENAME@). The actual opening is done by you, via an "OPEN" statement. There is nothing to stop you opening file after file this way.
Easier might be to open a file that contains all the linked or related filenames, read it and then do multiple OPENs, or to get a generic name and differentiate between the various input data files by their extensions (e.g. AGUSTIN.001, AGUSTIN.002 etc).
However, programs that open multiple files in this way are dissimilar to many "pure" Windows programs that have one "document" per problem.
Multiple document interface programs are usually working on multiple problems of the same type (e.g. Word when it has several documents open).
I agree that I can't find how to select multiple files at the same time using GET_FILTERED_FILE@ (or by any other method). However, you could do separate calls to it, entering the file names into boxes in another window, and then have a "Go" button that opens them all one after the other in quick succession.
Eddie |
|
Back to top |
|
|
PaulLaidler Site Admin
Joined: 21 Feb 2005 Posts: 7927 Location: Salford, UK
|
Posted: Tue Aug 17, 2010 6:10 pm Post subject: |
|
|
get_filtered_file@ does not allow you to do multiple file selection.
I have found an undocumented function in the library that allows multiple selection. Give me a few days and I will see if I can find out how it works. |
|
Back to top |
|
|
PaulLaidler Site Admin
Joined: 21 Feb 2005 Posts: 7927 Location: Salford, UK
|
Posted: Wed Aug 18, 2010 7:15 am Post subject: |
|
|
Here is a sample program. The first argument is a window handle for the parent window (zero for the desktop). I have set the default path as empty giving the current working directory.
Code: | program getfiles
C_EXTERNAL GET_MULTIPLE_FILENAMES@ 'get_multiple_file_names'(VAL,INSTRING,OUTSTRING,VAL,INSTRING,INSTRING,VAL):LOGICAL
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)
L = .TRUE.
next = .FALSE.
do while(L)
L=GET_MULTIPLE_FILENAMES@(0,"Dialog Title",filename,256,filter,defpath,next)
next = .TRUE.
if(L) print*, trim(filename)
end do
end |
|
|
Back to top |
|
|
aebolzan
Joined: 06 Jul 2007 Posts: 229 Location: La Plata, Argentina
|
Posted: Wed Aug 18, 2010 1:38 pm Post subject: |
|
|
Did you say "give me a few days"?. Great job Paul! It works as expected!. Now I have to see how to open files and read data from them, but I guess it will not be hard. I wonder why this possibility has remained undocumented till now....
Thanks a lot!
Agustin |
|
Back to top |
|
|
aebolzan
Joined: 06 Jul 2007 Posts: 229 Location: La Plata, Argentina
|
Posted: Tue Aug 24, 2010 5:26 pm Post subject: |
|
|
I would like to know if this is the most efficient way to use the new get_multiple_filenames@ facility. The only idea I had was to declare a number of arrays in a subroutine and then open one by one using Select Case. This seems for me rather primitive and does not allow to open more files than the number of arrays that is fixed in the subroutine, but I found no better idea. Any suggestions?
Agustin
Code: | subroutine get_several_files
C_EXTERNAL GET_MULTIPLE_FILENAMES@ 'get_multiple_file_names'(VAL,INSTRING,OUTSTRING,VAL,INSTRING,INSTRING,VAL):LOGICAL
logical L,next
character*256 filename,filter,defpath
integer :: status,ndata
character a,b
character*128,dimension(10) :: file_names_set
real x1,y1
type array
real*8 x
real*8 y
end type array
type(array),dimension(:), allocatable :: array_1,array_2,array_3,array_4,array_5,array_6
integer *4 :: number_of_files=0
filter = "Data files (*.dat)"//char(0)//"*.dat"//char(0)//"All files (*.*)"//char(0)//"*.*"//char(0)//char(0)
defpath = char(0)
L = .TRUE.
next = .FALSE.
number_of_files=1
! first select files
do while(L)
ndata=0
L=GET_MULTIPLE_FILENAMES@(0,"Dialog Title",filename,256,filter,defpath,next)
next = .TRUE.
if(L) then
file_names_set(number_of_files)=filename
number_of_files=number_of_files+1
endif
end do
!then open files one by one
do i=1,number_of_files
open(32,file=file_names_set(i),status='old',action='read',iostat=status)
read(32,100) a,b
100 format(2A16)
do
read(32,*,iostat=status) x1,y1
if(status/= 0) exit
ndata=ndata+1
end do
close(32)
open(32,file=file_names_set(i),status='old',action='read',iostat=status)
select case(i)
case(1)
read(32,*) a,b
allocate(array_1(ndata))
do j=1,ndata
read(32,*) array_1(j)%x,array_1(j)%y
end do
close(32)
case(2)
read(32,*) a,b
allocate(array_2(ndata))
do j=1,ndata
read(32,*) array_2(j)%x,array_2(j)%y
end do
close(32)
!...........up to n cases
end select
ndata=0 !reset ndata for the next file
end do
call plot_files !subroutine for plotting data
end subroutine get_several_files |
|
|
Back to top |
|
|
Borrmann Manfred
Joined: 29 Mar 2007 Posts: 28
|
Posted: Wed Aug 25, 2010 7:45 am Post subject: How can i open several files a second time? |
|
|
The multiple selection dialog can't be opened a second time! Is it true or have i made a mistake? Here comes the light modified example from Paul i have tried with.
Code: |
program getfiles
common /test/ files_selected(20)
character (len=256) :: files_selected
integer number_of_files, i, j
do j=1,2
number_of_files = 0
files_selected = ' '
call get_files_on_demand (number_of_files)
print*, 'Do-Loop variable=',j,', Number of Files=',number_of_files
do i = 1,number_of_files
print*, trim(files_selected(i))
enddo
enddo
end
subroutine get_files_on_demand (lfd)
C_EXTERNAL GET_MULTIPLE_FILENAMES@ 'get_multiple_file_names'(VAL,INSTRING,OUTSTRING,VAL,INSTRING,INSTRING,VAL):LOGICAL
common /test/ files_selected(20)
character (len=256) :: files_selected
logical load, next
character*256 filename,filter,defpath
filter = "Free Fortran files (*.f90)"//char(0)//"*.f90"//char(0)//char(0)
defpath = char(0)
load = .TRUE.
next = .FALSE.
lfd = 0
do while(load)
load = GET_MULTIPLE_FILENAMES@(0,"Dialog Title",filename,256,filter,defpath,next)
next = .TRUE.
if(load) then
lfd = lfd + 1
files_selected(lfd) = filename
endif
end do
return
end
|
Paul, can you tell me how to use the multiple selection dialog a second time? |
|
Back to top |
|
|
PaulLaidler Site Admin
Joined: 21 Feb 2005 Posts: 7927 Location: Salford, UK
|
Posted: Wed Aug 25, 2010 11:21 am Post subject: |
|
|
I have tested your code and get the same effect.
If I simply repeat my code in a main program then it works OK.
The failure occurs in the library when a call is made to the Microsoft API function GetOpenFileName.
My guess is that you will be OK if you put the code into the main program rather than a subroutine. I have seen something like this before where the problem was solved by clearing the floating point stack before making the API call. Unless I am missing something, this is something that I might be able to fix in the library but, for the time being you will need to write the code in a different way. |
|
Back to top |
|
|
PaulLaidler Site Admin
Joined: 21 Feb 2005 Posts: 7927 Location: Salford, UK
|
Posted: Wed Aug 25, 2010 9:11 pm Post subject: |
|
|
It turns out that my sample program needs a couple of changes...
Code: | program getfiles
C_EXTERNAL GET_MULTIPLE_FILENAMES@ 'get_multiple_file_names'(VAL,INSTRING,STRING,VAL,INSTRING,INSTRING,VAL):LOGICAL
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)
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 |
I have changed OUTSTRING to STRING and also provided a blank value for filename on input.
With these changes the call can be repeated. |
|
Back to top |
|
|
Borrmann Manfred
Joined: 29 Mar 2007 Posts: 28
|
Posted: Thu Aug 26, 2010 8:04 am Post subject: |
|
|
Paul, thanks for your prompt assistance. |
|
Back to top |
|
|
Borrmann Manfred
Joined: 29 Mar 2007 Posts: 28
|
Posted: Fri Aug 27, 2010 10:55 am Post subject: |
|
|
Paul, the CLEARWIN_INFO@ parameter 'filter_item_selected' gives the selected filter item when using the GET_FILTERED_FILE@ command. Is there any chance to get the selected filter item the same way when using the GET_MULTIPLE_FILENAMES@ command? |
|
Back to top |
|
|
PaulLaidler Site Admin
Joined: 21 Feb 2005 Posts: 7927 Location: Salford, UK
|
Posted: Fri Aug 27, 2010 6:11 pm Post subject: |
|
|
It is not in the library code at the moment but it would be a simple matter to add it in for the next release. |
|
Back to top |
|
|
Sebastian
Joined: 20 Feb 2008 Posts: 177
|
Posted: Mon May 09, 2011 8:41 am Post subject: |
|
|
It does not seem to be present in the 6.10 release, or can it be queried in another way? |
|
Back to top |
|
|
PaulLaidler Site Admin
Joined: 21 Feb 2005 Posts: 7927 Location: Salford, UK
|
Posted: Mon May 09, 2011 10:53 am Post subject: |
|
|
I did not add this to the library at the time of my last reply.
I may have been waiting for a confirmation that this was requested.
Anyway I have now added the clearwin_info@ data to the library for the next release.
I don't know of any other direct way to get this information.
It is worth noting that clearwin_info@ will not work when it is added to my simple sample code above. You need an active winio@ to get it to work. |
|
Back to top |
|
|
LitusSaxonicum
Joined: 23 Aug 2005 Posts: 2388 Location: Yateley, Hants, UK
|
Posted: Mon May 09, 2011 12:45 pm Post subject: |
|
|
Interesting - can you define what an "active WINIO@" means please? Does it mean that the code needs to be executed within a callback?
I hope this isn't simply me being thick.
Eddie |
|
Back to top |
|
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|