![]() |
|
||||||||||||||||||||||||
|
|
Simple mixed strings concatenation (StrConcatExamples) This is a simple example illustrating how f90VB allows concatenation of mixed strings types. Notice how we start by creating a BStrings and then concatenate another two Fortran strings at the end:
And here is the example: |
||||||||||||||||||||||||
program StrConcatExamples
!Demonstrates the use of StrConcat
!Copyright (C) 1999-2000, Canaima Software, Inc.
!All rights reserved
!load f90VB modules
use f90VBDefs
use f90VBBStrings
implicit none
!Declare a BString
integer(BSTRHNDL_KIND)::BstrA
!Declare an OLE String
type(OLESTRING)::OLEStr
!Declare a Fortran string
character(len=5)::FStr
integer(HRESULT_KIND)::iRet
integer::i
character(len=255)::TmpFStr
!concatenate a Fortran String to a BString
call StrCopy('This is',BStrA)
call StrConcat(BStrA,' the result of a')
call StrConcat(BStrA,' concatenation operation')
call StrCopy(BstrA, TmpFStr)
print *, trim(TmpFStr)
print *,'Total String length:', StrLenTrim(BstrA)
!concatenate a Fortran String to an OLE String
!note that the first call to StrConcat will
!allocate a new OLEStr
print *,''
print *,'Another example:'
do i=10,15
write(FStr,'(i2)') i
call StrConcat(OLEStr,FStr,iRet)
call StrCopy(OLEStr,TmpFStr)
print *,'OLE String:', trim(TmpFStr)
print *,'Concat. characters:',iRet
print *,'String length:',StrLenTrim(OLEStr)
enddo
!free memory used by dynamic strings
call StrFree(OLEStr)
call StrFree(BStrA)
stop
end
|
|||||||||||||||||||||||||
|
Copyright
© 1998-2000 Canaima Software
For questions regarding this site, send an e-mail to webmaster@canaimasoft.com |
|||||||||||||||||||||||||