Back to Contents Previous Next
5. ‘On/Off bits’
Throughout Wimp programming, the presence or otherwise of some feature e.g. an icon border, a menu-tick, etc. is often signified simply by the state of a specified single data bit somewhere in the depths of a definition held in memory. If the bit is 1 (’set’) then the feature is present: if the bit is 0 (’unset’) then it isn’t.
Dr Wimp hides the tricky detail, but it is still essential to give you, the programmer, the power to control such features yourself, via the various wimp-functions.
You will therefore find many instances where Dr Wimp uses the same philosophy of 0/1 for ‘off/on’, ‘disabled/enabled’, etc. For instance, if you want to put a menu-tick against a menu item you would use:
PROCwimp_menutick(menuhandle%,itemnumber%,1)
and if you wanted to remove the menu-tick you would use:
PROCwimp_menutick(menuhandle%,itemnumber%,0)
i.e. the same wimp-function but with a different third parameter controlling the effect.
Similarly, if you want to check whether or not an icon is already selected you would use:
selected%=FNwimp_geticonselect(window%,icon%)
which will return 1 if the icon is selected, or 0 if not.
You will find that you will rapidly assimilate this simple practice.
(Note that TRUE/FALSE is used instead of 1/0 in a few places in Dr Wimp, but there are special reasons for these exceptions and they should not cause confusion.)
Top of page Back to Contents Previous Next