Debian Codegraph @

help/foreach

raw
1 ! $Id: foreach,v 1.6 2003-09-21 16:02:36 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: FOREACH <structure> <variable> { <commands> }
10 FE (<list>) <variable> { <commands> }
11 FOR (<commence>, <evaluation>, <iteration>) { <commands> }
12 This causes <commands> to be executed once for each
13 element in the structure. The aliases inside the {}
14 are not expanded until execution unless the leading {
15 is quoted like \{
16 Here are a couple examples of basic foreach commands.
17 assign blue.1 one
18 assign blue.2 two
19 assign blue.3 three
20 foreach blue ii { echo $ii $blue[$ii] }
21 will return
22 1 one
23 2 two
24 3 three
25 FOREACH can also be imbedded such as in the following example.
26 assign blue.1.1 one one
27 assign blue.1.2 one two
28 assign blue.2.1 two one
29 assign blue.2.2 two two
30 alias showblue {
31 foreach blue ii
32 {
33 foreach blue.$ii jj
34 {
35 echo $ii $jj $blue[$ii][$jj]
36 }
37 }
38 }
39 And /showblue returns..
40 1 1 one one
41 1 2 one two
42 2 1 two one
43 2 2 two two
44 Another example using FE:
45 assign blue one two three
46 alias showblue {
47 fe ($blue) ii {
48 echo $ii
49 }
50 }
51 And /showblue returns:
52 one
53 two
54 three
55 And an example for FOR:
56 for (@count=1,count<5,@count++) {
57 echo count is now $count
58 }
59 Output:
60 count is now 1
61 count is now 2
62 count is now 3
63 count is now 4
64
65 Note:
66 When using this format the {} in the foreach must be on separate
67 lines by themselves. This is true for IF and WHILE as well.
68
69 Notice that variable names 'ii' and 'jj' were used. Any name can
70 be used for the index but keep in mind that single letter vars can
71 interfere with the built in single char vars. See ALIAS special
72
73 See Also:
74 expressions
75 ALIAS special