Hi,
I have been using dynamic containers to flip through a series of compound profiles and registering a progression decision...the setup is much like the update XY plot via dynamic containers example. My problem arises when I come to the last compound...it goes to read the data, but of course there is none remaining so it just crashes out. Is there a way to end the looping?
This is especially important for webports as the protocol must end for the output files to be displayed in a tab.
Thanks,
Eric

It depends on what your worker protocol looks like.
Assuming you have some component, like a reader, that's crashing out, you could try collapsing it into a subprotocol, and configuring the subprotocol to send all errors to the fail port. If you don't have an Error Handling tab visible, you can turn it on using View->Component Windows->Error Handling. Then select the subprotocol, go to that tab, and set "On General Error" to "Send Data out the Fail Port". You can then display some message when you reach the last data record.
If that approach doesn't work for you, can you supply some more information about how the worker protocol works?
Hope that helps,
Warren Hedley
Hi Warren,
Thanks for the reply. That is a handy work-around, however I think it won't work for my protocol (sorry for the vague details, I know it is hard to answer based on them) as the reading is being done in the protocol function, thus an error that is sent to a no-op, for example simply returns back to the main protocol.
To help, here is my main protocol:
The first group creates radio buttons (with the various cmpd progression decisions), the second group is the submit button, the third is the hidden field containing the compound counter, the fourth is the javascript, and the fifth is the protocol function and dynamic container. The javascript is listed below; it simply reads in the radiobutton selection and global compound counter, creates the name of the compound's data file to be read in (to produce the plots), bumps up the compound counter, and calls the protocol function that generates the new plots that are then placed in the dynamic container.
So, lets say that we have 5 compounds. The webport page has the radiobuttons, submit button and then the dynamic container that has the plots. When the user hits the submit button the radiobutton selection is recorded and the new plots are generated and displayed in the dynamic container. My question is: after the plots for the 5 compounds have been displayed and the user hits the submit button I would like the protocol to end so that the webport results page, containing the text file with the 5 compound's radiobutton selections, is displayed. As it stands, it tries to read in the 6's compound's datafile which results in an error and thus the webport results page is not displayed. Even with the work-around of sending the read error out the fail port, the main protocol is not killed.
How does one terminate the main protocol so that it is not stuck in an infinite loop?
Many thanks,
Eric
The javascript is set up as follows:
function getRadioValueRunProtocol ()
{
//Obtain the selected value of the radio button:
for (var i = 0; i < radioList.length; i++)
{
if (radioList[i].checked)
{
var DecisionVal = radioList[i].value;
}
}
//Pull in the global variables to be passed along:
var HiddenGlobalCntrField = document.getElementById('GlobalCmpdCntrID');
var GlobalCntrVal = parseFloat(HiddenGlobalCntrField.value) + 1;
var CmpdDataFNStart = '$(GlobalTempFileNameStart)';
var DecisionFN = '$(GlobalDecisionFile)';
var CntrString = GlobalCntrVal+'';
var CmpdDataFN = CmpdDataFNStart+'CompoundData.'+CntrString+'.csv';
//Increase the GlobalCmpdCntr by one:
HiddenGlobalCntrField.value = GlobalCntrVal;
updateMoleculeImage(GlobalCntrVal,DecisionVal,CmpdDataFN,DecisionFN);
}
Hi Eric,
Thanks for the explanation -- I now see what you're trying to do.
There are many solutions to the problem. The simplest is to have the crash handler output some JavaScript that submits the form. When your worker protocol detects that you've run out of data, simply output some JavaScript that submits the form in the parent report.
document.getElementById('formId').submit();
An alternative, if you think this would be too confusing for users and want them to know they've reach the end of the dataset, would be to add a second Submit button, with text like "Finished", a unique ID (e.g., "allDone"). Optionally, make it initially disabled by setting the HTML attribute disabled="disabled".
Then, as in my earlier post, look for the crash when you run out of data. If you're out of data, return a message like "All out of data. Click 'Finished' to continue ..." and include a JavaScript component and that enables the Finished button.
document.getElementById('allDone').removeAttribute("disabled");
You could also disable the first Submit button at that point. An improvement would be if you could switch the buttons on and off when you hit the last record.
Regards,
Warren Hedley
Hi Warren,
Thanks for the response. Just a clarifications (still getting a grasp on the terminology) and then I will give the first solution a go and then try to implement the second:
In your first solution, the worker protocol is the protocol that is called by the function protocol component, correct? If so, then the file reader tries to read in the data file for the 6th compound and gets an error. I set the error handling to "Send Data out the Fail Port" and connect a javascript component to the fail port. In the javascript component I simply put in document.getElementById('formId').submit();
What is the form that is submitted in this case; is this the results page and do I have to create the results page?
Thanks,
Eric
Yes, by worker protocol, I meant the one called by the Protocol Function.
It seems that the form elements (radio buttons, submit button, hidden field, etc.) should be piped into an Input Form component, probably placed after the Tile. The Input Form should run the "Final Report Protocol" and have id="formId" set in the HTML attributes. Using a form also lets you control where the final report is displayed.
Just make sure that in on your submit button that runs the protocol function, you call your protocol function and then return false, so that the form isn't submitted the first time you click on it. That is, the attribute should be onclick="getRadioValueRunProtocol(); return false;".
Hope that helps,
Warren Hedley