| 1 |
! $Id: switch,v 1.1 2003-09-21 16:04:53 f Exp $ |
| 2 |
! |
| 3 |
! Copyright (c) 1994-2003 Flier |
| 4 |
! |
| 5 |
! All rights reserved. See the HELP SCROLLZ COPYRIGHT file for more |
| 6 |
! information. |
| 7 |
! |
| 8 |
Usage: SWITCH (text to be matched) |
| 9 |
{ |
| 10 |
(sample text) |
| 11 |
{ |
| 12 |
... |
| 13 |
} |
| 14 |
(sample text2) |
| 15 |
(sample text3) |
| 16 |
{ |
| 17 |
... |
| 18 |
} |
| 19 |
... |
| 20 |
} |
| 21 |
The (...) expression is taken to be regular expando-text |
| 22 |
(much like the (...) body of FE. The {...} body is |
| 23 |
taken to be a series of [(...)] {...} pairs. The [(...)] |
| 24 |
expression is taken to be one or more consecutive (...) |
| 25 |
structures, which are taken to be text expressions to match |
| 26 |
against the header text. If any of the (...) expressions |
| 27 |
are found to match, then the commands in the {...} body |
| 28 |
are executed. There may be as many such [(...)] {...} |
| 29 |
pairs as you need. However, only the *first* pair found |
| 30 |
to be matching is actually executed, and the others are |
| 31 |
ignored, so placement of your switches are rather important: |
| 32 |
put your most general ones last. |
| 33 |
|
| 34 |
Example: |
| 35 |
alias blah { |
| 36 |
switch ($0) { |
| 37 |
(1) { |
| 38 |
echo you entered 1 |
| 39 |
} |
| 40 |
(2) { |
| 41 |
echo you entered 2 |
| 42 |
} |
| 43 |
(3) |
| 44 |
(4) |
| 45 |
(5) { |
| 46 |
echo you entered 3,4 or 5 |
| 47 |
} |
| 48 |
} |
| 49 |
} |
| 50 |
eval ^input "enter your choice: " blah $$* |