Jul 1 2004 |
[ il2 | icmbranching | ij ] ICM contains a complete set of control statements to allow looping, jumping and conditional branching.
For-loop for <i_index> = <i_from> , <i_to> [, <i_increment> ] ... ... endfor While-loop while( <logical_expression> ) ... ... endwhile Examples: for i = 1, 9 print "ICM-shell proudly announces that i=" i endfor for i = 1, 4 print "ICM-shell proudly announces that i=" i for j = 1, 3 print "ICM-shell proudly announces that nesting is possible and j=" j endfor endfor read object "crn" for i = 1, Nof(a_/*) # Nof(a_/*) means 'the number of residues' print Label(a_/$i) endfor i = -2 while (i != 4) i = i+1 print i endwhile while(yes) print "endless loop, please wait 8-)" endwhileAny number of nested loops may be used.
if if ( <logical_expression> ) <command> if-then-endif if ( <logical_expression> ) then ... ... endif if-then-elseif-..else-endif if( <logical_expression> ) then ... else ... endifor if ( <logical_expression> ) then ... elseif ( <logical_expression> ) then ... elseif ( <logical_expression> ) then ... else ... endifNote: end if or else if (instead of endif or elseif ) are not accepted by ICM-shell. Examples: JohnnySaid = "The gloves didn't fit" if ( JohnnySaid == "The gloves didn't fit" ) print "You must acquit" # grade = "bad" if (grade == "excellent") then print "It's great!" elseif (grade == "good") then print "It's good!" elseif (grade == "bad") then print "It's not so bad!" # do not be harsh on your kids endif
break <for-loop> or <while-loop> ... if ( <logical expression> ) break ... <end of loop> continue <for-loop> or <while-loop> ... if ( <logical expression> ) continue ... <end of loop> goto ... if ( <logical expression> ) goto <label> ... ... <label>: ... Examples: for i = 1, 6 print "currently i=", i, "and it will be increased at the next step" if (i == 3) then print "... but at this point we should stop it, sorry..." break endif endfor print "end of the loop demonstrating *break*, bye" for i = 1, 6 if (i == 3) then print "... let us skip over step 3 and continue looping" continue endif print "currently i=", i, "and it will be increased at the next step" endfor print "end of the loop demonstrating *continue*, bye" for i = 1, 5 if (i == 3) then print "... but at this point we decided to skip 3-rd step, sorry..." goto A endif print "currently i=", i, "and it will be increased at the next step" A: print " " endfor print "end of the loop demonstrating 'goto', bye" Note: go to (instead of goto) is not accepted by the ICM-shell. Any combination of alphanumeric characters beginning with a letter (upper or lower case) may serve as a label. Also keep in mind that goto can jump only forward; the backward goto is not allowed.
|
Copyright© 1989-2004, Molsoft,LLC - All Rights Reserved. |
This document contains proprietary and confidential information of
Molsoft, LLC. The content of this document may not be disclosed to third parties, copied or duplicated in any form, in whole or in part, without the prior written permission from Molsoft, LLC. |