I am having trouble getting a button in a window to be disabled. All of the conditions are met for disablement, the code gets executed, but the button stays enabled.
Here’s the code:
! Machine Quals checks
MESSAGE('IN THE NEW SELECTION EMBED')
CLEAR(Qua:CAM_Num) ; CLEAR(Qua:MachineName)
!SET(MachineQuals,0)
Qua:CAM_Num = GLO:CAM_Num
SET(Qua:CAMMachineQuals,Qua:CAMMachineQuals)
LOOP
NEXT(MachineQuals)
IF ERRORCODE()
DISABLE(?Change)
BREAK
.
IF Qua:CAM_Num = GLO:CAM_Num AND CLIP(Sch:MachineName) = CLIP(Qua:MachineName) !OR GLO:ADMIN = 1
!CLEAR(Qua:CAM_Num) ; CLEAR(Qua:MachineName) ; CLEAR(Qua:Qualified)
message('should enable')
ENABLE(?Change)
BREAK
.
MESSAGE('Qua:CAM_Num = ' & Qua:CAM_Num & '|' & 'GLO:CAM_Num = ' & GLO:CAM_Num & '|' & 'Sch:MachineName = ' & Sch:MachineName & '|' & 'Qua:MachineName = ' & Qua:MachineName)
IF Qua:CAM_Num = GLO:CAM_Num
CYCLE
ELSE
MESSAGE('You are not qualified to use this machine.')
DISABLE(?Change)
DO RefreshWindow
BREAK
.
.
=================================
The button of interest is ?Change
, but I notice that ?Change:2
has #ORIG(?Change)
in its window definition. Do you think that ORIG designation is confusing things?
BUTTON('&Change'),AT(133,172,49,14),USE(?Change:2),LEFT,ICON('WACHANGE.ICO'),DEFAULT, |DISABLE,FLAT,HIDE,MSG('Change the Record'),SKIP,TIP('Change the Record'),#LINK(?Delete:2), |
#ORIG(?Change),#SEQ(2),#ORDINAL(3)
BUTTON('&Add/Change Sessions Booked'),AT(346,182,120,14),USE(?Change),LEFT,ICON('WACHANGE.ICO'), |
MSG('Add or Change Sessions for the highlighted Machine'),TIP('Add or Chang' & |
'e Sessions for the highlighted Machine'),#ORIG(?Change),#SEQ(22),#ORDINAL(14)