Expiring Today—Celebrate National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

File Handles in Mixed Language Programming

Posted on 1998-08-03
7
Medium Priority
?
212 Views
Last Modified: 2013-11-08
I need a way to figure out how to obtain a listing of all files and there associated handles that a program has open at any given time during program execution.  I need this because I am opening, reading, writing, and closing my files in Fortran, but I am locking and unlocking records in these files using C++ (the original LOCKING routine was eliminated by Microsoft when they created Fortran Powerstation).  Anyway, I'm using Microsoft Developer Studio in conjuction with Visual C++ and Fortran Powerstation.  There is no way in Fortran that I know of to obtain the handles of the files that it opens.  Is there any other way I can get these handles?  This will be a tough question, I think.  It must be stored somewhere in some type of table, no?
0
Comment
Question by:ardolino
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
7 Comments
 
LVL 2

Expert Comment

by:JYoungman
ID: 1169302
My FORTRAN is a bit rusty now but it seems to me that the most convenient approach would probably be to WRITE your data into CHARACTER*(*) variables and then pass these to a C++ routine to do the actual I/O, and hence avoid opening the files from FORTRAN.  I know it's sometimes difficult to pass a CHARACTER*(*) to another language, so you may have to use a CHARACTER*(nnn) instead.

If this just isn't possible, then I suggest you use two files.  One ('FOO.DAT') is the one against which you do I/O from FORTRAN, and the other ("FOO.LCK") is the one against which you do the locking and unlocking from C++.  

0
 

Author Comment

by:ardolino
ID: 1169303
My problem is that I am doing a mass conversion of over 1000 programs written in FORTRAN that already having external function calls to lock and unlock records in a file, but all of the programs open, read, write, and close the files directly.  If I could just obtain the handle of the file, I can replace the lock and unlock functions with c++ routines that can actually lock and unlock the files.  (The original FORTRAN lock and unlock routines used the FORTRAN LOCKING command (no longer available)).  If I can't get the handle, then I can always work something out with using two files, but if there is a way to get the handle, it would be a lot easier for me, even if getting the actual handle may be difficult.  There has to be a way to get it, no?
0
 
LVL 2

Expert Comment

by:JYoungman
ID: 1169304
Yes, I assume there is *some* way to get it.  I don't have a copy of PowerStation here, and I'm currently booted to Linux, so I can't even search the MSDN library (since the MSDN library program only runs under Windows).  I could tell you how to do it under Linux with g77 if you like :-)    But seriously, I don't know how to get the file handle and don't have access to the relevant reference material at the moment.

Does this locking need to take place between machines over a network, or just on one machine?


0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 

Author Comment

by:ardolino
ID: 1169305
I found a utility called File Monitor for Win95 and WinNT - it has source code, but I'm having a little trouble understanding it.  I'll figure it out, though - it does what I want to do.
0
 
LVL 11

Expert Comment

by:alexo
ID: 1169306
Can you post the URL where this utility is obtainable from?
0
 
LVL 8

Accepted Solution

by:
Answers2000 earned 400 total points
ID: 1169307
FindFirstChangeNotification and FindNextChangeNotification allow you to monitor changes to a directory tree from a C++ program.  Assuming you know where the Fortran program writes files, the C program can monitor this area and take corresponding action (placing the locks for example).


0
 
LVL 22

Expert Comment

by:nietod
ID: 1169308
locking and unlocking need to be done synchronously.  The change notification system is goig to opperate asynchronously.  VERY asynchronously.  
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article will show, step by step, how to integrate R code into a R Sweave document
Q&A with Course Creator, Mark Lassoff, on the importance of HTML5 in the career of a modern-day developer.
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.
This theoretical tutorial explains exceptions, reasons for exceptions, different categories of exception and exception hierarchy.

719 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question