View previous topic :: View next topic |
Author |
Message |
m.burkhardt
Joined: 02 Sep 2008 Posts: 26
|
Posted: Tue Jun 07, 2011 1:18 pm Post subject: cast from .NET System.Int32 to INTEGER*4 |
|
|
How can I CAST the Datatype from .NET System.Int32 to INTEGER*4?
Is there any table with casting samples?
Thanks allot
Greetings from Germany
Michael |
|
Back to top |
|
|
davidb
Joined: 17 Jul 2009 Posts: 560 Location: UK
|
Posted: Tue Jun 07, 2011 10:13 pm Post subject: Re: cast from .NET System.Int32 to INTEGER*4 |
|
|
m.burkhardt wrote: | How can I CAST the Datatype from .NET System.Int32 to INTEGER*4?
|
Forgive me if I have misunderstood your question. It depends what you mean by CAST since Fortran 95 does not have this concept. The following code works. This is a bit like a dynamic cast in C++. I tried to do a static cast (C and C++) using equivalence but you get a compile time error when you try to equivalence the two variables.
Perhaps there is a .NET utility for doing it; I don't know. Others with more .NET knowledge than I may know some more.
Code: |
program anon
object('System.Int32') :: a
integer*4 :: b
a = 123
! cast a to b at run time using the transfer intrinsic
b = transfer(a,b)
print *, b
end program anon
|
|
|
Back to top |
|
|
m.burkhardt
Joined: 02 Sep 2008 Posts: 26
|
Posted: Wed Jun 08, 2011 7:35 am Post subject: How can I CAST the Datatype from .NET System.Int32 to INTEGE |
|
|
Here is the part of a code I mean:
Code: |
OBJECT("System.Object[]") :: oR
OBJECT("System.Int32") :: nResult
OBJECT("System.String") :: sString
INTEGER*4 VALUE
CHARACTER*10 STR
oR = NEW@("System.Object[],2)
! Get Object and want to Cast to Integer*4
oR(1) = DOTNETGetObjectValue(1)
! CAST ????
VALUE = CAST@(oR(1), INTEGER*4)
VALUE = transfer(???,???)
! Get Object and want to Cast to CHARACTER*6
oR(2) = DOTNETGetObjectValue(2)
! CAST ????
STR = CAST@(oR(2), CHARACTER*6)
STR = transfer(???,???)
|
|
|
Back to top |
|
|
alex21
Joined: 20 Apr 2011 Posts: 75 Location: Australia
|
Posted: Fri Jun 21, 2019 6:00 am Post subject: |
|
|
I am having the same issue, you can work around it simply by not casting from System.Object to a value type, but usually means a bit more code to provide value types un-boxed or their byte representations seem to get messed up...
http://forums.silverfrost.com/viewtopic.php?t=4025 |
|
Back to top |
|
|
|