WinBatch Tech Support Home

Database Search

If you can't find the information using the categories below, post a question over in our WinBatch Tech Support Forum.

TechHome

Samples

Can't find the information you are looking for here? Then leave a message over on our WinBatch Tech Support Forum.

Advancing Through a Series of Dialogs


Keywords: control dialog next back button

This is an example of using a "State Machine" for controlling a series of dialogs that have back/next buttons for advancing through a series of dialogs, and allowing the user to backtrack when required.
;Cancel handling
IntControl(72,2,0,0,0)

;State machine Example
State=1
MaxState=5
while State <= MaxState
Statex=strcat(state,"/",MaxState)
switch State
      case 1
            MyDialogFormat=`WWWDLGED,6.1`
            MyDialogCaption=`State Machine`
            MyDialogX=002
            MyDialogY=031
            MyDialogWidth=196
            MyDialogHeight=092
            MyDialogNumControls=003
            MyDialogProcedure=`DEFAULT`
            MyDialogFont=`DEFAULT`
            MyDialogTextColor=`DEFAULT`
            MyDialogBackground=`DEFAULT,DEFAULT`
            MyDialogConfig=0
            MyDialog001=`079,066,033,011,PUSHBUTTON,DEFAULT,"Next >>",1,1,32,DEFAULT,DEFAULT,DEFAULT`
            MyDialog002=`121,066,033,011,PUSHBUTTON,DEFAULT,"Cancel",0,2,DEFAULT,DEFAULT,DEFAULT,DEFAULT`
            ;;;;MyDialog003=`039,066,033,011,PUSHBUTTON,DEFAULT,"<< Back",2,3,DEFAULT,DEFAULT,DEFAULT,DEFAULT`
            MyDialog003=`057,015,046,032,VARYTEXT,StateX,"1/5",DEFAULT,4,DEFAULT,"Microsoft Sans Serif|16384|40|34","0|0|0",DEFAULT`
            ButtonPushed=Dialog("MyDialog")

            if ButtonPushed==1 then State=State+1
            if ButtonPushed==2 then Message("Debug","State 1 cannot go back.  Should not have a back button")
            break

      case 2
      case 3
      case 4
            MyDialogFormat=`WWWDLGED,6.1`
            MyDialogCaption=`State Machine`
            MyDialogX=002
            MyDialogY=031
            MyDialogWidth=196
            MyDialogHeight=092
            MyDialogNumControls=004
            MyDialogProcedure=`DEFAULT`
            MyDialogFont=`DEFAULT`
            MyDialogTextColor=`DEFAULT`
            MyDialogBackground=`DEFAULT,DEFAULT`
            MyDialogConfig=0
            MyDialog001=`079,066,033,011,PUSHBUTTON,DEFAULT,"Next >>",1,1,32,DEFAULT,DEFAULT,DEFAULT`
            MyDialog002=`121,066,033,011,PUSHBUTTON,DEFAULT,"Cancel",0,2,DEFAULT,DEFAULT,DEFAULT,DEFAULT`
            MyDialog003=`039,066,033,011,PUSHBUTTON,DEFAULT,"<< Back",2,3,DEFAULT,DEFAULT,DEFAULT,DEFAULT`
            MyDialog004=`057,015,046,032,VARYTEXT,StateX,"1/5",DEFAULT,4,DEFAULT,"Microsoft Sans Serif|16384|40|34","0|0|0",DEFAULT`
            ButtonPushed=Dialog("MyDialog")

            if ButtonPushed==1 then State=State+1
            if ButtonPushed==2 then State=State-1
            break
      case 5
            MyDialogFormat=`WWWDLGED,6.1`
            MyDialogCaption=`State Machine`
            MyDialogX=002
            MyDialogY=031
            MyDialogWidth=196
            MyDialogHeight=092
            MyDialogNumControls=004
            MyDialogProcedure=`DEFAULT`
            MyDialogFont=`DEFAULT`
            MyDialogTextColor=`DEFAULT`
            MyDialogBackground=`DEFAULT,DEFAULT`
            MyDialogConfig=0
            MyDialog001=`079,066,033,011,PUSHBUTTON,DEFAULT,"Finished",1,1,32,DEFAULT,DEFAULT,DEFAULT`
            MyDialog002=`121,066,033,011,PUSHBUTTON,DEFAULT,"Cancel",0,2,DEFAULT,DEFAULT,DEFAULT,DEFAULT`
            MyDialog003=`039,066,033,011,PUSHBUTTON,DEFAULT,"<< Back",2,3,DEFAULT,DEFAULT,DEFAULT,DEFAULT`
            MyDialog004=`057,015,046,032,VARYTEXT,StateX,"1/5",DEFAULT,4,DEFAULT,"Microsoft Sans Serif|16384|40|34","0|0|0",DEFAULT`
            ButtonPushed=Dialog("MyDialog")
            if ButtonPushed==1 then State=State+1
            if ButtonPushed==2 then State=State-1
            break
     case state
           Message("Debug","Error: Unhandled state")
           state=999999
           break
endswitch
endwhile

Message("All","Done")
exit

;************
;More cancel handline
:CANCEL
cancelxxx=Pause("CANCEL?","If you really want to cancel, press cancel again.  To go back and continue, press OK")
IntControl(72,2,0,0,0)
return






Article ID:   W16417
File Created: 2005:02:18:12:20:28
Last Updated: 2005:02:18:12:20:28