fixed file permissions
[fifth.git] / doc / commands / conditio.txt
1                         Conditionals & loops\r
2                         ------------------\r
3 \r
4 if              ( flag -- )   (immideate)\r
5                 "if 1.. else 2.. then" or\r
6                 "if 1.. then" construction. Conditional execution.\r
7                 Performs "1.." if "flag" was true,\r
8                 elseway performs "2.." if exist. Execution continues after\r
9                 word "then".\r
10                 ex: 1 if ." nonzero" else ." zero" then\r
11 \r
12 >=              ( n1 n2 -- result ) true if (n1 = n2) or (n1 > n2)\r
13                 ex: 5 3 >= if ." first number is greater or equal" then\r
14 \r
15 <=              ( n1 n2 -- result ) true if (n1 = n2) or (n1 < n2)\r
16 =               ( n1 n2 -- result ) true if n1 = n2\r
17 \r
18 do              ( count -- )  (immideate)\r
19                 "do .. loop" construction. Performs ".." "count" times.\r
20                 In every step "count" is decareased until it is 0.\r
21                 ex: : test 5 do i .d loop ;\r
22                 result: 4 3 2 1 0\r
23 \r
24 doexit         ( -- ) exit from "do .. loop"\r
25 \r
26 for             ( count top -- )   (immideate)\r
27                 "for .. loop" construction. Performs ".." (top - count)  times.\r
28                 In every step "count" is incareased until it reaches "top" .\r
29                 ex: : test 4 10 for i .d loop ;\r
30                 result: 4 5 6 7 8 9\r
31 \r
32 forexit         ( -- ) exit from "for .. loop"\r
33 \r
34 until           ( -- )  (immideate)\r
35                 "until .. loop" construction. Performs ".." until flag become\r
36                 true. False by default. Top of return stack holds flag.\r
37 \r
38 done            ( -- ) exit from "until .. loop"\r
39 \r