Host Engineering Forum
General Category => Do-more CPUs and Do-more Designer Software => Topic started by: mhw 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?
-
EXIT and HALT will execute immediately. No more rungs in the target program/task will be processed.
-
Thanks. What is the difference other than exit works only on the program that it is in?
-
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.
-
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...
-
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.