forums.silverfrost.com Forum Index forums.silverfrost.com
Welcome to the Silverfrost forums
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

cast from .NET System.Int32 to INTEGER*4

 
Post new topic   Reply to topic    forums.silverfrost.com Forum Index -> Support
View previous topic :: View next topic  
Author Message
m.burkhardt



Joined: 02 Sep 2008
Posts: 26

PostPosted: Tue Jun 07, 2011 1:18 pm    Post subject: cast from .NET System.Int32 to INTEGER*4 Reply with quote

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
View user's profile Send private message Send e-mail MSN Messenger
davidb



Joined: 17 Jul 2009
Posts: 557
Location: UK

PostPosted: Tue Jun 07, 2011 10:13 pm    Post subject: Re: cast from .NET System.Int32 to INTEGER*4 Reply with quote

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
View user's profile Send private message
m.burkhardt



Joined: 02 Sep 2008
Posts: 26

PostPosted: Wed Jun 08, 2011 7:35 am    Post subject: How can I CAST the Datatype from .NET System.Int32 to INTEGE Reply with quote

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
View user's profile Send private message Send e-mail MSN Messenger
alex21



Joined: 20 Apr 2011
Posts: 65
Location: Australia

PostPosted: Fri Jun 21, 2019 6:00 am    Post subject: Reply with quote

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
View user's profile Send private message MSN Messenger
Display posts from previous:   
Post new topic   Reply to topic    forums.silverfrost.com Forum Index -> Support All times are GMT + 1 Hour
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group