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 

Using core4() and loc()

 
Post new topic   Reply to topic    forums.silverfrost.com Forum Index -> 64-bit
View previous topic :: View next topic  
Author Message
wahorger



Joined: 13 Oct 2014
Posts: 1217
Location: Morrison, CO, USA

PostPosted: Fri Mar 01, 2024 4:06 pm    Post subject: Using core4() and loc() Reply with quote

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/viewtopic.php?t=3956&highlight=pcore) but that is not supported (throws an error during compilation). Is there a better way?
Back to top
View user's profile Send private message Visit poster's website
PaulLaidler
Site Admin


Joined: 21 Feb 2005
Posts: 7927
Location: Salford, UK

PostPosted: Fri Mar 01, 2024 4:43 pm    Post subject: Reply with quote

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.
Back to top
View user's profile Send private message AIM Address
wahorger



Joined: 13 Oct 2014
Posts: 1217
Location: Morrison, CO, USA

PostPosted: Fri Mar 01, 2024 6:29 pm    Post subject: Reply with quote

Here's the code:
Code:
   integer(7):: pcore_test
   pcore_test = pcore7(loc(r))


and here's the 64-bit compile

Code:
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
Back to top
View user's profile Send private message Visit poster's website
wahorger



Joined: 13 Oct 2014
Posts: 1217
Location: Morrison, CO, USA

PostPosted: Fri Mar 01, 2024 6:47 pm    Post subject: Reply with quote

For 32-bit usage:

Using the following declarations:
Code:

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:
Code:

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.

Code:

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.
Back to top
View user's profile Send private message Visit poster's website
wahorger



Joined: 13 Oct 2014
Posts: 1217
Location: Morrison, CO, USA

PostPosted: Fri Mar 01, 2024 11:56 pm    Post subject: Reply with quote

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.
Back to top
View user's profile Send private message Visit poster's website
JohnCampbell



Joined: 16 Feb 2006
Posts: 2554
Location: Sydney

PostPosted: Sat Mar 02, 2024 7:27 am    Post subject: Reply with quote

Bill,

Quote:
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
Code:
!  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
Back to top
View user's profile Send private message
PaulLaidler
Site Admin


Joined: 21 Feb 2005
Posts: 7927
Location: Salford, UK

PostPosted: Sat Mar 02, 2024 8:39 am    Post subject: Reply with quote

ABSOLUTE_ADDRESS with ALLOCATE is simpler to use than PCORE7. See item 423 in cwplus.enh.
Back to top
View user's profile Send private message AIM Address
wahorger



Joined: 13 Oct 2014
Posts: 1217
Location: Morrison, CO, USA

PostPosted: Sun Mar 03, 2024 6:04 am    Post subject: Reply with quote

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!!
Back to top
View user's profile Send private message Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    forums.silverfrost.com Forum Index -> 64-bit 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