• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers

How to bail out of a nested function?

Community Expert ,
Jan 12, 2019 Jan 12, 2019

Copy link to clipboard


Dear all,

In the good old days of 'large computers' I had an Exit routine which allowed me to terminate a Fortran program and return to the OS without the need to maintain a return chain to the top of the program structure.

I'm really missing such a thing in ESTK (or elsewhere in JS). Condition in this script can be entered only if the script has been started in ESTK - not via the menu in FM (menu appears only if document is active). So the situation may not be that dramatically - because a person doing so must be at least (as I am) somewhat familiar with ESTK and know how to proceed. Nevertheless I'm looking out for principle escape function.

Throwing an error

function IniFMGraph () {

var oDoc = app.ActiveDoc;

  if (!oDoc.ObjectValid()) {  // may be just the Welcome screen, but no FM document

    alert ("IniFMGraph\nNo active document!\nCan not place a diagram.", "FMgraph [DDD]", false);

    throw new Error ("Script stopped");



opens ESTK at that place and uses the status line for a message.

Is there a 'catch' method for the upper-most function (main) - or even a method to leave the script without further cluttering the screen?

I do not have a deep enough knowledge of event handlers...

Any ideas?







Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
no replies

Have something to add?

Join the conversation