News:

  • June 25, 2026, 03:29:15 PM

Login with username, password and session length

Author Topic: Exit vs Halt  (Read 9748 times)

mhw

  • Hero Member
  • *****
  • Posts: 250
Exit vs Halt
« on: August 06, 2014, 09:54:50 AM »
I am sure that this has been covered somewhere on this forum but I am unable to find it. Will the rungs below an exit or a halt execute for the remainder of the scan?

plcnut

  • Hero Member
  • *****
  • Posts: 814
    • premiersi.com
Re: Exit vs Halt
« Reply #1 on: August 06, 2014, 09:56:51 AM »
EXIT and HALT will execute immediately. No more rungs in the target program/task will be processed.
Circumstances don't determine who we are, they only reveal it.

~Jason Wolthuis
Premier Systems Integration, LLC
http://premiersi.com

mhw

  • Hero Member
  • *****
  • Posts: 250
Re: Exit vs Halt
« Reply #2 on: August 06, 2014, 10:09:58 AM »
Thanks. What is the difference other than exit works only on the program that it is in?

franji1

  • Bit Weenie
  • Host Moderator
  • Hero Member
  • *****
  • Posts: 3827
    • Host Engineering
Re: Exit vs Halt
« Reply #3 on: August 06, 2014, 10:40:53 AM »
EXIT is the "normal" termination of PROGRAM by the code-block itself.  This is great when performing a "long" operation, such as generating a report, running through a single "batch" of a specific "recipe".  The GenerateReport or RunBatch PROGRAM code-block knows best when it is done, not $Main.  $Main can monitor RunBatch.Done to know when the batch is done.  $Main typically would not HALT RunBatch cuz RunBatch knows best when it is done (however, see below).

HALT is a "supervisory" termination of code-block, typically for "abnormal" terminations.  Say you needed to abort the currently running batch, $Main could HALT RunBatch.

HALT could be used for "normal" termination of a code block by its "supervisory" code-block (typically $Main, where the code-block's RUN instruction also exists; but actually any code-block can HALT any other code-block, but nobody can HALT $Main, not even $Main).

Rule of thumb: prefer EXIT for "normal" (self) termination over HALT.  But, you can use HALT for "supervisory" termination.
« Last Edit: August 06, 2014, 10:42:26 AM by franji1 »

plcnut

  • Hero Member
  • *****
  • Posts: 814
    • premiersi.com
Re: Exit vs Halt
« Reply #4 on: August 06, 2014, 10:41:08 AM »
I believe the only difference is that EXIT is used internal to a program block, and HALT is used externally in a supervisory code block.

EDIT: ...See franji1's post...
« Last Edit: August 06, 2014, 10:42:58 AM by plcnut »
Circumstances don't determine who we are, they only reveal it.

~Jason Wolthuis
Premier Systems Integration, LLC
http://premiersi.com

BobO

  • Host Moderator
  • Hero Member
  • *****
  • Posts: 6161
  • Yes Pinky, Do-more will control the world!
Re: Exit vs Halt
« Reply #5 on: August 06, 2014, 01:36:21 PM »
As has been suggested already, there really isn't much difference between HALT and EXIT in practice...other than one takes a parameter and can be called externally and the other doesn't and can't. And as has been said, the intention is internal vs external. Probably the best way to think about it is EXIT is like closing a Windows program by hitting the 'X' or using the 'Exit' menu, whereas HALT is like killing the process from Task Manager.

When we originally conceived the two instructions, I think there was a bit more difference in them, and as the controller was developed the internal implementations became more similar. For purposes of program clarity, I would use EXIT as the normal and preferred termination of a Program Block and HALT as the Task/Program kill.
"It has recently come to our attention that users spend 95% of their time using 5% of the available features. That might be relevant." -BobO