Return Object

The return object is an object that may be returned by any ssCore command. Synchronous commands will return this object immediately and asynchronous commands will return this object as the first argument of the callback function.

The return object will always contain two properties: success and Error. It will also contain one property for each of the output parameters listed for the command. Any input parameters specified in the parameters object will also be returned on the return object.

success - is a boolean value that indicates that the command completed successfully or not.

Error - the error return object.

Here are two examples of executing an ssCore command where data is returned on the return object. The first example uses the synchronous command method. The second example uses the asynchronous command method. Both examples display a message box to the user and act on the response the user gives. If the command fails a textfield is populated with an error message containing the description of the error.

Example 1: a synchronous call that receives the return object immediately

ssDefaults.synchronousCommands = true;

var return_obj = ssCore.App.showMsgBox({prompt:"Delete the selected file?", icon:"question", buttons:"YESNO"});

if (return_obj.success)
{
    if (return_obj.result == "YES")
    {
        deleteFile();
    }
}
else
{
    debugTextField_txt.text = "ERROR: "+return_obj.Error.description";
}

Example 2: an asynchronous call that receives the return object as an argument of a callback function

ssCore.App.showMsgBox({prompt:"Delete the selected file?", icon:"question", buttons:"YESNO"},{callback:"answer", scope:this});

function answer(return_obj,callback_obj,error_obj)
{
    if (return_obj.success)
    {
        if (return_obj.result == "YES")
        {
            deleteFile();
        }
    }
    else
    {
        debugTextField_txt.text = "ERROR: "+return_obj.Error.description";
    }
}

In both of these examples we are accessing a property of the return object called result. If you look at the definition for ssCore.App.showMsgBox, result is listed as the only output parameter. If there had been more than one output parameter, a property would have been created and populated on the return object for each one.