~ubuntu-branches/ubuntu/feisty/kvirc/feisty

« back to all changes in this revision

Viewing changes to data/help/index/syntax_aliases.kvihelp

  • Committer: Bazaar Package Importer
  • Author(s): Robin Verduijn
  • Date: 2002-04-16 13:47:41 UTC
  • Revision ID: james.westby@ubuntu.com-20020416134741-02slrqk6ige4cchu
Tags: 1:2.1.2-11
* #138169: The problem in bug #138169 is due to a bug in libtool. See
  bug #98342 for details. KVirc still doesn't build correctly even with
  the latest libtool (1.4.2-4). When this gets properly fixed I'll update
  kvirc's build dependency on libtool. In the mean time, I've applied a
  patch from that bug report which fixes it for me.
  (Closes: #138169)
* Redid debian/rules somewhat; no longer try to build differently
  depending on how KDE is installed. If the preferred configuration breaks
  for some platform, I'd rather know about it.
* Don't link versus qt-mt anymore.
* GNU config automated update: config.sub (20010907 to 20020307),
  config.guess (20010904 to 20020320)

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
<doctitle>Scripting language syntax : aliases</doctitle>
 
2
<docbody>
 
3
<hr>
 
4
 
 
5
<docsubtitle>Aliases</docsubtitle>
 
6
<blockquote>
 
7
<p>
 
8
KVIrc supports definition of sub-procedures : aliases<br>
 
9
You can define an alias by using the built-in editor or by using the
 
10
<a href="alias.kvihelp">alias</a> command.<br>
 
11
</p>
 
12
<example>
 
13
<a href="alias.kvihelp">alias</a> saytoconsole { <a href="echo.kvihelp">echo</a> -w=<a href="s_console.kvihelp">$console</a> $1-; }
 
14
</example>
 
15
<p>
 
16
In the above example we define the command "saytoconsole"
 
17
that "echoes" the text passes as parameters to the console window.<br>
 
18
Now we can call it in the following way:<br>    
 
19
</p>
 
20
<example>
 
21
saytoconsole This text will go to the console window
 
22
</example>
 
23
<p>
 
24
Inside the alias there are few special identifiers:<br>
 
25
$0 : evaluates to the name of the alias<br>
 
26
$1 : evaluates to the first positional parameter<br>
 
27
$2...$9999999 : same as above but for the second, third.....parameter<br>
 
28
$# : evaluates to the number of the parameters passed.<br>
 
29
$1- : evaluates to all the positional parameters<br>
 
30
$2- : evaluates to all the positional parameters starting at the second one.<br>
 
31
$1-2 : evaluates to the parameters 1 and 2
 
32
$3-12 : evaluates to the parameters from 3 to 12
 
33
</p>
 
34
</blockquote>
 
35
 
 
36
 
 
37
<docsubtitle>User definable functions</docsubtitle>
 
38
<blockquote>
 
39
<p>
 
40
KVIrc does not provide a direct way to create user definable functions.<br>
 
41
The function mechanism is emulated by aliases , the "bracket identifier" ${ }
 
42
and the <a href="setreturn.kvihelp">setreturn</a> command.<br>
 
43
</p>
 
44
<example>
 
45
<a href="alias.kvihelp">alias</a> sumthreenumbers <a href="setreturn.kvihelp">setreturn</a> <a href="s_calc.kvihelp">$calc</a>( $1 + $2 + $3)
 
46
<a href="echo.kvihelp">echo</a> ${ sumthreenumbers 10 20 30; }
 
47
</example>
 
48
<p>
 
49
The example above will print 60 in the current window.<br>
 
50
<a href="setreturn.kvihelp">setreturn</a> sets the return value of the alias
 
51
to the sum of the three numbers.<br>
 
52
The "${ }" identifier braces execute the command specified inside and evaluate
 
53
to the return value of that command.<br>
 
54
You can execute more commands in the identifier braces
 
55
and <a href="setreturn.kvihelp">setreturn</a> may be not called or called more than once.<br>
 
56
Obviously the last call defines the effective value returned by ${ }.<br>
 
57
Some other KVIrc commands set the return value.<br>
 
58
All the alias calls set the return value
 
59
to the return value of the internal sequence of commands
 
60
(<a href="alias.kvihelp">alias</a> propagates the return value).<br>
 
61
</p>
 
62
<example>
 
63
<a href="alias.kvihelp">alias</a> propagate sumthreenumbers 15 5 20
 
64
<a href="echo.kvihelp">echo</a> ${ propagate }
 
65
</example>
 
66
<p>
 
67
In the example above "sumthreenumbers" sets the return value of the
 
68
"propagate" alias.<br>
 
69
The <a href="parse.kvihelp">parse</a> command also propagates the
 
70
return value.<br>
 
71
<a href="op.kvihelp">op</a> , <a href="deop.kvihelp">deop</a> ,
 
72
<a href="ban.kvihelp">ban</a> and other similar commands
 
73
return the number of messages effectively sent to the server.<br>
 
74
Bad example:<br>
 
75
</p>
 
76
<example>
 
77
<a href="alias.kvihelp">alias</a> test  <a href="setreturn.kvihelp">setreturn</a> 10; op Pragma; echo Opped Pragma;
 
78
<a href="echo.kvihelp">echo</a> ${ test }
 
79
</example>
 
80
<p>
 
81
In the example above the <a href="setreturn.kvihelp">setreturn</a> command is
 
82
useless: <a href="op.kvihelp">op</a> resets the return value to 1 that is the number
 
83
of MODE +o messages sent.<br>
 
84
<a href="echo.kvihelp">echo</a> does not modify the return value.<br>
 
85
</p>
 
86
<p>
 
87
In the help page of each command you will find the information
 
88
about the return value.<br>
 
89
Seem complicated ? :)<br>
 
90
</p>
 
91
</blockquote>
 
92
 
 
93
<hr>
 
94
<a href="index.kvihelp">Main index</a> , <a href="syntax.kvihelp">Syntax index</a>
 
95
</docbody>
 
96
 
 
97
 
 
98
</docbody>
 
99