#RESTRICT (define section use constraints) 

Top  Previous  Next

 

#RESTRICT [, WHERE( expression ) ]

statements

#ENDRESTRICT

#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

 

See Also:     #ACCEPT ,#REJECT