#CONTEXT (set template code generation context) 

Top  Previous  Next

 

#CONTEXT( section [, instance ] )

  statements

#ENDCONTEXT

#CONTEXT

Sets the code generation context to emulate generating the named section.

section

One of the following valid symbols: %Application, %Procedure, %Module, or %Program.

instance

A symbol containing a valid instance number of a code, control ,or extension template used in the named section.

statements

Template language code.

#ENDCONTEXT

Terminates the context change.

The #CONTEXT structure specifies template code that executes as if the source code for the named section were being generated. Once the context has been set, all the prompt symbols , declared symbols, and embeds in the named section are in scope and available for use in the #CONTEXT statements. If an instance is specified, the prompts for the corresponding component are brought into scope. #CONTEXT is valid for use anywhere in template code.

The key to understanding the use of the #CONTEXT structure is "as if the source code for the named section were being generated." This statement means that the statements are evaluated as if #GENERATE were executing. For example, a #EMBED statement within a #CONTEXT structure does not name a new embed point but instead, generates the contents of the named embed point.

Example:

#CODE(StealSomeCode,'Preparing to Process the Window Code Stealer')

#PROMPT('Procedure Name',FROM(%Procedure)),%ProcToStealFrom,REQ

#FIX(%Procedure,%ProcToStealFrom)

#CONTEXT(%Procedure)

#EMBED(%BeforeAccept,'Preparing to Process the Window')

#ENDCONTEXT

 

See Also:     #CODE , #CONTROL , #EXTENSION