From WikiChip
Difference between revisions of "mirc/commands/echo"
< mirc‎ | commands

m (Bot: Fixing compatibility)
(mIRC is British software - colour not color)
 
(26 intermediate revisions by 6 users not shown)
Line 1: Line 1:
The '''/echo command''' prints text to the specified window. This command does not send anything to the server. Text is only shown in your window buffer.
+
{{mirc title|/echo Command}}
 
+
The '''/echo''' command prints text to the specified window. This command does not send anything to the server; text is only shown in the window.
'''Note:''' If you use /window -s, line added to the window with /echo won't get sorted.
 
  
 
== Synopsis ==
 
== Synopsis ==
  /echo [color] [-deghiNtsaqlbfnmr] [window] <text>
+
  /echo [colour-number] [-deghi[N]tsaqlbfnmr] [window] <text>
  /echo [color] -c[deghiNtsaqlbfnmr] <color_name> [window] <text>
+
  /echo -c[deghi[N]tsaqlbfnmr] <colour-name> [window] <text>
  
 
== Switches ==
 
== Switches ==
* '''-c''' - Indicates the <color_name> parameter was provided.
+
=== Target window switches ===
* '''-e''' - Encloses the text with a pair of line separators
 
* '''-g''' - Prevents the text from being logged.
 
* '''-h''' - Applies a hard-wrap on the text.
 
* '''-i<N>''' - Wraps the text by <N> characters.
 
* '''-t''' - Adds a timestamp to the text if the timestamp is enabled (global or for that window)
 
 
* '''-s''' - prints to the status window
 
* '''-s''' - prints to the status window
 
* '''-a''' - prints to the active window
 
* '''-a''' - prints to the active window
 
* '''-d''' - prints to the single message window
 
* '''-d''' - prints to the single message window
* '''-q''' - Honors the $show flag. (If the alias was called with the . prefix)
+
 
* '''-n''' - Prevents switchbar/treebar status color change
+
=== Settings Related: ===
* '''-m''' - Treats the line as user message instead of an event
+
* '''-r''' - Applies the strip settings to the text (as defined in mIRC Options / IRC / Messages).
*Settings Related:
+
* '''-l''' - Applies the highlight settings to the text (as defined in mIRC Address Book / Highlight).
* '''-r''' - Applies the strip settings to the text.
+
* '''-b''' - Applies the windows beep settings (to beep if mIRC is not the active application) as defined in mIRC Options / Sounds and any individual window override.
* '''-l''' - Applies the highlight settings to the text
+
* '''-f''' - Applies the flash settings to the window (to flash the mIRC System Tray icon) as defined in mIRC Options / IRC / Options and any individual window override.
* '''-b''' - Applies the beep settings to the window.
+
 
* '''-f''' - Applies the flash settings to the window.
+
=== Other switches ===
 +
* '''-c''' - Indicates that the <colour-name> parameter is provided as the 1st parameter following the switch(es).
 +
* '''-e''' - Encloses the text with a pair of lines containing the line separator. Note: does not add a leading line if it already consists entirely of the line separator.
 +
* '''-g''' - Prevents the text from being logged if the window has logging on.
 +
* '''-h''' - Applies a hard-wrap on the text so that the wrap point does not change when the window is resized. Text is not wrapped if it is echoed to a custom listbox window.
 +
* '''-i[N]''' - Indents wrapped lines by [N] characters. The default mIRC indent is 2 spaces if N not used. Note: When using a proportional font, the indented width is a constant width regardless of the width of the characters echoed.
 +
* '''-t''' - Adds a timestamp to the text if the timestamp is enabled for that window. Without this, the line will not be timestamped even if the window has timestamping set. Note: -t shows timestamp in Custom Windows even though they do not have a timestamp setting, but only if timestamping has been enabled in mirc-options/irc/messages/"timestamp events".
 +
* '''-q''' - Honors the $show flag. (Displays nothing if the alias was called with the . prefix)
 +
* '''-n''' - Prevents switchbar button/treebar colour change
 +
* '''-m''' - Treats the line as an user message, colours the window button in the switchbar/treebar with the "Message" colour defined in the option  alt+o>Display.
  
 
== Parameters ==
 
