Check Boxes Screen

These examples show how you can detect whether or not a checkbox was checked on a Check Boxes screen, and react using action script. Each of the action script examples below can be copied to the On Next event (before the Screen.Next action) of a default Check Boxes screen to see their functionality. The On Next event can be found on the Actions tab of the screen's properties.

Example 1

-- Create a string to hold the checkbox states that were checked to be displayed in the dialog box.
strTheseChecked = "The following checkboxes were checked:\r\n";

-- Check if the first checkbox was checked.
if (check01) then
    -- Get the properties of the first checkbox.
    tbCheck1 = DlgCheckBox.GetProperties(CTRL_CHECK_BOX_01);

    -- Add the variable name of the checkbox and its label it to the dialog string.
    strTheseChecked = String.Concat(strTheseChecked, tbCheck1.Text.." - check01\r\n");
end

-- Check if the second checkbox was checked.
if (check02) then
    -- Get the properties of the second checkbox.
    tbCheck2 = DlgCheckBox.GetProperties(CTRL_CHECK_BOX_02);

    --- Add the variable name of the checkbox and its label it to the dialog string.
    strTheseChecked = String.Concat(strTheseChecked, tbCheck2.Text.." - check02\r\n");
end

-- Check if the third checkbox was checked.
if (check03) then
    -- Get the properties of the third checkbox.
    tbCheck3 = DlgCheckBox.GetProperties(CTRL_CHECK_BOX_03);

    --- Add the variable name of the checkbox and its label it to the dialog string.
    strTheseChecked = String.Concat(strTheseChecked, tbCheck3.Text.." - check03\r\n");
end

-- Check if the fourth checkbox was checked.
if (check04) then
    -- Get the properties of the fourth checkbox.
    tbCheck4 = DlgCheckBox.GetProperties(CTRL_CHECK_BOX_04);

    --- Add the variable name of the checkbox and its label it to the dialog string.
    strTheseChecked = String.Concat(strTheseChecked, tbCheck4.Text.." - check03\r\n");
end

-- Display a dialog containing the states of each checkbox.
-- Check if at least one of the checkboxes are checked.
if (check01 or check02 or check03 or check04) then
    Dialog.Message("Checkboxes", strTheseChecked, MB_OK, MB_ICONINFORMATION, MB_DEFBUTTON1);
else
    -- No checkboxes were checked.
    Dialog.Message("Checkboxes", "No checkboxes were checked.", MB_OK, MB_ICONINFORMATION, MB_DEFBUTTON1);
end

This action script demonstrates how to check which of the four default check boxes were checked. This is accomplished by checking the state of the Lua variable that is assigned to each checkbox. These variables contain a Boolean value of either true or false. If a check box has been checked, its label is retrieved and added to a string so that it can be shown at the end.

Example 2

-- Check if the first check box was checked.
-- If it is checked, open a readme text file.
if (check01) then
    -- The first check box was checked. Open a readme text file.
    File.Open(SessionVar.Expand("%SourceFolder%").."\\readme.txt");
end

-- Check if the second checkbox was checked.
-- If it is checked, run the application.
if (check02) then
    -- The second check box was checked. Run the application.
    File.Run(SessionVar.Expand("%SourceFolder%").."\\MyProg.exe", "", "", SW_SHOWNORMAL, false);
end

This action script example illustrates how you can optionally open a readme file and launch your application if this screen was added at the end of your update. The above script can be added to a default Check Boxes screen when only the first two check boxes are present.