- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I am trying to write a subroutine to convert a variant to a string but I am not having any success. I would be grateful for any assistance.
The code I have come up with so far is:
subroutine
VariantToString(V, Str) use ifwinty use ifcom implicit none type(variant), intent(in):: V character(len=*), intent(out):: Str integer*4:: Hr select case (V%varVal%vt) case (VT_BSTR)Hr = ConvertBSTRtoString( V%varVal%bstrVal, Str )
if ( Hr .ne. S_OK ) thenStr = ""
end case default Str = "" end selectend
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I think you ought to define a length foryour character buffer. Try
CHARACTER(100) STR
and see if that works. I assume ConvertBSTRtoString is defined in one of the IVF modules you are USEing, along with S_OK and VT_BSTR etc. ? There should be a routine or function for determining the length of the bit-string buffer, so that you can test if your character string buffer is large enough to take the bit string. If not, you can do it using
INTEGER(4) strbufflen
POINTER (pString, strbufflen)
...
pString=V%varVal%bstrVal - 4
The bit-string pointer 'V%varVal%bstrVal' points to the first character in the bit string, butthe bit string itselfis preceded by 4-bytes that stores the length of the bit string buffer, so point 'pString' to the first of these 4 bytes, after which the bit-string lengthwillbe accessable as 'strbufflen'.
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page