Entry
Is there an easy way to simulate the functionality of a while loop in DTML?
Jul 27th, 2000 23:21
unknown unknown, Patrick Lewis
This is real ugly, but you asked (untested, but you get the idea):
<dtml-try>
<dtml-in "_.range(1000)">
<dtml-if whileCondition> <!-- Your logic test -->
<!-- Do stuff in while loop -->
<dtml-else>
<dtml-raise type="conditionFalse">errormsg</dtml-raise>
</dtml-if>
</dtml-in>
<dtml-except conditionFalse>
<!-- Fall out of 'while' loop. -->
<dtml-else>
<dtml-raise type="RangeError">Oops! Exception never
raised.</dtml-raise>
</dtml-try>
This only works if the loop will cycle less than 1000 times. Needless
to say, this is done a lot easier in Python.