Previous Topic

Next Topic

Book Contents

Algorithms - pseudocode

This pseudocode provides a programmatic explanation of the requirements described in Writing a client program to evaluate ItemData elements.

IsItemComplete(item)

{

if (item only has calculated controls)

return true;

foreach(childControl of item)

{

bool completeControlFound = false;

if (IsControlIncomplete(childControl, completeControlFound))

return false;

}

return completeControlFound;

}

IsControlIncomplete(control, completeControlFound)

{

if (control is a calculated control)

return false;

if (control is a control type that doesn’t have children (text,

pulldown, etc.))

{

if (control has value)

{

completeControlFound = true;

}

return false;

}

if (control is a radio group)

{

if (it doesn’t have a selection)

return false;

selectedOption = the radio group’s selected option;

if (selectedOption doesn’t have any child controls OR

it has exactly one child that is a calculated control)

{

completeControlFound = true;

return false;

}

foreach (child of the selected option)

{

if (IsChildControlIncomplete(child))

return true;

}

completeControlFound = true;

return false;

}

if (control is a checkbox option)

{

if (it isn't checked)

return false;

if (it has exactly one child that is a calculated control)

{

completeControlFound = true;

return false;

}

foreach (child of the checkbox option)

{

if (IsChildControlIncomplete(child))

return true;

}

completeControlFound = true;

return false;

}

}

IsChildControlIncomplete(control)

{

if (control is a calculated control)

return false;

if (control is a control type that doesn't have children (text, pulldown, etc.))

Does the control have a value?

if (yes)

return false;

if (no)

return true;

if (control is a radio group)

{

if (it doesn’t have a selection)

return true;

selectedOption = the radio group’s selected option;

if (selectedOption doesn’t have any child controls OR

it has exactly one child that is a calculated control)

return false;

foreach (child of the selected option)

{

if (IsChildControlIncomplete(child))

return true;

}

return false;

}

if (control is a checkbox option)

{

if (it isn't checked)

return true;

if (it has exactly one child that is a calculated control)

return false;

foreach (child of the checkbox option)

{

if (IsChildControlIncomplete(child))

return true;

}

return false;

}

}

Send Feedback