| 1 |
! $Id: assign,v 1.4 2002-02-21 17:16:31 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: ASSIGN [[-]<user-variable> [<whatever>]] |
| 10 |
ASSIGN lets you create user variables which are automatically |
| 11 |
expanded by ScrollZ in aliases using the $variable-name format. |
| 12 |
For example, if you had defined: |
| 13 |
ASSIGN me The Big Cheese |
| 14 |
Then, in an alias, $me would expand to "The Big Cheese". These |
| 15 |
are straight textual substitutions. You can use these kind |
| 16 |
of variables as counters and indexes into lists as well. For |
| 17 |
example: |
| 18 |
ASSIGN index 0 |
| 19 |
ASSIGN index ${index+1} |
| 20 |
The first line sets "index" to 0, the seconds increments index by 1. |
| 21 |
Note that the second will always be expanded if used in another |
| 22 |
alias (where $ are normally expanded). If you want it to be |
| 23 |
expanded if typed at the input line, you must first set |
| 24 |
INPUT_ALIASES to ON. |
| 25 |
|
| 26 |
Note: In the above example, the mathematical expression must be |
| 27 |
enclosed by {}'s otherwise the + would be treated as an alias |
| 28 |
delimiter and the addition not performed. (See @ as well) |
| 29 |
|
| 30 |
Suppose now you wanted to use index to get a single word in a list, |
| 31 |
you could do: |
| 32 |
ALIAS WORD ECHO $($index) |
| 33 |
Then doing: |
| 34 |
WORD This is a test |
| 35 |
would display the index'th word in the list. |
| 36 |
The $($index) format does the following: it parses the text |
| 37 |
between the () as a sub-alias. The "$index" is thus evaluated |
| 38 |
and returns it's value. This value is then replaced for the () |
| 39 |
expression and evaluated. So, if you had: |
| 40 |
ASSIGN index 1 |
| 41 |
Then, the following would be evaluated: |
| 42 |
$index becomes 1 which given |
| 43 |
$(1) which becomes simply $1 |
| 44 |
Thus the $1 argument is used. |
| 45 |
This functionality can be nested. This the following: |
| 46 |
ASSIGN A Hey You! |
| 47 |
ASSIGN B A |
| 48 |
ASSIGN C B |
| 49 |
ALIAS NESTING echo $($($C)) |
| 50 |
will cause NESTING to display "Hey You!" |
| 51 |
|
| 52 |
The following format are also legal: |
| 53 |
$#name evaluates to the number of words in name |
| 54 |
$@name evaluates to the number of characters in name |
| 55 |
You can use these with the mathematical expressions as well, |
| 56 |
for example: |
| 57 |
ASSIGN foo Testing One Two |
| 58 |
ECHO $#foo $@foo |
| 59 |
ASSIGN junk ${#foo + @foo} |
| 60 |
The ECHO line will display 3 15 and the variable junk have the |
| 61 |
value 18. |
| 62 |
|
| 63 |
Additionally, values assigned to FUNCTION_RETURN are taken to be |
| 64 |
the return value of a function. |
| 65 |
|
| 66 |
IMPORTANT NOTE: |
| 67 |
There is a special version of this command called '@' |
| 68 |
for use in aliases and scripts. It is well suited to mathematical |
| 69 |
operations. Its use over ASSIGN is highly recommended. |
| 70 |
|
| 71 |
See Also: |
| 72 |
@ |
| 73 |
ALIAS |
| 74 |
IF |
| 75 |
SET INPUT_ALIASES |
| 76 |
ALIAS functions |