User Tools

Site Tools


restrict_define_section_use_constraints_.htm
Navigation:  Templates > Template Language Reference > Complete Alpha Listing >====== #RESTRICT (define section use constraints) C6H0068.jpg ====== Previous pageReturn to chapter overviewNext page

#RESTRICT [, WHERE( expression ) ]

statements

#ENDRESTRICT

blk2blue.jpg

#RESTRICT Specifies conditions where a Template Code Section (#CODE, #CONTROL, #EXTENSION, #PROCEDURE, #PROGRAM, or #MODULE) can be used.
WHERE The #RESTRICT statements are excuted only when the expression is true.
expression A logical expression to limit execution of the #RESTRICT statements.
statements Template language code to #ACCEPT or #REJECT use of the section which contains the #RESTRICT structure.
#ENDRESTRICT Terminates the #RESTRICT structure.

The #RESTRICT structure provides a mechanism to limit the availability of a Template Code Section (#CODE, #CONTROL, #EXTENSION, #PROCEDURE, #PROGRAM, or #MODULE) at application design time to only those points where the generated code would be appropriate. Any WHERE clause on the Template Code Section is evaluated first, before #RESTRICT.

The #ACCEPT statement may be used to explicitly declare the section as appropriate for use. An implicit #ACCEPT also occurs if the #RESTRICT statements execute without encountering a #REJECT statement. The #REJECT statement must be used to specifically exclude the section from use. Both the #ACCEPT and #REJECT statements immediately terminate processing of the #RESTRICT code.

Example:

#CODE(ChangeControlSize,'Change control size')
#RESTRICT
   #CASE(%ControlType)
   #OF('LIST')
   #OROF('BUTTON')
     #REJECT
   #ELSE
     #ACCEPT
   #ENDCASE
 #ENDRESTRICT
 #PROMPT('Control to change',CONTROL),%MyField,REQ
 #PROMPT('New Width',@n04),%NewWidth
 #PROMPT('New Height',@n04),%NewHeight
 %MyField{PROP:Width} = %NewWidth
 %MyField{PROP:Height} = %NewHeight
#CODE(ControlValueValidation,'Control Value Validation')
#RESTRICT
  #CASE(%ControlType)
  #OF('ENTRY')
  #OROF('SPIN')
  #OROF('COMBO')
    #CASE(%ControlEvent)
    #OF('Accepted')
    #OROF('Selected')
      #ACCEPT
    #ELSE
      #REJECT
    #ENDCASE
  #ELSE
    #REJECT
  #ENDCASE
#ENDRESTRICT
#DISPLAY('This Code Template is used to perform a control value')
#CONTROL(PauseButton,'Pause the Process'),WINDOW
#RESTRICT
  #IF ( UPPER(%ProcedureTemplate) = 'REPORT' OR UPPER(%ProcedureTemplate) = 'PROCESS' )
    #ACCEPT
  #ELSE
    #REJECT
  #ENDIF
#ENDRESTRICT
  #PROMPT('Pause Text',@S20),%PauseText,DEFAULT('Pause')
  #PROMPT('Restart Text',@S20),%RestartText,DEFAULT('Restart')

See Also:     #ACCEPT ,#REJECT

restrict_define_section_use_constraints_.htm.txt · Last modified: 2022/04/28 02:32 by carlbarnes