Background:
Running a dialog box with a checkbox to be ticked.
Looking for a handle to reflect checkbox status (Unticked(default) or Ticked)
What I thought should work is not.
What am I doing wrong?
I am using a Detatched dialog box having created a dialog box using the Dialog Editor
For anyone inclined I think this DCF file can be imported as a button and should run complete with dialog box and code:
2023-06-16 002 CheckBox.dcf (14.3 KB)
Fault Description:
I am trying to extract a handle to tell me if the checkbox has been ticked or not.
I run the script twice and get the unexpected results below.
Take1 - I am expecting a 0 or boolian negative to be returned.
The code I have to capture this return is not executed at all:
Take2 - I am expecting 1 or boolian positive to be returned.
The code at least in this case is executed but runs the default case statement.
Debug 002000-400-030 says my object has been returned undefined:
I think the Control object .value property is in play:
function OnClick(clickData)
{
DOpus.ClearOutput;
DOpus.Output("001000 Start CheckBox Troubleshoot");
// 001000
// 001000 Start
// 001000
//
var Dlg = DOpus.Dlg;
Dlg.window = clickData.func.sourcetab; // Parent Window of the dialog
Dlg.template = "Dialog_1"; // GUI Script Dialog defined in Resources
Dlg.detach = true;
Dlg.Show();
// 002000
// 002000 Msg Loop
// 002000
Dlg_Control_Check_Box_Folder = Dlg.Control("Check_Box_Folder") // Returns a Control object
i = 0;
DOpus.Output("002000 Msg Loop ENTER");
while (true)
{
// DOpus.Output(" 000 Iteration ======================================================"+ i);
var Dlg_Msg = Dlg.GetMsg();
if (!Dlg_Msg.result) break;
//
switch(Dlg_Msg.Control)
{
case "Check_Box_Folder":
{
switch(Dlg_Control_Check_Box_Folder.value.name)
{
case 0:
// Checbox is UNCHECKED
DOpus.Output(" 002000-400-010 Check_Box_Folder = "+ Dlg_Control_Check_Box_Folder.value.name);
DOpus.Output(" 002000-400-011 Unchecked");
break;
case 1:
// Checbox is CHECKED
DOpus.Output(" 002000-400-020 Check_Box_Folder = "+ Dlg_Control_Check_Box_Folder.value.name);
DOpus.Output(" 002000-400-021 Checked");
break;
default:
// Checbox not sure
DOpus.Output(" 002000-400-030 Check_Box_Folder = "+ Dlg_Control_Check_Box_Folder.value.name);
DOpus.Output(" 002000-400-031 Unsure");
break;
}
break;
DOpus.Output(" 002000-100 case ComboB2 EXIT = "+ Dlg_Control_ComboB2.value.name);
}
default:
// code block
DOpus.Output(" 200d Default we have a problem"); // DailogListItem
}
if (Dlg_Msg.event == "focus")
{
// We have changed controls
// We which control is in focus
//
DOpus.Output(" 002000-150 Dlg_Msg_Event = " + Dlg_Msg.event);
DOpus.Output(" 002000-170 Dlg_Msg.Control = " + Dlg_Msg.Control);
//
// Populate ComboB2
//
}
}
// 002200
// 002200 Exit Loop
// 002200
DOpus.Output("002200 Dailog Box Loop EXIT");
DOpus.Output("002200 Dailog Box Loop EXIT");
DOpus.Output("002200-010 Return code = " + Dlg.result + " 0=CANCEL, 1=Ok" + "<<< Dialog Closed");
// DOpus.Output(" 020 Destination_Alias never set at this point = "+ Destination_Alias);
//
DOpus.Output("003000 Process Dialog box RETURN START");
DOpus.Output("003000 Process Dialog box RETURN START");
DOpus.Output("003000 Process Dialog box RETURN START");
if (Dlg.result == 0)
{
// CANCEL Button so do nothing
}
else
{
//
// Ok Button Pressed
// Assign Destination Alias if not already set above.
// Maybe they should all move here
// 2023-03-26 Yes move ALL assignmetns here. Above processing DB is too iterative
//
}
// 003000
// 003000 Summary
// 003000
DOpus.Output(" 003100 Summary");
DOpus.Output(" 003100-280 Dlg_Control_Check_Box_Folder.value.name = "+ Dlg_Control_Check_Box_Folder.value.name);
//
// 004000
DOpus.Output("003990 Process Dialog box RETURN END");
DOpus.Output("");
}