![forums.silverfrost.com Forum Index](templates/subSilver/images/logo_phpBB.gif) |
forums.silverfrost.com Welcome to the Silverfrost forums
|
View previous topic :: View next topic |
Author |
Message |
wahorger
![](http://cjdsoftware.com/wp-content/uploads/2016/06/cjd-color-avatar.png)
Joined: 13 Oct 2014 Posts: 1217 Location: Morrison, CO, USA
|
Posted: Fri Mar 01, 2024 4:06 pm Post subject: Using core4() and loc() |
|
|
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 |
|
![](templates/subSilver/images/spacer.gif) |
PaulLaidler Site Admin
Joined: 21 Feb 2005 Posts: 7926 Location: Salford, UK
|
Posted: Fri Mar 01, 2024 4:43 pm Post subject: |
|
|
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 |
|
![](templates/subSilver/images/spacer.gif) |
wahorger
![](http://cjdsoftware.com/wp-content/uploads/2016/06/cjd-color-avatar.png)
Joined: 13 Oct 2014 Posts: 1217 Location: Morrison, CO, USA
|
Posted: Fri Mar 01, 2024 6:29 pm Post subject: |
|
|
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 |
|
![](templates/subSilver/images/spacer.gif) |
wahorger
![](http://cjdsoftware.com/wp-content/uploads/2016/06/cjd-color-avatar.png)
Joined: 13 Oct 2014 Posts: 1217 Location: Morrison, CO, USA
|
Posted: Fri Mar 01, 2024 6:47 pm Post subject: |
|
|
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 |
|
![](templates/subSilver/images/spacer.gif) |
wahorger
![](http://cjdsoftware.com/wp-content/uploads/2016/06/cjd-color-avatar.png)
Joined: 13 Oct 2014 Posts: 1217 Location: Morrison, CO, USA
|
Posted: Fri Mar 01, 2024 11:56 pm Post subject: |
|
|
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 |
|
![](templates/subSilver/images/spacer.gif) |
JohnCampbell
Joined: 16 Feb 2006 Posts: 2554 Location: Sydney
|
Posted: Sat Mar 02, 2024 7:27 am Post subject: |
|
|
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 |
|
![](templates/subSilver/images/spacer.gif) |
PaulLaidler Site Admin
Joined: 21 Feb 2005 Posts: 7926 Location: Salford, UK
|
Posted: Sat Mar 02, 2024 8:39 am Post subject: |
|
|
ABSOLUTE_ADDRESS with ALLOCATE is simpler to use than PCORE7. See item 423 in cwplus.enh. |
|
Back to top |
|
![](templates/subSilver/images/spacer.gif) |
wahorger
![](http://cjdsoftware.com/wp-content/uploads/2016/06/cjd-color-avatar.png)
Joined: 13 Oct 2014 Posts: 1217 Location: Morrison, CO, USA
|
Posted: Sun Mar 03, 2024 6:04 am Post subject: |
|
|
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 |
|
![](templates/subSilver/images/spacer.gif) |
|
|
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
|