! Paramters:
!  int_arg - the number entered by the user.  To be multiplied by 10 and passed to the 3rd callback
! str_in - the string entered by the user.  To be appended to int_arg, and passed to 2nd callback

subroutine dll_rout(int_arg,str_in,cbproc1,cbproc2,cbproc3)
!dec$ attributes dllexport ::dll_rout
!dec$ attributes alias :'dll_rout'::dll_rout
use dfcom

! Define interface blocks for each of the callback routines
interface 
subroutine cbproc1(c1, i1)
pointer  (c1, foo1)
character *(200) foo1
integer*4 i1
end
subroutine cbproc2(c1)
pointer  (c1, foo1)
character *(20) foo1
end
subroutine cbproc3(i1)
integer*4 i1
end
end interface

! Define the parameters passed to this routine
integer int_arg
character *(*) str_in

character *25 str_out
integer temp
character *5 int_str

! The following paradigm is used for interfacing to the ConvertStringToBSTR
!  routine.  The string created is Unicode, which is 16 bit.  CHARACTER is
!  8 bit, and so an array of INTEGER*2 are used instead of an array of
!  CHARACTERs.
pointer (p1, my_str_in)
pointer (p2, my_str_out)
integer*2 my_str_in(25)
integer*2 my_str_out(25)



! Multiply the value passed by 10, and give it to cbproc3
temp = int_arg * 10
call cbproc3(temp)

! Convert the integer to string, and append it to the string passed,
!  and then give it back to cbproc2 as a BSTR
write(int_str,'(i5.5)')int_arg
str_out = str_in // int_str
p2 = ConvertStringToBSTR(str_out)
call cbproc2(p2)

! Create our message, and pass both it and the original integer to cbproc1
p1 = ConvertStringToBSTR("Fortran says Hello!")
call cbproc1 (p1, int_arg)


! Clean up after ourselves
call SysFreeString(p1)
call SysFreeString(p2)
return
end
