I miss the FMP Halt script step!
I’ve read in these posts that the Halt script step will be included in future releases for compatibility, but is not recommended.
Why not?
I frequently have nested methods that I would like to end far into the sequence. What techniques can be used to elegantly bail out at the end of the nth nesting level?
Has the Halt step been included? If not, when/if it is implemented, will it function similar to FMP?
I’m sure there’s an answer to any kind of halt you wish.
return; definitely halts your script
But there are also more subtle ways like break; and continue;
Check out the attachment for examples.
Also check out this very good (and downloadable) javascript reference
http://devedge.netscape.com/library/man … reference/
OR
http://devedge.netscape.com/library/man … 1.5/guide/
(more extensive examples)
If you need help on a specific situation let me know.
maarten:
I’m sure there’s an answer to any kind of halt you wish.
I put an OnHide method that checks if an invoice has been linked to an offer.
My purpose is that, if the user clicks on the controller meaning to move to another form, the check method is launched (and this is working fine) AND, if the the Invoice is not linked, Servoy has to stop the other method (located on the controller) and stay on the Invoices form.
I thought to add a marker on a global (something like if the invoice is not linked, set gPass to “1”), then add some code in the navigation scripts that first checks if the global gPass is set to 1.
But I’m asking if there’s a cleaner solution because I have a lot of methods on the controller and I’d prefer not to edit all of them.
Without knowing the details of your navigation structure,
would this (pseudo)code work for you?
(no need to create a global flag)
navigationScript
if( onHideScript() == 1 )//this triggers the onHide script and returns 1 if true
{
//continue
}
onHideScript
//check stuff
if(OK)
{
return 1;
}
else
{
return 0
}
maarten:
Without knowing the details of your navigation structure,
would this (pseudo)code work for you?
(no need to create a global flag)navigationScript
if( onHideScript() == 1 )//this triggers the onHide script and returns 1 if true
{
//continue
}onHideScript
//check stuff
if(OK)
{
return 1;
}
else
{
return 0
}
It’s certainly a better solution, but I still have to add it to all navigation scripts present in the controller. I tried to add to a global method (ResetNavigator) used by all navigation scripts, but this way, only the ResetNavigator method is stopped, not the navigation script itself.
The structure of my navigation scripts is something like:
globals.Reset_Navigator(); //sets all fonts to verdana 10 black
application.setWindowSize(1000, 770)
application.setWindowLocation(0, 0)
forms.navigator.elements.button_offers.fgcolor = '#0000cc'
forms.navigator.elements.button_offers.setFont('Verdana,1,14');
forms.offers.controller.show()
Do you think it’s possible to add some code to Reset_navigator that stops itself and the script in which it’s contained?
hmm… then you would end up doing something like this:
(please test before implementing
//onHideScript
//check stuff
if(OK)
{
return 1;
}
else
{
return 0
}
//globals.Reset_Navigator()
your current code
if( forms.myInvoiceForm.onHideScript() == 1 )
{
return 1;
}
//you might also have to check if currentcontroller == "myInvoiceForm"
//otherwise your nav script could get blocked in all other forms.
//navigationscript
if(globalsReset_Navigator() != 1)
{
return; //this stops your navigation script
}
application.setWindowSize(1000, 770)
application.setWindowLocation(0, 0)
forms.navigator.elements.button_offers.fgcolor = '#0000cc'
forms.navigator.elements.button_offers.setFont('Verdana,1,14');
forms.offers.controller.show()
regarding the last script:
Do Ctrl+F in method editor to globally replace (on navigation form level)
globals.Reset_Navigator();
with…
if(globalsReset_Navigator() != 1)
{
return; //this stops your navigation script
}
maarten:
hmm… then you would end up doing something like this:
(please test before implementing
Thanks, maarten: I’ll check it this afternoon