Debian Codegraph @

help/while

raw
1 ! $Id: while,v 1.3 2002-02-19 19:43:28 f Exp $
2 !
3 ! Copyright (c) 1990-2001 Michael Sandrof, Troy Rollo, Matthew Green,
4 ! and other ircII contributors.
5 !
6 ! All rights reserved. See the HELP SCROLLZ COPYRIGHT file for more
7 ! information.
8 !
9 Usage: WHILE <boolean> { <cmd> }
10 This will execute the given cmd while the given boolean returns
11 true. The boolean has the same format as for the IF command, except
12 that it is re-evaluated at each loop interation. The same is true
13 for cmd. It is re-evaluated at each loop interation.
14 Example (in script format):
15 alias repeat
16 {
17 @ rep = 0;
18 while (rep < [$0])
19 {
20 $1-
21 @ rep = rep + 1
22 }
23 assign -rep
24 }
25
26 This can be used as follows:
27 /repeat 10 /msg bigcheese This repeats 10 times
28 The repeat alias breaks down into three parts.
29
30 @ rep = 0
31 while (rep < [$0]) {$1-;@ rep = rep + 1}
32 assign -rep
33
34 The first is to initialize rep to 0 and the last part is to remove
35 rep when done. The first is just like ASSIGN rep 0
36 The WHILE portion is described below:
37 The boolean for the while loop is (rep < [$0]).
38 This is what is then used at each loop interation. At the
39 first iteration this will be ( 0<10 ), at the next ( 1<10 ), and so on.
40 The cmd part of this looks like {$1-;@ rep = rep + 1}
41 When the alias is first parsed, the stuff inside {..} is not expanded but
42 is simply executed at each loop interation. It expands to
43 'msg bigcheese This repeats 10 times.;@ rep = rep + 1'
44 It sends the MSG to BigCheese and then it increments rep by 1.
45 (See HELP @ for more information about this assignment)
46
47 The command part while is exactly like the syntax in IF
48 and FOREACH.
49
50 See Also:
51 IF
52 FOREACH
53 @
54 expressions