Silverfrost Forums

Welcome to our forums

Using core4() and loc()

1 Mar 2024 3:06 #31186

It appears that I can pass an argument for %ud as a simple loc(), rather than using the CORE* to indicate the type. So, this is memory-model transparent, yes?

I also have used the CORE4 function to pass along the address of a logical as if it is an integer (for radio buttons, specifically) in the 32-bit model.

Is there a memory-independent function to replicate CORE4 I used for the 32-bit model?

There was an old reference to PCORE7 (https://forums.silverfrost.com/Forum/Topic/3521&highlight=pcore) but that is not supported (throws an error during compilation). Is there a better way?

1 Mar 2024 3:43 #31192

Bill

PCORE7 should still work. Please post some code that illustrates the failure.

Regarding the general questions, can you be more specific? Maybe post some code that illustrates what you are aiming to do.

1 Mar 2024 5:29 #31195

Here's the code:

	integer(7):: pcore_test
	pcore_test = pcore7(loc(r))

and here's the 64-bit compile

0026)         pcore_test = pcore7(loc(r))
*** Error 620: INTRINSIC PCORE7 is not yet implemented
    1 ERROR  [<CLEARWIN_SETUP> FTN95 v9.02.0.0]
*** Compilation failed
M
1 Mar 2024 5:47 #31196

For 32-bit usage:

Using the following declarations:

INTEGER:: I,J=123,K=0
LOGICAL:: BUTTON_VAL=.TRUE.
INTEGER,EXTERNAL:: MY_SUB

when I wish to pass the LOGICAL to a radio button, I use:

I = WINIO@('%rb[Press Me]&',CORE4(LOC(BUTTON_VAL))) ! use a logical with a radio button
I = WINIO@('%^rd%ud&',j,my_sub,k) ! pass an integer value to MY_SUB when the control is changed

winio@() processes this as if it is a reference to 32-bit integer (what is needed for a radio button). Basically, it does an end-around to present to winio@() a pointer to an integer, which is actually a logical.

For 64-bit (and by extension, 32-bit), if PCORE7 (or equivalent) were to perform the same function as CORE4 or CORE8 (automatically for the appropriate memory model), that would work very well!

For %ud, when passing a simple integer, I will have to do int(value,7). Lots of changes to the code, but I expected that. And it will be more portable between memory models.

I = WINIO@('%^rd%ud&',j,my_sub,int(k,7)) ! pass an integer value to MY_SUB when the control is changed

I hope this explains in better detail what I am trying to accomplish.

1 Mar 2024 10:56 #31199

I want to apologize for what I think was a waste of your time. I've figured it out, reminded by my own code as to what I need it to do.

For the logical-to-look-like-an-integer purpose, it all still works. CORE4 works in any memory model, and I only use it for this kind of purpose.

I reviewed all my code, and use loc() for %ud when I am passing an address of an item. So that is consistent.

The modifications I did have to make were %ud related when passing a true integer value. I have to wrap that in a int(var,7) wrapper to make it fit the needed typing.

So, the only real changes are when %ud is used and an integer is needed.

On the plus side, I did find a few places where (7) was used when defining a variable that was NOT appropriate, and a few places where it WAS (and had not yet made) appropriate.

2 Mar 2024 6:27 #31201

Bill,

I = WINIO@('%rb[Press Me]&',CORE4(LOC(BUTTON_VAL))) ! use a logical with a radio button

This is much more complex than I remember of %rb !

Why not try logical :: BUTTON_VAL integer :: I_BUTTON_VAL equivalence ( BUTTON_VAL, I_BUTTON_VAL ) ... I = WINIO@('%rb[Press Me]&', I_BUTTON_VAL ) ! use a logical with

equivalence has not yet been deleted from Fortran, but they are trying.

The following works ok ! test logical use of radio button value use iso_fortran_env

   logical :: BUTTON_VAL
   integer :: I_BUTTON_VAL, i
   equivalence ( BUTTON_VAL, I_BUTTON_VAL )

    write (*,*) 'Vern : ',compiler_version ()
    write (*,*) 'Opts : ',compiler_options ()

   button_val = .true.
   write (*,*) button_val, i_button_val, '  .true.'

   button_val = .false.
   write (*,*) button_val, i_button_val, '  .false.'

   do i = -3,3
     i_button_val = i
     write (*,*) button_val, i_button_val, i
   end do

   end
2 Mar 2024 7:39 #31202

ABSOLUTE_ADDRESS with ALLOCATE is simpler to use than PCORE7. See item 423 in cwplus.enh.

3 Mar 2024 5:04 #31206

John, yes, that does work and in a few cases I have done this. It obfuscates debugging. Better to actually use the same name for both the control and the code. Maybe that's just me.

Also, I have had problems with equivalence in the past, so I tend not to use it any more.

I do use the ABSOLUTE_ADDRESS in callback routines. Since I just pass the loc(), it works great!!

Please login to reply.