lib-case

Anyone familiar with "select...case" statements should be relatively at home with lib-case. Put the data item to be check at the top of the stack and then 'case'. Follow with a possible test for the data item followed by a when ... end (effectively structured like a if...then). Continue doing this for each possible case and if desired, include the optional default...end case (code to be executed if no matches are found). finish up the section with an 'endcase'.

<data> case
    <test> when <effect> end
    <test> when <effect> end
    <test> when <effect> end
    <test> when <effect> end
    default <otherwise> end
endcase

A "real world" example:
command @ case
    "firstcmd" strcmp not when handle-firstcmd end
    "secondcmd" strcmp not when handle-secondcmd end
    default handle-invalidcmd end
endcase


feaelin@kemenel.org
lib-case / Revised 2004 March 31 22:06 (Wednesday)
© 2004 Iain E. Davis

Green Web Hosting! This site hosted by DreamHost. Standards Now! Valid XHTML 1.1! Valid CSS! We rated with ICRA!