LATCH - Maintain value when input is removed Latch.gif (11316 bytes)

The format of the LATCH External function is:

         LATCH( Input?, Save@)          

The function provides a way of storing transient information throughout a cycle. The LATCH function requires some other active device, such as a FORNEST or WHILE (or even the user), to control for how long the transient information is kept.
Some models have transient information which needs to be stored for use throughout a cycle. The SHUTTER function carries out a test and then destroys the information which formed the basis of that test. The information may need to be saved for other use in the same cycle.

The LATCH function will obtain and store information. When its output is searched, it first searches on the Save@ pin and then on its input. The information at its input is copied into the function and can only be killed by a change of state on the Save@ pin, which will usually be connected in some way to the Run@ pin on a WHILE function.

The LATCH function is simpler in operation than the GATE function. It does not have the Initialise@ facility, nor can it handle lists (an exception is a list of non-transient objects). For complex information storage, use the GATE function.