== Parameters ==
 
+
* '''[colour-number]''' - A numeric colour value (0 to 99) Note: 99 is $colour(listbox text) instead of $colour(normal) even in #channel and Status window where background is $colour(background). If $colour(listbox text) is the same index as $colour(background), 99 tries $colour(normal) then $colour(gray) searching for a colour that doesn't match the background colour.
* '''[color]''' - A numeric color value (0 to 15)
+
* '''<colour-name>''' - When the -c switch is used, the next parameter must be one of the following: action, ctcp, highlight, info, info2, invite, join, kick, mode, nick, normal, notice, notify, other, own, part, quit, topic, wallops, whois, "listbox text", gray, listbox, "treebar text", treebar Note: Quotes are needed for items which are 2 words. Note: If colour for that name matches $colour(background) it is displayed as $colour(normal) until the colour index for background is changed. Note: If colour name not in the list of recognized names, defaults to 'normal'. Note: If you later change the colour index for a colour name, the echoed lines change to that colour.
* '''<color_name>''' - Used with the -c switch. One of the following: Action, ctcp, highlight, info, info2, invite, join, part, quit, kick, mode, topic, nick, normal, notice, notify, other, own, wallops, whois
+
* '''[window]''' - The target @window/#channel/query '''Note:''' If you use /echo to send text to a custom @window which has been opened by {{mIRC|/window|/window -s}}, the line will be added at the bottom of the window rather than being inserted in the correct sort position. '''Note:''' If target is a listbox @window created using the -l switch, the output echoes to the Status Window instead.
* '''[window]''' - The target window/channel/query
 
 
* '''<text>''' - The text to be printed
 
* '''<text>''' - The text to be printed
 
+
Note: regardless whether or not -e switch is used, echo will not create a 2nd consecutive line consisting of the line separator, unless the existing last line was created in a @window using /aline.
== Example ==
+
== Examples ==
A Hello World example:
+
=== Example 1: Hello world ===
 
 
 
<syntaxhighlight lang="mIRC">/echo -a Hello World!</syntaxhighlight>
 
<syntaxhighlight lang="mIRC">/echo -a Hello World!</syntaxhighlight>
  
A simple example of a loop that prints a few lines:
+
=== Example 2: A loop prints a few lines ===
 
 
 
