Would be great to have this new control to be able update its output dynamically with window_update@. %wx does not allow dynamic update. This became useful after introducing the new Clearwin+ option color=$aabbcc where aabbcc is hex number for RGB color. Good also to add output of HEX numbers to %cl palette
New control %rx for HEX
I will make a note of this.
Dan,
Does UPDATE_WINDOW@ (iWindow_Handle) do it? (i.e. you update the whole window). I'm surprised that WINDOW_UPDATE@ doesn't.
Eddie
Yes, that's still surprising to me too, it's kind of antiintuitive. Why we can not write things many times into the same spot is pure hidden science, but we discussed that here before and developers find the logic in that...All writes are not window_update'able. And you definitely know, but if not take a chair - the reads in place of writes, the %rd, %rf, %rs etc should be used instead and only they are dynamically updatable. I suspect that there existed some shadow logic or difficulty of implementation in Windows API at the time of Clearwin+ development behind these writes which developers couldn't overjump easily. Some easy things sometimes are really hard to implement. Same i suspect was with the alignment of all CWP controls which are aligned keeping same top of them on a straight line while it has to be the bottom to look perfect
Dan,
If you don't mind the Window 'winking' at you, then you can update %w? 'writes' after a fashion ....
WINAPP
OPTIONS (INTL)
PROGRAM W
INCLUDE <WINDOWS.INS>
CHARACTER*(50) TEXT
COMMON TEXT
INTEGER, EXTERNAL :: iButton
TEXT='Initial run'
10 CONTINUE
IA=WINIO@ ('%ca[Test]%nl%ws%2nl&', TEXT)
IA=WINIO@ ('%10^`bt[Change string]', iBUTTON)
IF (IA .EQ. 1) GO TO 10
END
INTEGER FUNCTION iBUTTON()
INCLUDE <WINDOWS.INS>
CHARACTER*(50) TEXT
COMMON TEXT
TEXT = 'Changed text'
iBUTTON = -1
END
FREEZE_WINDOW_CONTENTS@ doesn't help overcome the shrink-grow in Windows 7. Perhaps someone more patient than I am knows how to do it.
And yes, I was surprised at the non-updatability of the %w? formats. It only goes to show how little of Clearwin+ I actually use.
Eddie
A small example for hexa output with update - not 'elegant' but working:
winapp
program hexa
IMPLICIT NONE
INCLUDE <WINDOWS.INS>
external set_hex
integer*4 j,nr
character*8 hex
common /mk_hex/ nr,hex
nr = 100
hex = '64 '
j = winio@('%ca[]%sy[3d_thin]decimal%il%^3rd--> hexa %`2rs%nl%cn'&
//'%bt[Close]',0,255,nr,set_hex,hex)
end
integer function set_hex()
integer*4 nr
character*8 hex
common /mk_hex/ nr,hex
write(hex,'(Z2.2)')nr
set_hex = 1
end
Regards - Wilfried
Well, there is no way back...Since Clearwin+ mostly allows that I adopted the no-compromise style like in this converter of F-to-C-to-K-to-eV one in Users's Examples
https://forums.silverfrost.com/Forum/Topic/823&postdays=0&postorder=asc&start=15
where you type anything in any field and all other fields update automatically. And everyone here already expect that all should work similar way. And all works great but the HEX
I have added %rd[radix=16] and uploaded a new DLL to http://www.silverfrost.com/beta/salflibc.exe.
This gives hexadecimal input but you could use any value for the radix in the range 2 to 36.
Thanks Paul, It works displaying HEX well. But may be i am doing something wrong, when using same for input if i add %dd spin wheel to %rd[radix=16] and click up arrow then all works until hex number reach 10 (A). It then starts over from 1 instead of going further to B,C...
I will take a look. I did not test this case.
I have fixed this and uploaded a new beta. I have assumed that, when using %dd with a radix other than 10, decrements will stop at zero.
Paul, yes, that fixes everything, thanks.
And here is the code (i collect many such small useful programs in my TOOLS menu) for everyone consumption. Code is doing hex and binary conversions needed more now in Clearwin+. It needs to add any background texture file BkGrBin.bmp (or remove that line completely). Similarly sound warning needs to be added or completely removed (the line: res=PLAY_SOUND_RESOURCE@( 'o_o' )). Probably there exist also more elegant and short way to convert integer to binary, i did that from first principles. Anyone are welcome to modify it, for example, rewrite it using modules etc
The first line of the code
integer function BinaryNumbConversion ()
can be removed too if use this as a standalone program
integer function BinaryNumbConversion ()
use clrwin
integer*4 Numb_Integer, Numb_Hex
character*16 Numb_Binary, Numb_BinaryOld
common /BinaryConvers_/ Numb_Integer, Numb_Hex, Numb_Binary, Numb_BinaryOld
external update_Slider, update_Integer, update_Hex, update_Binary
data Numb_Integer/0/, Numb_Hex/0/, Numb_Binary/' '/, Numb_BinaryOld/' '/
save
i = winio@('%sy[3d_raised]%ww[casts_shadow]&')
i = winio@('%ca[Binary Number Conversions ]&')
I = WINIO@('%wp[BkGrBin]&')
i = winio@('%bg[btnface]&')
i = winio@('%ob&')
i = winio@('%fn[Arial]%ts%tc[black]%bf Integer%ta&
&%dd%il%`bg[white]%^8rd%`il%sf%ff&', 2.d0, 1, -2**15+1, 2**15-1, Numb_Integer, update_Integer)
i = winio@('%fn[Arial]%ts%tc[black]%bf Hex%ta&
& %`bg[white]%dd%8^rd[radix=16]%sf%ff&', 2.0d0, 1, Numb_Hex, update_Hex)
i = winio@('%fn[Arial]%ts%tc[black]%bf Binary%ta&
&%`bg[white]%^12rs%sf%ff&', 2.0d0, Numb_Binary, update_Binary)
i = winio@('%cb&')
i = winio@('%sc&',update_Integer)
i = winio@('%ac[esc]&','exit')
i = winio@('%nl%ff%cn%3`bt[OK]')
BinaryNumbConversion = 2
end
!................................................
integer function update_Integer ()
use clrwin
integer*4 Numb_Integer, Numb_Hex
character*16 Numb_Binary, Numb_BinaryOld
common /BinaryConvers_/ Numb_Integer, Numb_Hex, Numb_Binary, Numb_BinaryOld
Numb_Binary = ' '
! Binarry is filled in end-to-beginning direction
do i=1,15 ! 16...
iSetBit2 = ( abs(Numb_Integer)/2**(i-1)) * 2**(i-1) - &
( abs(Numb_Integer)/2**(i)) * 2**(i)
iSetBit = iSetBit2 / 2**(i-1)
if(iSetBit.eq.0) Numb_Binary(17-i:17-i) = '0'
if(iSetBit.eq.1) Numb_Binary(17-i:17-i) = '1'
enddo
i=16
if(Numb_Integer.ge.0) Numb_Binary(17-i:17-i) = '0'
if(Numb_Integer.lt.0) Numb_Binary(17-i:17-i) = '1'
Numb_Hex = Numb_Integer
call WINDOW_UPDATE@(Numb_Binary)
call WINDOW_UPDATE@(Numb_Hex )
update_Integer = 1
end function
!................................................
integer function update_Hex ()
use clrwin
integer*4 Numb_Integer, Numb_Hex
character*16 Numb_Binary, Numb_BinaryOld
common /BinaryConvers_/ Numb_Integer, Numb_Hex, Numb_Binary, Numb_BinaryOld
Numb_Integer = Numb_Hex
Numb_Binary = ' '
! Binarry is filled in end-to-beginning direction
do i=1,15 ! 16...
iSetBit2 = ( abs(Numb_Integer)/2**(i-1)) * 2**(i-1) - &
( abs(Numb_Integer)/2**(i)) * 2**(i)
iSetBit = iSetBit2 / 2**(i-1)
if(iSetBit.eq.0) Numb_Binary(17-i:17-i) = '0'
if(iSetBit.eq.1) Numb_Binary(17-i:17-i) = '1'
enddo
i=16
if(Numb_Integer.ge.0) Numb_Binary(17-i:17-i) = '0'
if(Numb_Integer.lt.0) Numb_Binary(17-i:17-i) = '1'
call WINDOW_UPDATE@(Numb_Integer)
call WINDOW_UPDATE@(Numb_Binary)
update_Hex = 1
end function
!......................................................
integer function update_Binary ()
use clrwin
integer*4 Numb_Integer, Numb_Hex
character*16 Numb_Binary, Numb_BinaryOld
common /BinaryConvers_/ Numb_Integer, Numb_Hex, Numb_Binary, Numb_BinaryOld
character*16 Numb_Binary2
do i=1,16
N_ok=0
if(Numb_Binary(i:i).eq.'1'.or.Numb_Binary(i:i).eq.'0'.or.Numb_Binary(i:i).eq.' ')N_ok=1
if(N_ok.ne.1) then
Print*,' Error ' , Numb_Binary
res=PLAY_SOUND_RESOURCE@( 'o_o' )
Numb_Binary = Numb_BinaryOld
goto 10000
endif
enddo
Numb_Binary2 = Numb_Binary
call trimr@(Numb_Binary2)
Numb_Integer = 0
do i=16,2,-1 ! 16...
if(Numb_Binary2(i:i).eq.'1') Numb_Integer = Numb_Integer + 2**(16-i)
enddo
if(Numb_Binary2(1:1).eq.'1') Numb_Integer= -Numb_Integer
Numb_Hex = Numb_Integer
call WINDOW_UPDATE@(Numb_Integer)
call WINDOW_UPDATE@(Numb_Hex)
10000 update_Binary = 1
Numb_BinaryOld = Numb_Binary
end function

Or maybe...
WINAPP
program hex
integer n,iw,winio@
n = 127
iw=winio@('%ca[Hex and Binary]&')
iw=winio@('%ob&')
iw=winio@('%dy&',0.4d0)
iw=winio@('Integer%ta%dd%rd&',1,n)
iw=winio@('%ffHex %ta%dd%rd[radix=16]&',1,n)
iw=winio@('%ffBinary %ta%dd%rd[radix=2]&',1,n)
iw=winio@('%cb&')
iw=winio@('%ff%nl%cn%bb[OK]')
end program hex
RESOURCES
1 24 default.manifest
😃 cool
Next will be creating same without programming at all using just the mouse and Visual Clearwin+ LOL
Please do not forget to document it well and include this good example there (i'd even stress - always include examples, more examples !)