Silverfrost Forums

Welcome to our forums

CAST from System.Object to e.g. INTEGER*4 or CHARACTER*4

8 Jun 2011 9:33 #8361

Hello, I know I have posted an simillar topic and I'am annoying! But need strongly help. Here are more Information!

I want to Cast an .NET System.Object to Fortran Datatypes like INTEGER2, INTEGER4 or CHARACTER*?

The INTEGER value I must receive is 1 but if I print the Value after 'transfer' Function it looks like 32123455. The CHARACTER Value should be '28VA1' but after print I see binary character.

I think I get a pointer from the DOTNETGetObjectValue(nIndex) Method.

...
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 ???? 
nResult  = CAST@(oR(1), 'System.Int32') 
VALUE = transfer(nResult ,VALUE) 
print *,VALUE
! Get Object and want to Cast to CHARACTER*6 
oR(2) = DOTNETGetObjectValue(2) 
! CAST ???? 
sString = CAST@(oR(2), 'System.String') 
STR = transfer(sString,STR) 
print *,STR

So what can I do! I need strongly help please!

Greetings from Germany Michael

21 Jun 2019 5:04 #23825

I replied to your other issue as well and have made a more recent post with the example source code hosted on github: https://forums.silverfrost.com/Forum/Topic/3578

Please login to reply.