Any Script can get called anytime by anyone

Having a number of checks at the top of Scripts is a good idea...

Because these checks will be performed at the top of many Scripts, I would (when possible) create a separate Script to be called as a "sub-routine" for each check. This "sub-routine" can then be called using a single line. (A well chosen "sub-routine" Script Name can take the place of a comment.)

Whether these "sub-routine" Scripts Halt or Exit is a subject of debate.
Halt Script can get the job done using fewer lines in the calling Script.
Sometime you need to use Exit Script.
A time and a place for each, in my opinion.

Script Name: _Val current user has privilege_P // called with a Parameter (_P)

Script Name: _Val Check for some platforms_P

Script Name: _Val Move/Go to right layout if needed_P // this one is tricky as you introduce Layout indirection unless you are reading and passing along the LayoutID (and converting it back):

Script Name:_Val window FoundCount > 0 or Halt

More here

reply 1/n