<syntaxhighlight lang="mIRC">alias example {
 
<syntaxhighlight lang="mIRC">alias example {
 
   var %x = 5
 
   var %x = 5
Line 55: Line 55:
 
This is example line 2.
 
This is example line 2.
 
This is example line 1.</pre>
 
This is example line 1.</pre>
 +
 +
=== Example 3: Timestamps ===
 +
<syntaxhighlight lang="mIRC">
 +
echo    #test            This line never has a timestamp
 +
echo -t #test            This line has a timestamp only if timestamping is enabled within #test
 +
echo    #test $timestamp This line always has a timestamp
 +
</syntaxhighlight>
 +
 +
=== Example 4: Colours ===
 +
<syntaxhighlight lang="mIRC">
 +
//echo 4 -at                abc $chr(22) def $chr(15) The timestamp and this text following the Ctrl-O revert to colour 4 (red)
 +
//echo -act ctcp            abc $chr(22) def $chr(15) The timestamp and this text following the Ctrl-O revert to "ctcp" colour ( $+ $colour(ctcp) $+ )
 +
//echo -at $chr(3) $+ 04 $+ abc $chr(22) def $chr(15) The timestamp and this text appear as "normal" colour ( $+ $colour(normal) $+ )
 +
</syntaxhighlight>
 +
 +
=== Example 5: Switchbar/treebar colours ===
 +
<syntaxhighlight lang="mIRC">
 +
; See mirc-options/display
 +
; The 1st line    causes the switchbar to change to the "event" colour.
 +
; The 2nd line -m causes the switchbar to change to the "messages" colour, overriding the default EVENT colour.
 +
; The 3rd line -n leaves the switchbar colour unchanged.
 +
; Note that Chanserv giving the joined nick OP level is a separate event, and mIRC will change the -m override, and that event will colour the switchbar as the EVENT colour.
 +
 +
on ^*:JOIN:#:{
 +
  echo $colour(join) -t  # * $nick $+($chr(40),$gettok($fulladdress,2-,33),$chr(41)) has joined # $comchan($nick,0)
 +
  echo $colour(join) -tm # * $nick $+($chr(40),$gettok($fulladdress,2-,33),$chr(41)) has joined # $comchan($nick,0)
 +
  echo $colour(join) -tn # * $nick $+($chr(40),$gettok($fulladdress,2-,33),$chr(41)) has joined # $comchan($nick,0)
 +
  haltdef
 +
}
 +
</syntaxhighlight>
 +
 +
<syntaxhighlight lang="mIRC">
 +
/echo -m @window test
 +
/echo -m #channel test
 +
  ;has the same effect as:
 +
/echo @window test
 +
/echo #channel test
 +
/window -g1 @window
 +
/window -g1 #channel
 +
</syntaxhighlight>
 +
 +
<syntaxhighlight lang="mIRC">
 +
The echo command modifies <text> by hiding duplicate spaces and non-printable characters including $chr(9) tab.
 +
//var %a abc $+ $chr(32) $+ $chr(32) $+ def | echo -a $len(%a) %a
 +
returns: 8 abc def
 +
... where the duplicate space is not displayed.
 +
//var %a abc $chr(9) def | echo -a $len(%a) %a
 +
returns: 9 abc  def
 +
... where there are 2 spaces appearing next to each other because they were not consecutive prior to the non-printable tab being hidden.
 +
All 6 letters are displayed on the same line because $crlf is non-printable:
 +
//var %a $+(abc,$crlf,def) | echo -a %a
 +
Echo a blank line because it contains only non-printable characters:
 +
//echo -a $crlf
 +
</syntaxhighlight>
  
 
== Compatibility ==
 
== Compatibility ==
Line 62: Line 116:
 
* [[List of commands - mIRC|List of commands]]
 
* [[List of commands - mIRC|List of commands]]
 
* [[List of identifiers - mIRC|List of identifiers]]
 
* [[List of identifiers - mIRC|List of identifiers]]
 +
* {{mIRC|$colour}}
 +
* {{mIRC|$color}}
 
* {{mIRC|$N}}
 
* {{mIRC|$N}}
 
* {{mIRC|/aline}}
 
* {{mIRC|/aline}}
Line 71: Line 127:
 
{{mIRC command list}}
 
{{mIRC command list}}
  
[[Category:MIRC commands]]
+
[[Category:mIRC commands|echo command - mIRC]]

Latest revision as of 03:39, 10 January 2018

The /echo command prints text to the specified window. This command does not send anything to the server; text is only shown in the window.

Synopsis[edit]

/echo [colour-number] [-deghi[N]tsaqlbfnmr] [window] <text>
/echo -c[deghi[N]tsaqlbfnmr] <colour-name> [window] <text>

Switches[edit]

Target window switches[edit]

  • -s - prints to the status window
  • -a - prints to the active window
  • -d - prints to the single message window

Settings Related:[edit]

  • -r - Applies the strip settings to the text (as defined in mIRC Options / IRC / Messages).
  • -l - Applies the highlight settings to the text (as defined in mIRC Address Book / Highlight).
  • -b - Applies the windows beep settings (to beep if mIRC is not the active application) as defined in mIRC Options / Sounds and any individual window override.
  • -f - Applies the flash settings to the window (to flash the mIRC System Tray icon) as defined in mIRC Options / IRC / Options and any individual window override.

Other switches[edit]

  • -c - Indicates that the <colour-name> parameter is provided as the 1st parameter following the switch(es).
  • -e - Encloses the text with a pair of lines containing the line separator. Note: does not add a leading line if it already consists entirely of the line separator.
  • -g - Prevents the text from being logged if the window has logging on.
  • -h - Applies a hard-wrap on the text so that the wrap point does not change when the window is resized. Text is not wrapped if it is echoed to a custom listbox window.
  • -i[N] - Indents wrapped lines by [N] characters. The default mIRC indent is 2 spaces if N not used. Note: When using a proportional font, the indented width is a constant width regardless of the width of the characters echoed.
  • -t - Adds a timestamp to the text if the timestamp is enabled for that window. Without this, the line will not be timestamped even if the window has timestamping set. Note: -t shows timestamp in Custom Windows even though they do not have a timestamp setting, but only if timestamping has been enabled in mirc-options/irc/messages/"timestamp events".
  • -q - Honors the $show flag. (Displays nothing if the alias was called with the . prefix)
  • -n - Prevents switchbar button/treebar colour change
  • -m - Treats the line as an user message, colours the window button in the switchbar/treebar with the "Message" colour defined in the option alt+o>Display.

Parameters[edit]

  • [colour-number] - A numeric colour value (0 to 99) Note: 99 is $colour(listbox text) instead of $colour(normal) even in #channel and Status window where background is $colour(background). If $colour(listbox text) is the same index as $colour(background), 99 tries $colour(normal) then $colour(gray) searching for a colour that doesn't match the background colour.
  • <colour-name> - When the -c switch is used, the next parameter must be one of the following: action, ctcp, highlight, info, info2, invite, join, kick, mode, nick, normal, notice, notify, other, own, part, quit, topic, wallops, whois, "listbox text", gray, listbox, "treebar text", treebar Note: Quotes are needed for items which are 2 words. Note: If colour for that name matches $colour(background) it is displayed as $colour(normal) until the colour index for background is changed. Note: If colour name not in the list of recognized names, defaults to 'normal'. Note: If you later change the colour index for a colour name, the echoed lines change to that colour.
  • [window] - The target @window/#channel/query Note: If you use /echo to send text to a custom @window which has been opened by /window -s, the line will be added at the bottom of the window rather than being inserted in the correct sort position. Note: If target is a listbox @window created using the -l switch, the output echoes to the Status Window instead.
  • <text> - The text to be printed

Note: regardless whether or not -e switch is used, echo will not create a 2nd consecutive line consisting of the line separator, unless the existing last line was created in a @window using /aline.

Examples[edit]

Example 1: Hello world[edit]

/echo -a Hello World!

Example 2: A loop prints a few lines[edit]

alias example {
  var %x = 5
  while (%x) {
    echo -a This is example line $v1 $+ .
    dec %x
  }
}

The above will print:

This is example line 5.
This is example line 4.
This is example line 3.
This is example line 2.
This is example line 1.

Example 3: Timestamps[edit]

echo    #test            This line never has a timestamp
echo -t #test            This line has a timestamp only if timestamping is enabled within #test
echo    #test $timestamp This line always has a timestamp

Example 4: Colours[edit]

//echo 4 -at                abc $chr(22) def $chr(15) The timestamp and this text following the Ctrl-O revert to colour 4 (red)
//echo -act ctcp            abc $chr(22) def $chr(15) The timestamp and this text following the Ctrl-O revert to "ctcp" colour ( $+ $colour(ctcp) $+ )
//echo -at $chr(3) $+ 04 $+ abc $chr(22) def $chr(15) The timestamp and this text appear as "normal" colour ( $+ $colour(normal) $+ )

Example 5: Switchbar/treebar colours[edit]

; See mirc-options/display
; The 1st line    causes the switchbar to change to the "event" colour.
; The 2nd line -m causes the switchbar to change to the "messages" colour, overriding the default EVENT colour.
; The 3rd line -n leaves the switchbar colour unchanged.
; Note that Chanserv giving the joined nick OP level is a separate event, and mIRC will change the -m override, and that event will colour the switchbar as the EVENT colour.
 
on ^*:JOIN:#:{
  echo $colour(join) -t  # * $nick $+($chr(40),$gettok($fulladdress,2-,33),$chr(41)) has joined # $comchan($nick,0)
  echo $colour(join) -tm # * $nick $+($chr(40),$gettok($fulladdress,2-,33),$chr(41)) has joined # $comchan($nick,0)
  echo $colour(join) -tn # * $nick $+($chr(40),$gettok($fulladdress,2-,33),$chr(41)) has joined # $comchan($nick,0)
  haltdef
}
/echo -m @window test
/echo -m #channel test
  ;has the same effect as:
