contents   index   previous   next



StrFree

 

f90VB Modules

 

f90VBDefs, f90VBBStrings

Summary

 

StrFree deallocates a Fortran OLE String or a BString and releases its memory to the operating system.

Syntax

 

subroutine StrFree (Str

 

{
type(OLESTRING),intent(inout):: Str |
integer(BSTRHNDL_KIND),intent(inout):: Str
}
 

Arguments

 

Str [Input/Output]

Destination string. Str must be a Fortran OLE String structure or a BString handle.

Comments

 

StrFree releases the memory used by the BString or the Fortran OLE String. When Str is a BString handle, upon return from StrFree, the handle is set to null (f90VB_NULL_PTR). When Str is a Fortran OLE String, Str%Str is deallocated and its content deleted, and Str%StrHndl is set to null.

Examples

 

Program StrFreeExample

 

!Demonstrates how to use StrFree

!copyright 1999-2000, Canaima Software

!All rights reserved

 

!load f90VB modules

use f90VBDefs

use f90VBBStrings

implicit none

 

!declare a BStrings

integer(BSTRHNDL_KIND):: BStr

!declare a Fortran OLE String structure

type(OLESTRING)::OLEStr

 

!utility variables

integer(HRESULT_KIND)::iRet

 

 

!print uninitialized string handles

print *,'BString handle:',Bstr

print *,'Fortran OLE String:'

if (associated(OLEStr%Str)) then

    print *,'OLEStr Str status: Associated'

    print *,'Address of OLEStr String:',loc(OLEStr%Str)

    print *,'Size of OLEStr String:', size(OLEStr%Str)

    print *,'OLEStr Handle:',OLEStr%StrHndl

else

    print *,'OLEStr Str status: Not Associated'

    print *,'OLEStr Str status: Associated'

    print *,'Address of OLEStr String:',loc(OLEStr%Str)

    print *,'Size of OLEStr String:', size(OLEStr%Str)

    print *,'OLEStr Handle:',OLEStr%StrHndl

endif

 

print *,''

 

!initialize BStr and OLEStr

call StrCopy('This is my Fortran BString',BStr,iRet)

print *,'Characters copied to BStr:',iRet

call StrCopy('and this one is a Fortran OLE String',OLEStr,iRet)

print *,'Characters copied to OLEStr:',iRet

 

print *,''

print *,'BString handle:',Bstr

print *,'Fortran OLE String:'

if (associated(OLEStr%Str)) then

    print *,'OLEStr Str status: Associated'

    print *,'Address of OLEStr String:',loc(OLEStr%Str)

    print *,'Size of OLEStr String:', size(OLEStr%Str)

    print *,'OLEStr Handle:',OLEStr%StrHndl

else

    print *,'OLEStr Str status: Not Associated'

    print *,'OLEStr Str status: Associated'

    print *,'Address of OLEStr String:',loc(OLEStr%Str)

    print *,'Size of OLEStr String:', size(OLEStr%Str)

    print *,'OLEStr Handle:',OLEStr%StrHndl

endif

 

!free strings memory

call StrFree(Bstr)

call StrFree(OLEStr)

 

!Show nullified pointers and handles

print *,''

print *,'BString handle:',Bstr

print *,'Fortran OLE String:'

if (associated(OLEStr%Str)) then

    print *,'OLEStr Str status: Associated'

    print *,'Address of OLEStr String:',loc(OLEStr%Str)

    print *,'Size of OLEStr String:', size(OLEStr%Str)

    print *,'OLEStr Handle:',OLEStr%StrHndl

else

    print *,'OLEStr Str status: Not Associated'

    print *,'OLEStr Str status: Associated'

    print *,'Address of OLEStr String:',loc(OLEStr%Str)

    print *,'Size of OLEStr String:', size(OLEStr%Str)

    print *,'OLEStr Handle:',OLEStr%StrHndl

endif

 

!free memory used by dynamic strings

call StrFree(OLEStr)

call StrFree(BStr)

 

stop

end

Related Topics

 

For information about See
Creating new BStrings BStrAlloc
Creating new Fortran OLE Strings OLEStrAlloc
Changing the content of a BString BStrReAlloc, StrCopy
Changing the content of a Fortran OLE String StrCopy

 


StrIndex