replica nfl jerseysreplica nfl jerseyssoccer jerseyreplica nfl jerseys forums.silverfrost.com :: View topic - Opening a file with Windows using FTN95
forums.silverfrost.com Forum Index forums.silverfrost.com
Welcome to the Silverfrost forums
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Opening a file with Windows using FTN95

 
Post new topic   Reply to topic    forums.silverfrost.com Forum Index -> Support
View previous topic :: View next topic  
Author Message
Little-Acorn



Joined: 06 Jul 2008
Posts: 111
Location: San Diego

PostPosted: Fri Aug 27, 2010 1:44 am    Post subject: Opening a file with Windows using FTN95 Reply with quote

I need to open three different files in a Windows program I'm writing, using WINAPP and including <windows.ins> on a WinXP system. It is a fixed-format FORTRAN program file called PARTSPROG.for .

Using an example from the HELP file, I'm able to open all three successfully. But a lot of windows and mouse clicks are involved for each one, and it gets tedious. I've listed the present code at the bottom of this post. Is there a way I can streamline this?

Presently when I run the program:

* A small window appears with the title "Select Parts List" and one menu heading, "File".
* I click on "File", and one subheading appears, "Open".
* I click on "Open", and the usual Windows file-selection window appears, letting me navigate thru paths, select the file, and click the OPEN button.
* When I click that OPEN button, the Windows file-selection window disappears, as expected. But the small window with the "Select Parts List" title is still there.
* If I then click on the X at the upper right corner of this small window, the small window vanishes, and the program moves on the the next section, which uses similar code to open the next file I need.

That works, but is tedious, and there's a risk that I won't realize that after I click the OPEN button and the file-selection window disappears, the small window I see is still for the file I just opened. I might click on its File manuagain, and then on its Open menu, and re-open the same file I just opened, which I don't want to do.

What I'd rather see the program do, using three similar sections of FTN95 code to open three different files, is:

* When I start the program, the usual Windows file-selection window appears immediately, with the title "Select Parts List".
* I navigate thru the paths, click on the file I want, and click the OPEN button. The file-selection window disappears.

* A new File-selection window appears (I might put it in a different location on the screen, or with a different color) with the title "Now select the 2nd file".
* That lets me navigate to the second file, click on it, and click the OPEN button. That file-selection window disappears.

* A third file-selection window appears to let me open the third file, etc.

Is there a way I can get my program to operate in a streamlined way like that?

--------------------------------------------------------

The code I'm presently using is:

PROGRAM MYPARTS
WINAPP
include <windows.ins>
CHARACTER*250 ABPartsListNm,filenm
COMMON/FileNames/filenm
EXTERNAL getfilenm
.
.
filenm=''
i=winio@('%ca[&Select Parts List]&')
i=winio@('%mn[&File[&Open]]','FILE_OPENR',filenm,getfilenm)
ABPartsListNm=filenm
OPEN(3,FILE=ABPartsListNm,ACTION='READ')
.
.
<two more sections of similar code with different filenames>
.
.
STOP
END
C
INTEGER FUNCTION getfilenm()
CHARACTER*250 filenm
COMMON/FileNames/filenm
i=winio@('%ws %`bt[OK]',filenm)
getfilenm=1
END
Back to top
View user's profile Send private message
Wilfried Linder



Joined: 14 Nov 2007
Posts: 314
Location: D�sseldorf, Germany

PostPosted: Fri Aug 27, 2010 8:24 am    Post subject: Reply with quote

I think you should use get_filtered_file@. The code may be similar to the following (within your main programme at the beginning):

Code:
      integer*4     i
      character*40  title(3),text(3),extens(3)
      character*120 path,curdir@,string,my_file_1(3)

      path   = curdir@
      string = curdir@
      call append_string@(string,'\*.dat')
      title(1)  = 'Select parts #1'
      text(1)   = 'File #1'
      extens(1) = 'dat'
      i = 1
      call get_filtered_file@(title,string,path,text,extens,i,1L)
      if (string .ne. ' ') then
        my_file(1) = string
c
c
c
      end if

      string = curdir@
      call append_string@(string,'\*.dat')
      title(2)  = 'Select parts #2'
      text(2)   = 'File #2'
      i = 1
      call get_filtered_file@(title,string,path,text,extens,i,1L)
      if (string .ne. ' ') then
        my_file(2) = string
c
c
c
      end if
c
c
c

Regards, Wilfried
Back to top
View user's profile Send private message
Little-Acorn



Joined: 06 Jul 2008
Posts: 111
Location: San Diego

PostPosted: Fri Aug 27, 2010 10:14 pm    Post subject: Reply with quote

Thank you, Wilfried, I will try this!
Back to top
View user's profile Send private message
LitusSaxonicum



Joined: 23 Aug 2005
Posts: 2402
Location: Yateley, Hants, UK

PostPosted: Sun Aug 29, 2010 1:21 am    Post subject: Reply with quote

Hi Little-Acorn,

Wilfried has pointed out to you the alternative system using a subroutine call instead of a standard call-back which means that you do not need a persistent window. You still need to get the 3 separate files. Why not open just one file which contains the names of all the other files you want to open?

Alternatively, if the three files are linked in some way, why not get the basic name once, and work out the other names as you go? One way of doing this would be to have the same file name, but different extensions e.g.

oaktree.dat
oaktree.prt
oaktree.ext

or make the file names relate to each other in a systematic way, e.g.

bigoak_1.dat
bigoak_2.dat
bigoak_3.dat

if the extension is meaningful. Remember that you can even change the subdirectory as well when doing this.

Another post covers a routine for getting multiple files in one go.

Eddie
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    forums.silverfrost.com Forum Index -> Support All times are GMT + 1 Hour
Page 1 of 1

 
Jump to:  
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