/echo @window test
/echo #channel test
/window -g1 @window
/window -g1 #channel
The echo command modifies <text> by hiding duplicate spaces and non-printable characters including $chr(9) tab.
//var %a abc $+ $chr(32) $+ $chr(32) $+ def | echo -a $len(%a) %a
returns: 8 abc def
... where the duplicate space is not displayed.
//var %a abc $chr(9) def | echo -a $len(%a) %a
returns: 9 abc  def
... where there are 2 spaces appearing next to each other because they were not consecutive prior to the non-printable tab being hidden.
All 6 letters are displayed on the same line because $crlf is non-printable:
//var %a $+(abc,$crlf,def) | echo -a %a
Echo a blank line because it contains only non-printable characters:
//echo -a $crlf

Compatibility[edit]

Added: mIRC v3.7
Added on: 12 Oct 1995
Note: Unless otherwise stated, this was the date of original functionality.
Further enhancements may have been made in later versions.


See also[edit]

v · d · e mIRC commands list

A /abook, /action, /add, /ajinvite, /alias, /aline, /ame, /amsg, /anick, /aop, /auser, /auto, /autojoin, /avoice, /away

B /background, /ban, /bcopy, /beep, /bindip, /bread, /break, /breplace, /bset, /btrunc, /bunset, /bwrite

