/ Forums / Advansys Formativ / Creating Solutions with Formativ / Exiting the applet when the user presses “Cancel”

  • Creator
    Topic
  • #4062
    Anonymous

    Hello,

    I’m trying to design an applet that is a sequence of dialogue boxes. Ordinarily, when the user presses next the applet will just move to the next dialogue box (no problem there). However, I would like the applet to exit entirely when the user presses Cancel.

    My test code is below and it does not work. It seems the variable Cmd successfully gets set to cExit (999) after the Select Case statement, but loop still continues. It’s driving me crazy since I told it loop until Cmd=cExit.

    Any input is appreciated!

    Thanks,
    Kate

    ‘*******************
    ‘Global Constants
    ‘*******************

    Const cExit =999
    Const cDlg1 =101
    Const cDlg2 =102

    ‘*******************
    ‘Main Routine
    ‘*******************

    Sub Main(ClientState, GWEvent)

    Dim Dlg
    Dim Cmd

    ‘*******************
    ‘Dialogue 1
    ‘*******************
    Do

    set Dlg = Utilities.NewControlBoxDialog
    with Dlg
    .Caption = “Advansys Formativ”
    .Title = “Dialogue 1”
    .Description = “This is Dialogue 1.”
    end with

    Cmd=cDlg1

    If Cmd = cDlg1 Then
    Select Case Dlg.Execute
    Case Btn1 Cmd = cDlg2
    Case Btn2 Cmd = cExit
    Case Else Cmd = cExit
    End Select
    End If

    ‘*******************
    ‘Dialogue 2
    ‘*******************
    If c=Dlg2 Then
    set Dlg = Utilities.NewControlBoxDialog
    with Dlg
    .Caption = “Advansys Formativ”
    .Title = “Dialogue 2”
    .Description = “Dialogue 2”
    end with

    if Dlg.Execute = Btn1 then
    MsgBox(“OK pressed”)
    Else
    MsgBox(“Something else pressed”)
    end if
    End If

    Loop Until Cmd=cExit

    end sub

  • Author
    Replies
  • #6993
    Support 1a
    Participant

    Try this code. The Cmd variable needed to be set again down near dialog 2.

    Regards,

    Advansys Support

    '*******************
    'Global Constants
    '*******************
     
    Const cExit =999
    Const cDlg1 =101
    Const cDlg2 =102
     
    '*******************
    'Main Routine
    '*******************
     
    Sub Main(ClientState, GWEvent)
     
      Dim Dlg
      Dim Cmd
     
      '*******************
      'Dialogue 1
      '*******************
      Do
     
        set Dlg = Utilities.NewControlBoxDialog
        with Dlg
         .Caption = "Advansys Formativ"
         .Title = "Dialogue 1"
         .Description = "This is Dialogue 1."
        end with
     
        Cmd = cDlg1
     
        If Cmd = cDlg1 Then
         Select Case Dlg.Execute
           Case Btn1 Cmd = cDlg2
           Case Else Cmd = cExit
         End Select
        End If
     
        '*******************
        'Dialogue 2
        '*******************
        If Cmd = cDlg2 Then
         set Dlg = Utilities.NewControlBoxDialog
         with Dlg
           .Caption = "Advansys Formativ"
           .Title = "Dialogue 2"
           .Description = "Dialogue 2"
         end with
     
         ' ** Set the variable Cmd value to the button pressed **
         Select Case Dlg.Execute
           Case Btn1 Cmd = cExit
                     MsgBox("OK pressed")
           Case Else Cmd = cExit
                     MsgBox("Something else pressed")
         End Select
        End If
     
      Loop Until Cmd=cExit
     
    end sub
    
    #6992
    kparmelee
    Participant

    A ha!!!

    Actually, I hadn’t even attempted to make the “Exit” code work for Dialogue 2 since I couldn’t get it to work for Dialogue 1.

    It turns out it was my line
    If C=Dlg2 Then

    that should read
    If Cmd=Dlg2 Then

    that was messing Dialogue 1 up.

    *sigh* for want of a shoe, the horse was lost…

    Thank you so much!

    Kate

    #6994
    Support 1a
    Participant

    Glad to be of assistance.

    Version 2.0, scheduled for release at the end of this month, makes working with dialogs much easier. You’ll find a link to the download on our home page if you are interested.

    Regards,

    Advansys Support

Viewing 3 replies - 1 through 3 (of 3 total)
  • You must be logged in to reply to this topic.