handling yes or no in question dialogue

Comments

2 comments

  • Avatar
    paddy

    Ok, I added the following code to exit the installation if the variable continue_installation that is defined by "showquestion" dialogue is false. But irrespective of I press "yes" or "no" from the showquestion dialogue, the installer just exits. So, there is not effect. I feel I'm not accessing the "continue_installation" variable defined in the "showquestion" dialogue. Would you please let me know how to access the variable correctly? - <exit> <customerrormessage>Installation aborted ${continue_installation}</customerrormessage> <rulelist> <isfalse> <value>continue_installation</value> </isfalse></rulelist> </exit>

  • Avatar
    cjw

    Try checking the value of the <showquestion> equals vs the values "yes" and "no".

    Here's how I use it. I have an <exit> action where I check the variable for the value "no", and if it is not no then allow it to proceed, which allows simpler code in the case where the <showquestion> is not executed because its <rulelist> says it does not need to be displayed.

    <actionGroup>
      <actionList>
        <registryGet>
          <key>HKEY_LOCAL_MACHINE\SOFTWARE\${project.vendor}\${project.fullName}</key>
          <name>Version</name>
          <variable>previousVersion</variable>
        </registryGet>
    
        <showQuestion>
          <abortOnError>1</abortOnError>
          <explanation>Warn the user they are about to downgrade and allow them to abort installation.</explanation>
          <text>A newer version ${previousVersion} is already installed on this computer. Are you sure you want to continue and downgrade to version ${project.version}?</text>
          <default>no</default>
          <variable>downgradeAnswer</variable>
          <ruleList>
            <compareValues>
              <logic>does_not_equal</logic>
              <value1>${previousVersion}</value1>
              <value2>Unknown variable</value2>
            </compareValues>
    
            <compareValues>
              <logic>greater</logic>
              <value1>${previousVersion}</value1>
              <value2>${project.version}</value2>
            </compareValues>
          </ruleList>
        </showQuestion>
    
        <exit>
          <exitCode>0</exitCode>
          <ruleList>
            <compareValues>
              <logic>equals</logic>
              <value1>${downgradeAnswer}</value1>
              <value2>no</value2>
            </compareValues>
          </ruleList>
        </exit>
      </actionList>
    </actionGroup>
    

Please sign in to leave a comment.