Dialog.Message

number Dialog.Message ( 

string Title,

string Text,

number Type = MB_OK,

number Icon = MB_ICONINFORMATION,

number DefaultButton = MB_DEFBUTTON1 )

Example 1

btn = Dialog.Message("Error!", "Unable to proceed.", MB_RETRYCANCEL);

Alerts the user that an error occurred and asks them if they want to retry or cancel. Depending on which button they click on, the value represented by the constant IDRETRY or IDCANCEL will be stored in the btn variable.

Example 2

Dialog.Message("Important", "The rain in Spain falls mainly on the plain.", MB_OK, MB_ICONEXCLAMATION);

Gives the user an important (okay, maybe not so important :) message, and waits for them to click the OK button before continuing.

Note: This example doesn't store the return value in a variable because it will always be IDOK. In cases like these, we say that the return value is ignored.

Example 3

ishappy = Dialog.Message("Prying Question #023", "Are you happy?", MB_YESNO, MB_ICONQUESTION, MB_DEFBUTTON1);

Asks the user if they're happy, with Yes and No buttons on the dialog. Since we're asking a question, the MB_ICONQUESTION icon is specified. To encourage happiness in our users, the Yes button is selected by default. The user's response is stored in the variable ishappy as one of two constants, IDYES or IDNO.

Example 4

-- Gets the path to the user's My Documents folder.
my_docs_path = Shell.GetFolder(SHF_MYDOCUMENTS);

-- Check to see if the My Documents folder detection was successful.
if (Application.GetLastError() == 0)then

    -- Search the user's My Documents folder for the file "Data.ini".
    search_results = File.Find(my_docs_path, "Data.ini", true, false, nil);

    --Check to see if an error occurred during the search. If it did, display the error message.
    error = Application.GetLastError();
    if error ~= 0 then
        Dialog.Message("Error",_tblErrorMessages[error]);
    else

        -- If no files were found, notify the user.
        if (search_results == nil) then
            Dialog.Message("Notice", "Data.ini was not found in your My Documents folder.");

        -- If files were found, display a dialog containing a list of their locations.
        -- Also ask for deletion confirmation.
        else
            message = "Data.ini was found in the following location(s). Click OK to delete the file(s):\r\n\r\n";
            for index, path in search_results do
                message = String.Concat(message, path.."\r\n");
            end
            proceed = Dialog.Message("File Search Results", message, MB_OKCANCEL, MB_ICONQUESTION, MB_DEFBUTTON1);

            -- If the user clicked OK, delete all of the files found.
            if proceed == IDOK then

                -- Delete each file found in the search.
                for index, path in search_results do
                    File.Delete(path, false, false, false, nil);

                    -- Check to see if any errors occurred during the deletion.
                    if (Application.GetLastError() ~= 0) then
                        Dialog.Message("Error", "The file located at: "..path.." could not be deleted.");
                    end
                end
            end
        end
    end
end

This example uses the File.Find action to search for all copies of a particular INI file in the user's My Documents folder. If the file is found in more than one location, the user is presented with the list and asked if they wish to delete them using a Dialog.Message action. If they agree, each copy is deleted using the File.Delete action.

See also:  Related Actions