- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Link Copied
- « Previous
-
- 1
- 2
- Next »
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
regsvr32 ifdlg100.dll
This will take care of it.
I have noticed that with this example, sometimes when the program closes an error message appears. I have not yet found the cause of this.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Re: IVF StdCall DLLs Fortran- Excel/VBA/VB with Strings IN, OUT and INOUT
I have had trouble upgrading old CVF style code to IVF. The modern IVF multi-language (...11.0\066\fortran\Samples\Fortran\MixedLanguage\..) sample does not offer both IN and OUT strings. Can anyone show me reliable samples of stdcall DLLs Fortran- Excel/VB/VBA which do.
erratum (28-Mar) as with cvf: "You can use CHARACTER(LEN=*) in Fortran if you omit the REFERENCE attribute and in the VB code,' explicitly pass a length (perhaps using the LEN intrinsic) as a "ByVal arglen as Long" argument' immediately following the string argument". But my strings are not passing properly in IVF.
. I use: Intel(R) Visual Fortran Composer XE 2013 Update 1 Integration for Microsoft Visual Studio* 2008, 13.0.3600.2008, Copyright (C) 2002-2012 Intel Corporatio
(as old CVF sample)
******* Excel/ VBA ******
Declare Sub DLL_ROUT Lib "Fcall.dll" ( _
ByRef INT_ARG As Long, _
ByVal STR_IN As String, ByVal STR_IN_LEN As Long, _
ByVal STR_OUT As String, ByVal STR_OUT_LEN As Long)
**** Fortran ***
! Fortran part of a VB-Fortran DLL example. This
! routine DLL_ROUT is called from a VB executable
! program.
SUBROUTINE DLL_ROUT (INT_ARG, STR_IN, STR_OUT)
IMPLICIT NONE
! Specify that DLL_ROUT is exported to a DLL
! and that the external name is 'DLL_ROUT'
!DEC$ ATTRIBUTES STDCALL, DLLEXPORT :: DLL_ROUT
!DEC$ ATTRIBUTES ALIAS:'DLL_ROUT' :: DLL_ROUT
! ** My own code has..
!!DEC$ATTRIBUTES REFERENCE ::INT_ARG, STR_IN, STR_OUT
INTEGER INT_ARG
CHARACTER(Len=*) STR_IN, STR_OUT
! This routine converts INT_ARG to a decimal string.
! appends the string value to STR_IN and stores it
! in STR_OUT.
!
! Note that there are implicit length arguments
! following the addresses of each CHARACTER argument.
CHARACTER(Len=6) INT_STR
WRITE (INT_STR,'(I5.5)')INT_ARG
STR_OUT = STR_IN // INT_STR
RETURN
END
Many thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I'll take a look at this tomorrow.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Peter, I am confused as to what you want. The VB sample you quote already does output strings. The current C_Calls_Fortran sample isn't yet using BIND(C) - I will remedy that for a future release - but it uses LEN=*. What are you looking for?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi Steve
My apologies forthe confusion. The Len=* is a redherring. But the code, which I believe would work in CVF, fails to,pass the arrays to Fortran. The excel can now test both with (1) worksheet function (2) command button. Though the code has issues.. The fcall3.xls is in debug directory.
29-Mar-13: I would be pleased to have a choice between LEN=* and LEN=len (not shown) versions. But neither are working
Thanks Peter
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
The fcall3.xls doesn't seem (to my non-Excel-experienced) eye to have the VBA code to call the DLL. You have several XLS files there. I am used to being able to press Alt-F11 to bring up the VBA editor, but that does nothing in your fcall3.xls.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Steve: Here is a new version with
Two DLL methods
- Much as old CVF (LEN=* etc) this fails. It would be nice to fix this but, if necessary perhaps option 2 will suffice?
- Based on modern example (Len=<big enough> etc) . This now works
Two methods of running in excel (fcall6.xls)
- as cell formula (Instructions in the spreadsheet!)
- via a command button (recomended)
Is there a way to only receive Forum emails automatically on "ones own" questions? Or could you possibly email as well?Many thanks Peter
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
You can click "Subscribe to this post" at the top of the topic and it will send you emails for all replies to that topic.
I will look at your new zip.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Ok, a couple of things going on with your FC_10 call. First, you declare the strings in Excel to be 20 bytes but declared them in Fortran to be 100. When you assigned to STR_OUT in DLL_ROUT10, this corrupted memory and resulted in an access violation. Fix: declare STR_IN and STR_OUT as CHARACTER(20).
Second, you use INDEX to search for a trailing NUL to set LEN_IN and LEN_OUT. Excel doesn't use that convention, so get rid of those. Just use TRIM to trim trailing blanks.
When I do this, it works.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Steve
I should have said that rough and ready "OK" code ("specifield len=??" paradigm e.g. FC_10) was prone to memery issues. But I had hoped there was a safe way of making the Forran strings "very big" to allow the same flexibiity as len=*
So if the len=* can be made to work in IVF that would certainly be great. I guess there might be a third option ijn which the len arg is past through in a non-tranparent way
thanks, Peter
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
No, there isn't unless you go the "BSTR" route which is more complicated. One of the VB examples demonstrates this. I think it would be easier to pass the lengths.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi Steve
Re the char(LEN=*) Sample DLL in Excel in modern IVF
To avoid BSTR we discussed two options but I am stuck on both
1) Character(len=*): not working 2) Character(len=X): I have had no luck
Can you please demonstate one working one?
Pter
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi Steve,
The link you provided for samples in your original posting on this thread appears to be broken.
Thanks,
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
LEN=* will work if your Excel code passes the character variable lengths by value. LEN=x will work if x is the same as the VBA declaration (and you specify REFERENCE for the procedure and arguments.
Please ignore the link - it is from 2005 before we started including samples in the product.
I suggest that you start a new thread on your question rather than tacking it on to this ancient one.
![](/skins/images/45C6C2D737ED71F4C51F0145C8CB1E9C/responsive_peak/images/icon_anonymous_message.png)
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- « Previous
-
- 1
- 2
- Next »