Silverfrost Forums

Welcome to our forums

Pointers, pointers, pointers!

12 Jan 2012 12:25 #9456

Got a wierd situation. I have a routine (QW_SetAdr defined in a separate DLL) that displays a value on the screen. When it is passed a variable defined through a pointer to a structure variable, it behaves inconsistently. So, to give a coding example:

In the following, CPH is defined in a module and populated elsewhere

TYPE(PHRES), POINTER :: PH
.
.
PH=>CPH
.
.
CALL QW_SetADR (IS, IFLD, PH%Avalue)

Fails to update the field on the screen cleanly.

But…

TYPE(PHRES), POINTER :: PH
.
.
PH=>CPH
.
.
AVALUE = PH%Avalue
CALL QW_SetADR (IS, IFLD, Avalue)

…Works

And…

TYPE(PHRES)          :: PH
.
.
PH=CPH
.
.
CALL QW_SetADR (IS, IFLD, PH%Avalue)

…Works as well

If I try stepping through the code under /debug, it all works OK, but if I just run the app, regardless of whether the relevant code is compiled under /debug or not, sometimes it works, sometimes it doesn't.

Any ideas?

TIA

K

12 Jan 2012 1:49 #9457

OK, sussed it! The routine that displays the value is using the LOC of the variable and was testing for that being .le.0, and, of course, under 64-bit OS, the 4-byte addresses can and do go negative!

K

Please login to reply.