- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi Friends,
I have written a function in my COM server component which accepts the name of a file as an input string.Inside the function I am generating 20 random numbers and storing those numbers into a data file and sending the average of those numbers to the client.Here I am able to build the dll but while I am calling this function either in VB or in ASP it is not responding.
I am attaching the code below. I will be glad if I will get any suggestion from anybody.
Thanks in Advance
Debaprasad Tripathy
tripathd@timken.com
Fortran Code
*****************
function IFileCOMServerClass_CallFile( ObjectData ,&
FileName,&
Avg) result (hresult)
use FileCOMServerClass_Types
use oleaut32
use dfwinty
implicit none
type(FileCOMServerClass_InstanceData) ObjectData
!dec$ attributes reference :: ObjectData
CHARACTER(*), intent(in) :: FileName
TYPE(VARIANT), intent(inout) :: Avg
integer(LONG) hresult
! TODO: Add implementation
REAL x, total,value
INTEGER count,I
OPEN (1, FILE = FileName)
DO I = 1, 20
CALL RANDOM_NUMBER(x)
WRITE (1, '(F6.3)') x * 100.0
END DO
CLOSE(1)
OPEN (1, FILE = FileName)
DO WHILE (.NOT. EOF(1))
count = count + 1
READ (1, *) value
total = total + value
END DO
100 IF ( count .GT. 0) THEN
call VariantInit(Avg)
Avg%vt = VT_R8
Avg%vu%DOUBLE_VAL=total/count
END IF
STOP
hresult = S_OK
end function
I have written a function in my COM server component which accepts the name of a file as an input string.Inside the function I am generating 20 random numbers and storing those numbers into a data file and sending the average of those numbers to the client.Here I am able to build the dll but while I am calling this function either in VB or in ASP it is not responding.
I am attaching the code below. I will be glad if I will get any suggestion from anybody.
Thanks in Advance
Debaprasad Tripathy
tripathd@timken.com
Fortran Code
*****************
function IFileCOMServerClass_CallFile( ObjectData ,&
FileName,&
Avg) result (hresult)
use FileCOMServerClass_Types
use oleaut32
use dfwinty
implicit none
type(FileCOMServerClass_InstanceData) ObjectData
!dec$ attributes reference :: ObjectData
CHARACTER(*), intent(in) :: FileName
TYPE(VARIANT), intent(inout) :: Avg
integer(LONG) hresult
! TODO: Add implementation
REAL x, total,value
INTEGER count,I
OPEN (1, FILE = FileName)
DO I = 1, 20
CALL RANDOM_NUMBER(x)
WRITE (1, '(F6.3)') x * 100.0
END DO
CLOSE(1)
OPEN (1, FILE = FileName)
DO WHILE (.NOT. EOF(1))
count = count + 1
READ (1, *) value
total = total + value
END DO
100 IF ( count .GT. 0) THEN
call VariantInit(Avg)
Avg%vt = VT_R8
Avg%vu%DOUBLE_VAL=total/count
END IF
STOP
hresult = S_OK
end function
Link Copied
5 Replies
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Remove the STOP statement in your code and it will work.
In general, STOP statements don't belong in DLLs or COM servers.
hth,
John
In general, STOP statements don't belong in DLLs or COM servers.
hth,
John
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
hi john,
it is working great in ASP page after removing STOP from the code.I have a small doubt.By default it creates the data file in c:winntsystem32 .Is it possible to give a particular folder name in the OPEN st.
Thanks,
Debaprasad Tripathy
it is working great in ASP page after removing STOP from the code.I have a small doubt.By default it creates the data file in c:winntsystem32 .Is it possible to give a particular folder name in the OPEN st.
Thanks,
Debaprasad Tripathy
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Sure, have the caller specify the full path to the file.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I don't know exactly what's the intention of the code, however, note that writing to WinntSystem32 is a) "impolite" b) if the disk is NTFS and system well configured, you probably won't even be able to write there without Administrator privileges. Consider writing to temp directory (GetTempPath).
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi Jugoslav,
This was my thinking of how the file got to system32:
if the caller doesn't include the full path to the file, then the file is opened in the current directory. If the COM object is called by an ASP page, then the calling app is IIS and system32 is the apps current dir.
In any case, the ASP script should use a full path in the call.
-John
This was my thinking of how the file got to system32:
if the caller doesn't include the full path to the file, then the file is opened in the current directory. If the COM object is called by an ASP page, then the calling app is IIS and system32 is the apps current dir.
In any case, the ASP script should use a full path in the call.
-John
![](/skins/images/D3C0B914909A6564BBB97F4AD1ED1973/responsive_peak/images/icon_anonymous_message.png)
Reply
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page