Skip to content
Luxembourg edited this page Mar 20, 2013 · 4 revisions

@dolist

command: @dolist[/<switch>] [<delimiter>] <list>=<action>

<list> is a list of strings, which can be object numbers, attributes, or arbitrary words. <action> is a command to perform once for each item in <list>, replacing the special symbol ## with the corresponding item from <list>, and the symbol #@ with the position in the list, starting with one. by default, @dolist considers each item in <list> to be separated with spaces. if you specify the /delimit switch, then each item is considered to be separated by <delimiter>. <delimiter> must be a single character.

if present, <switch> can be any of: /space - (default) list elements are separated by spaces. /delimit - list elements are separated by <delimiter>. /notify - queues a '@notify' after all commands in the list.

this command is particularly handy with lcon() and lexits(). a few examples:

@dolist [lcon(here)] = "name(##) @dolist [lcon(here)] = @switch [get(##/last)]=1990,"[name(##)] @va me = va vb vc @dolist [get(me/va)] = @emit [get(me/##)] @dolist frodo bilbo gandalf = page ## = help!!!! i've fallen into a pit. @dolist/delimit , {frodo, bilbo baggins, gandalf} = page ## = help!!!! @wait me="this is a semaphore. @dolist/notify lnum(3)=say ## > you say, "0" > you say, "1" > you say, "2" > you say, "this is a semaphore."

related topics: iter(), @notify, semaphores.

Clone this wiki locally