C /channel, /clear, /clearall, /clearial, /cline, /clipboard, /close, /closechats, /closedccs, /closefserves, /closemsg, /cnick, /color, /colour, /comclose, /comlist, /commands, /comopen, /comreg, /continue, /copy, /creq, /ctcp, /ctcpreply, /ctcps

D /dcc, /dccserver, /dde, /ddeserver, /debug, /dec, /describe, /dialog, /did, /didtok, /disable, /disconnect, /dlevel, /dline, /dll, Template:mIRC/donotdisturb, /dns, /dqwindow, /drawcopy, /drawdot, /drawfill, /drawline, /drawpic, /drawrect, /drawreplace, /drawrot, /drawsave, /drawscroll, /drawsize /drawtext

E /ebeeps, /echo, /editbox, /else, /elseif, /emailaddr, /enable, /events, /exit

F /fclose, /filter, /findtext, /finger, /firewall, /flash, /flist, /flood, /flush, /flushini, /fnord, /font, /fopen, /fseek, /fsend, /fserve, /fullname, /fupdate, /fwrite

G /ghide, /gload, /gmove, /gopts, /goto, /gplay, /gpoint, /gqreq, /groups, /gshow, /gsize, /gstop, /gtalk, /gunload, /guser

H /hadd, /halt, /haltdef, /hdec, /hdel, /help, /hfree, /hinc, /hload, /hmake, /hotlink, /hop, /hsave

I /ial, /ialclear, /ialmark, /identd, /if, /ignore, /iline, /inc, /iuser

J /join

L /leave, /linesep, /links, /list, /load, /loadbuf, /localinfo, /log, /logview

M /maxdepth, /mdi, /me, /menubar, /mkdir, /mnick, /mode, /msg

N /noop, /notice, /notify

O /onotice, /omsg

P /pareline, /part, /partall, /pdcc, /perform, /play, /playctrl, /pop, /protect, /proxy, /pvoice

Q /qme, /qmsg, /query, /queryrn, /quit, /quote

R /raw, /registration, /reload, /remini, /remote, /remove, /rename, /renwin, /reseterror, /resetidle, /return, /returnex, /rlevel, /rline, /rmdir, /run, /ruser

S /save, /savebuf, /saveini, /say, /scid, /scon, /server, /set, /setlayer, /showmirc, /signal, /sline, /sockaccept, /sockclose, /socklist, /socklisten, /sockmark, /sockopen, /sockpause, /sockread, /sockrename, /sockudp, /sockwrite, /sound, /speak, /splay, /sreq, /strip, /switchbar

T /timer, /timestamp, /tip, /tips, /titlebar, /tnick, /tokenize, /toolbar, /topic /tray, /treebar

U /ulist, /unload, /unset, /unsetall, /updatenl, /url, /username, /uwho

V /var, /vcadd, /vcmd, /vcrem, /vol

W

X /xyzzy