User Tools

Site Tools


section_define_code_section_.htm
Navigation:  Templates > Template Language Reference > Complete Alpha Listing >====== #SECTION (define code section) C6H0068.jpg ====== Previous pageReturn to chapter overviewNext page

#SECTION (<;name>)

statements

#ENDSECTION

blk2blue.jpg

#SECTION Marks the beginning of a section of generated code.
name A string that identifies the name of the section.
statements Any template or target language statements.
#ENDSECTION Terminates the #SECTION.

The #SECTION structure defines a contiguous section of generated code so that the position of embedded source code is correctly patched up for error positions in the resulting generated code. #APPEND with the SECTION attribute performs the patch.

Named Sections

A name parameter has been added to the #SECTION statement. This parameter can then be referenced by the SECTION attribute of the #APPEND statement as follows:

 

#SECTION('First Section')

#ENDSECTION

#SECTION('Another Section')

#ENDSECTION

 

#APPEND('FileName'),SECTION('Another Section')

#APPEND('FileName'),SECTION('First Section')

The first #APPEND statement with the SECTION attribute uses the last defined section in source order. The next #APPEND statement is used for the previous section, etc. A named #SECTION can be used with the #APPEND statement only once. If the SECTION attribute of the #APPEND statement has a parameter defined, for example:

#APPEND('somefile'),SECTION('somesection')

The template source generator will append the #SECTION defined with the name 'somesection' and then removes it from the list of sections. If the SECTION attribute has no parameter

#APPEND('somefile'),SECTION

The generator uses the most recently declared #SECTION not removed yet from the top of sections stack and then pops it (but does not destroy).

In summary, to avoid any logic problems, all #APPEND statements should not mix usage of named and unnamed sections.

Other Example:

#CREATE(%Temp)                               #!Create temp module file

#SECTION

#EMBED(%MyEmbed,@s30)

#ENDSECTION

#CLOSE

#CREATE('target.clw')

CODE

#APPEND(%Temp),SECTION                       #!Correctly patch position of #EMBED

#CLOSE

See Also:     #APPEND

section_define_code_section_.htm.txt · Last modified: 2021/04/15 15:57 by 127.0.0.1