Navigation: Templates > Template Language Reference > Complete Alpha Listing >====== #RELEASE (commit conditional source generation) ====== | |
#RELEASE
The #RELEASE enables source generation in a #SUSPEND section. This allows empty unnecessary “boiler-plate” code to be easily removed from the generated source. The code in a #SUSPEND section is generated only when a #RELEASE statement is encountered.
#SUSPEND sections may be nested within each other to as many levels as necessary. A #RELEASE encountered in an inner nested section commits source generation for all the outer nested levels in which it is contained, also.
A #EMBED that contains source to generate performs an implied #RELEASE. Any generated source output also performs an implied #RELEASE. Therefore, an explicit #RELEASE statement is not always necessary. The #? statement defines an individual conditional source line that does not perform the implied #RELEASE.
Example:
ACCEPT
#SUSPEND #!Begin suspended generation
#?CASE SELECTED()
#FOR(%ScreenField)
#SUSPEND
#?OF %ScreenField
#EMBED(%ScreenSetups,'Control selected code'),%ScreenField
#!Implied #RELEASE from the #EMBED of both nested sections
#RESUME
#?END
#RESUME #!End suspended generation
#SUSPEND #!Begin suspended generation
#?CASE EVENT()
#SUSPEND
#?OF EVENT:AlertKey
#SUSPEND
#?CASE KEYCODE()
#FOR %HotKey
#RELEASE #!Explicit #RELEASE
#?OF %HotKey
#EMBED(%HotKeyProc,'Hot Key code'),%HotKey
#ENDFOR
#?END
#RESUME
#?END
#RESUME #!End suspended generation
END
IF scField
scField{Prop:Background} = scColor
#!
#! test for style
#SUSPEND
#?scField{Prop:FontStyle} = scStyle
#IF(%SelectedStyle = %True)
#RELEASE
#ENDIF
#RESUME
#!
#! test for caret
#SUSPEND
#?HIDE(LocSelectedCaret)
#IF(%SelectedCaret = %True)
#RELEASE
#ENDIF
#RESUME
#!
END