The <return> step has one attribute value of type String. This value is the value to return. If no value is specified, the block stops execution without returning a value.
The following example shows <return> steps in <try> and <finally> blocks. The value b will be returned (as in Java).
<try> <block> <return value="a" </block> <catch/> <finally> <return value="b"> </finally> </try> |
The following is an example of the <return> step used conditionally (line numbers were added for emphasis). If var1 is true, then the <return> step at line 5 would skip the remainder of the steps in the block. Lines 8 and 9 would not be executed at all. If var1 is not true, then the <return> step at line 9 would be the last step executed in the block.
1. <control name = "blah" returns="true"> 2. <varList> 3. <var name="var1" default="val1"/> 4. <var name="var2" default="val2"/> 5. </varList> 6. <if> 7. <condition><istrue value=":[var1]"/></condition> 8. <then> 9. <return value=":[var2]"> 10. </then> 11. </if> 12. <assign varName="var2" value="new value"/> 13. <return value=":[var2]"/> 14.</control> |
In contrast, the following example shows a conditionally used <return> step within a <try> block. Regardless of whether or not var1 is true, line 15 will always be the last line executed.
1. <control name="blah" returns="true"> 2. <varList> 3. <var name="var1" default="val1"/> 4. <var name="var2" default="val2"/> 5. </varList> 6. <try> 7. <block> 8. <if> 9. <condition><istrue value=":[var1]"/></condition> 10. <then> 11. <return value=":[var2]"> 12. </then> 13. </if> 14. <assign varName="var2" value="new value"/> 15. <return value=":[var2]"/> 16. </block> 17. <catch/> 18. <finally> 19. <pause delaySecs="5"/> 20. </finally> 21. </try> 22.</control> |
The following example shows a <return> step occurring within the <SimpleSteps> of an inlineSubplan or execSubplan body. Control is returned to the next step in the set of steps that call the inlineSubplan or execSubplan. The next step after the <return> step at line 4 is line 7.
1. <complexSteps> 2. <inlineSubplan> 3. <simpleSteps> 4. <return/> 5. </simpleSteps> 6. </inlineSubplan> 7. <inlineSubplan> 8. <simpleSteps> 9. <pause delaySecs="1"/> 10. </simpleSteps> 11. </inlineSubplan> 12.</complexSteps> |