|
forums.silverfrost.com Welcome to the Silverfrost forums
|
View previous topic :: View next topic |
Author |
Message |
DanRRight
Joined: 10 Mar 2008 Posts: 2826 Location: South Pole, Antarctica
|
Posted: Sun Jul 14, 2013 4:34 am Post subject: New control %rx for HEX |
|
|
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 |
|
Back to top |
|
|
PaulLaidler Site Admin
Joined: 21 Feb 2005 Posts: 7931 Location: Salford, UK
|
Posted: Sun Jul 14, 2013 6:28 am Post subject: |
|
|
I will make a note of this. |
|
Back to top |
|
|
LitusSaxonicum
Joined: 23 Aug 2005 Posts: 2390 Location: Yateley, Hants, UK
|
Posted: Mon Jul 15, 2013 11:38 am Post subject: |
|
|
Dan,
Does UPDATE_WINDOW@ (iWindow_Handle) do it? (i.e. you update the whole window). I'm surprised that WINDOW_UPDATE@ doesn't.
Eddie |
|
Back to top |
|
|
DanRRight
Joined: 10 Mar 2008 Posts: 2826 Location: South Pole, Antarctica
|
Posted: Mon Jul 15, 2013 7:11 pm Post subject: |
|
|
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 |
|
Back to top |
|
|
LitusSaxonicum
Joined: 23 Aug 2005 Posts: 2390 Location: Yateley, Hants, UK
|
Posted: Thu Jul 18, 2013 1:24 pm Post subject: |
|
|
Dan,
If you don't mind the Window "winking" at you, then you can update %w? "writes" after a fashion ....
Code: | 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 |
|
Back to top |
|
|
Wilfried Linder
Joined: 14 Nov 2007 Posts: 314 Location: D�sseldorf, Germany
|
Posted: Thu Jul 18, 2013 2:31 pm Post subject: |
|
|
A small example for hexa output with update - not "elegant" but working:
Code: | 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 |
|
Back to top |
|
|
DanRRight
Joined: 10 Mar 2008 Posts: 2826 Location: South Pole, Antarctica
|
Posted: Fri Jul 19, 2013 7:57 pm Post subject: |
|
|
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
http://forums.silverfrost.com/viewtopic.php?t=1072&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 |
|
Back to top |
|
|
PaulLaidler Site Admin
Joined: 21 Feb 2005 Posts: 7931 Location: Salford, UK
|
Posted: Wed Aug 07, 2013 3:21 pm Post subject: |
|
|
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. |
|
Back to top |
|
|
DanRRight
Joined: 10 Mar 2008 Posts: 2826 Location: South Pole, Antarctica
|
Posted: Thu Aug 08, 2013 12:12 am Post subject: |
|
|
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... |
|
Back to top |
|
|
PaulLaidler Site Admin
Joined: 21 Feb 2005 Posts: 7931 Location: Salford, UK
|
Posted: Thu Aug 08, 2013 6:35 am Post subject: |
|
|
I will take a look. I did not test this case. |
|
Back to top |
|
|
PaulLaidler Site Admin
Joined: 21 Feb 2005 Posts: 7931 Location: Salford, UK
|
Posted: Thu Aug 08, 2013 1:17 pm Post subject: |
|
|
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. |
|
Back to top |
|
|
DanRRight
Joined: 10 Mar 2008 Posts: 2826 Location: South Pole, Antarctica
|
Posted: Fri Aug 09, 2013 3:42 am Post subject: |
|
|
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
Code: |
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
|
Last edited by DanRRight on Fri Aug 09, 2013 4:10 am; edited 5 times in total |
|
Back to top |
|
|
DanRRight
Joined: 10 Mar 2008 Posts: 2826 Location: South Pole, Antarctica
|
Posted: Fri Aug 09, 2013 3:43 am Post subject: |
|
|
Code: |
!................................................
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
|
|
|
Back to top |
|
|
PaulLaidler Site Admin
Joined: 21 Feb 2005 Posts: 7931 Location: Salford, UK
|
Posted: Fri Aug 09, 2013 8:29 am Post subject: |
|
|
Or maybe...
Code: | 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 |
|
|
Back to top |
|
|
DanRRight
Joined: 10 Mar 2008 Posts: 2826 Location: South Pole, Antarctica
|
Posted: Fri Aug 09, 2013 8:38 am Post subject: |
|
|
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 !) |
|
Back to top |
|
|
|
|
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
|