I have been working on converting several Fortran DLLs first to DLLs callable from Visual Basic, and now to DLLs callable from VBScript.
I succeeded in the first task (calling Visual Fortran from Visual Basic) with no problem. Now I need help converting my Fortran subroutines to COM DLLs callable from VBScript. I am able to do it when my Fortran subroutine returns only one value. However, I do not know what to do for cases when the subroutine returns several output values. I understand that when I specify arguments for object methods in the Fortran COM Server Wizard, only one argument with Intent Out can have a return value. This makes sense since object methods are functions, but what to do about subroutines? I was under impression that COM Server Wizard will create a wrapper, and implementation of the method is cut and paste of my original Fortran DLL. Where am I going wrong and what am I missing? Do I need to completely re-write my Fortran subroutines if they return more than one argument?
A simple Fortran subroutine is listed below. It takes three input arguments (integer, string, and float) and returns integer tripled, a concatenated string, and the float doubled.
SUBROUTINE Test_VB (INT_ARG, STR_IN, FLOAT_ARG, INT_OUT, STR_OUT, NUM)
! Specify that Test_VB is exported to a DLL
! and that the external name is 'Test_VB'
!DEC$ ATTRIBUTES DLLEXPORT :: Test_VB
!DEC$ ATTRIBUTES ALIAS:'Test_VB' :: Test_VB
CHARACTER*(*) STR_IN, STR_OUT
! This routine converts INT_ARG to a string,
! appends the string value to STR_IN and stores it
! in STR_OUT. It also triples the integer and doubles
! the float.
WRITE (INT_STR,'(I5)') INT_ARG
INT_OUT = 3*INT_ARG
STR_OUT = STR_IN // INT_STR
NUM = FLOAT_ARG*2.0
Please let me know what I would need to specify in the Fortran COM Server Wizard to make this work. Again, I was able to get this to work as COM DLLs form ASP when I separated the Fortran routine into three routines returning one value each.
Your help is greatly appreciated.