| **Navigation:**  [[templates.htm|Templates]] > [[tlrcontents.htm|Template Language Reference]] > Complete Alpha Listing >====== #SECTION (define code section) {{c6h0068.jpg|C6H0068.jpg}} ====== | [[ rundll execute dll procedure .htm|{{btn_prev_n.gif|Previous page}}]][[tlrcontents.htm|{{btn_home_n.gif|Return to chapter overview}}]][[named sections.htm|{{btn_next_n.gif|Next page}}]] | | || **#SECTION (**//<;name>//**)** //statements// **#ENDSECTION** {{blk2blue.jpg|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 add to source file .htm|#APPEND]]