replica nfl jerseysreplica nfl jerseyssoccer jerseyreplica nfl jerseys forums.silverfrost.com :: View topic - Problem using CURDIR@ in DLL called by VB
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 

Problem using CURDIR@ in DLL called by VB

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



Joined: 10 Dec 2009
Posts: 14
Location: Miami, FL USA

PostPosted: Tue Sep 27, 2011 7:26 pm    Post subject: Problem using CURDIR@ in DLL called by VB Reply with quote

Hi,

I have spent most of 3 days tracking down a problem (no, I'm not a professional programmer) that occurred when I tried to call a Fortran DLL from Visual Basic. It appears the problem is caused by using CURDIR@ in the Fortran.

The following Fortran works fine when called from VB:
�.
Character (LEN=300):: FN_Input
�.
FN_input = �hardwired path to test.csv�
Open(unit=IR, file = FN_Input, status='old', err=999)
�.

Replacing the above code with:
�.
Character (LEN=300):: FN_Input
CHARACTER (LEN=256)::CURDIR@
�.
FN_Input = Trim(CURDIR@()) // "\test.csv"
Open(unit=IR, file = FN_Input, status='old', err=999)
�.
Results in Excel crashing as soon as the open command is executed

However, if I call the same code from Fortran rather than VB, it executes fine as far as I can tell (i.e. it reads the contents of the file)

Am I doing something obviously wrong?

Thanks,
Kent
Back to top
View user's profile Send private message
Kent Lyons



Joined: 10 Dec 2009
Posts: 14
Location: Miami, FL USA

PostPosted: Tue Sep 27, 2011 8:55 pm    Post subject: IGNORE THIS POST Reply with quote

SORRY,

I'm pretty sure my own stupidity caused the problem so you can delete this topic.

I still can't understand why the error trapping in the FORTRAN read statement didn't properly ID my real problem, but I don't want to spend more time figuring out how I screwed that up too.

Kent
Back to top
View user's profile Send private message
JohnCampbell



Joined: 16 Feb 2006
Posts: 2615
Location: Sydney

PostPosted: Wed Sep 28, 2011 1:38 am    Post subject: Reply with quote

The use of "IOSTAT=" can sometimes be helpful in these cases. I've taken an error report I use and listed it below:
Code:

      EXTERNAL  FORTRAN_ERROR_MESSAGE@
      CHARACTER MESSAGE*64, program_MODULE*64
!
Open (unit=IR, file = FN_Input, status='old', iostat=err_code)
if (err_code /= 0) then
      CALL FORTRAN_ERROR_MESSAGE@ (err_code, MESSAGE)
      WRITE (*,1001) err_code,FN_Input,IR,program_MODULE,trim(MESSAGE)
 1001 FORMAT (' ***** FILE ACCESSING ERROR *****'/                      &
              ' status : ',I0/                                          &
              ' file   : ',A/                                           &
              ' unit   : ',I0/                                          &
              ' module : ',A/                                           &
              ' type   : ',A)
   goto 999
end if
Back to top
View user's profile Send private message
Kent Lyons



Joined: 10 Dec 2009
Posts: 14
Location: Miami, FL USA

PostPosted: Wed Sep 28, 2011 1:25 pm    Post subject: Reply with quote

Thanks, John

Out of curiosity, do you know why Excel crashed when the Fortran tried to read a non-existent file? Since I had an 'err=999' statement I would have thought the Fortran would just trigger the code I had at 999 (a write statement followed by a 'stop') and the exit would have been more graceful as well as more informative

Thanks,
Kent
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