Control structures must be used within an explicit definition. The explicit definition link will explain what the "3" and "0" signify, but note that the following are equivalent.
myfunction=: 3 : 0
NB. define function/verb here
)
myfunction=: verb define
NB. define function/verb here
)
Here is an example of defining an explicit function/verb containing a for loop:
for_eg=: verb define
a=. 3
b=. 8
for. i.b do.
a=. a + 1
end.
a
)
Here is an example of using that verb:
for_eg ''
11
The Jwiki contains a wiki page describing how to define a verb. Note the references at the bottom for more info.