Programming with Castalia : Refactoring : Surround With...
Previous  Top  Next

A section of code should be in a control block.

Surround the section with the appropriate block.

To surround a block of code with an appropriate control structure:

1.Highlight the block of code.  
2.Right-click the block of code and choose Refactoring from the editor context menu, or choose Refactoring from the Edit menu.  
3.Select Surround With...  
4.Select the appropriate control block.  
5.Your code will automatically be surrounded by the control block that you selected.  

The following control block types are automatically generated by Castalia's Surround With refactoring:

·If  
·Else  
·For  
·While  
·Repeat..Until  
·Try..Except  
·Try..Finally  

Note: This action can be undone, but due to anomalies in Delphi's undo stack implementation, you will need to undo twice in order to undo the action.

See also: Refactoring Overview