Hi, Ola!
The netlogo way to emulate a select or switch statement is to use a nested if-else structure.
For example:
if-else option1 [ action1 ] [
if-else option2 [ action2 ] [
if-else option3 [ action3 ] [
otherwise-action
]]]
To preserve the formatting and clarity of the structure, it's good to use only short commands, or procedure calls as the action, but that is a code-style issue, not a code-running issue.
Note that there will always be one right square bracket at the end for each if-else, so, three options = three brackets.
Note that even if there is no "otherwise-action", the last if-else can remain an if-else, there's no need to break the symmetry and use IF instead.
Hope this helps,
~~James
_________________
www.turtlezero.com
On Thu, Mar 6, 2008 at 8:25 PM, Ola Olsson < oeolsson
enosis.net">oeolsson
enosis.net> wrote:
> Hello,
>
> I9;m trying to get a handle on all the NetLogo commands. Is there an
> equivalent command or preferred set of commands that will replicate
> the "select case" statement found in other languages? Currently I
> have to set a boolean variable at the top of my procedure then
> traverse through a bunch of if statements until one is satisfied then
> set my variable to false so the procedure doesn't waste its time with
> the subsequent ifs.
>
> Best Regards,
> Ola Olsson
> --
> Cheers,
> Ola Olsson
>
> /*******************************************
> /** oeolsson
enosis.net">oeolsson
enosis.net -- http://www.enosis.net
> /** "There is a time for laughing
> /** and there is a time not for laughing.
> /** This is not one of them."
> /*******************************************
.