home *** CD-ROM | disk | FTP | other *** search
/ CD Actual 9 / CDACTUAL9.iso / comms / Internet / virc96 / VSCRIPT.TXT < prev    next >
Encoding:
Text File  |  1996-12-22  |  71.6 KB  |  2,074 lines

  1. ViRCScript Documentation (for Visual IRC '96 0.82a and above) - Revision 16a
  2. ============================================================================
  3.  
  4. Introduction
  5. ============
  6.  
  7. What is ViRCScript? ViRCScript (from now on abbreviated to VS) is the scripting
  8. language supported by ViRC '96. VS is similar to BASIC, C, VPL, and ircII's
  9. scripting language. You use VS to write code for events and aliases. In 0.82,
  10. the ViRCScript interpreter is around 97% complete. Newer versions will add more
  11. functionality, however, I will endeavour to ensure that these new changes don't
  12. break your old code.
  13.  
  14. VS is 100% written by myself. I've used no code from anywhere else or custom
  15. controls in my parser, numerical evaluator, or anything else. This means that
  16. if you have any problems, you have no-one to blame them on but me. >:-> (That
  17. said, no-one has reported any real problems in ViRCScript. It seems to be the
  18. most stable portion of V96 I've written so far).
  19.  
  20. What's new in this release of ViRCScript?
  21. -----------------------------------------
  22.  
  23. Note that this list also includes the stuff new in 0.80 and 0.82.
  24.  
  25. The ^^ (raise to a power) operator now works properly. Deleting array variables
  26. with a variable as the index (e.g. -@ $array.$x) now works properly
  27. (finally!! ;). Added C-style += and -= operators. Added date/time formatting
  28. capabilities to the TIME function. Corrected some documentation inaccuracies
  29. (e.g. the built-in variables, and in the sample code for the IDLETIME
  30. function). New built-in <OnNewInactiveText> event. New BEEP command. New
  31. OPENDIALOG and SAVEDIALOG functions to encapsulate the common dialogs. Fixed
  32. bugs where pseudovariables could be lost after TextOut and Yield statements.
  33. New built-in DCC events (<OnDCCChatConnect>, <OnDCCChatText>,
  34. <OnDCCChatDisconnect>). Minor performance improvements. HALT statement now
  35. breaks out of all loops correctly (previous versions had problems with breaking
  36. out of nested code blocks). MIN, MAX, RESTORE, CLOSE, SETFOCUS window-handling
  37. functions. New file I/O stuff (READLINE, GETLINESINFILE commands). Directory
  38. I/O stuff (MKDIR, CHDIR, RMDIR commands, GETCURRENTDIR function). UNALIAS and
  39. UNEVENT commands added. ObjectViRCScript extensions added (see OBJECTVS.TXT).
  40. New MESSAGEDLG function added.
  41.  
  42. New in 0.82: SIMULATESERVERDATA command. New OPTIMIZED keyword for FOR and
  43. WHILE statements. New set-handling functions (ADDTOSET, REMOVEFROMSET and
  44. ISINSET). New GETUSER function. Documented event templates (they were
  45. implemented in 0.80, but were documented only in 0.82). Severely-broken BREAK
  46. command fixed. CONTINUE command added. Conditional execution parameters added
  47. to BREAK and HALT commands (and CONTINUE too). Corrected documentation
  48. inaccuracies (e.g. the code sample given in the local variables section (the
  49. LOCALTEST and LOCALLOOP aliases) did not work at all ;). New OPSTRIP and
  50. SELECTEDNICK functions.
  51.  
  52. New in 0.82a: Buggy string comparisons with == fixed. WILDMATCH function
  53. improved to handle a*c-style wildcards. New === (exactly equals) operator
  54. added.
  55.  
  56. Syntax
  57. ------
  58.  
  59. Place one VS instruction on each line. Lines beginning with # or // are assumed
  60. to be comments, and are ignored. Otherwise the line is parsed and executed.
  61. Statements and functions are case-insensitive, except for variables, which are
  62. case-sensitive, i.e. $x is not the same as $X. Numerical parameters to
  63. functions can be supplied in decimal, or in hex by prefixing with a $. For
  64. example, to get a random number between 0 and 254, you could use:
  65.  
  66.         $rand(255)
  67.  
  68.     Or:
  69.  
  70.         $rand($FF)
  71.  
  72. Variables
  73. ---------
  74.  
  75. Variables are allocated and assigned with the @ operator, and deallocated with
  76. the -@ operator. Examples:
  77.  
  78.         @ $x = Hello everybody!!
  79.         -@ $x
  80.  
  81. Wildcards are supported when using -@, and this is very useful with arrays.
  82. Say, for example, you defined the following array:
  83.  
  84.         @ $greeting.0 = Hello
  85.         @ $greeting.1 = Hi
  86.         @ $greeting.2 = Yo
  87.         @ $greeting.3 = Greetings
  88.         @ $greeting.4 = Howdy
  89.  
  90. You could delete the whole thing in one go with the single statement:
  91.  
  92.         -@ $greeting.*
  93.  
  94. Or, as the array element numbers are only 1 figure long:
  95.  
  96.         -@ $greeting.?
  97.  
  98. You should always deallocate used variables at the end of your scripts, as
  99. "dangling" variables will make script parsing slower and take up memory.
  100.  
  101. In addition, ViRC '96 0.34 and above support stored variables. These are like
  102. regular variables, except their values are stored in the registry, and hence
  103. are retained if V96 is closed down and then restarted. Define a stored
  104. variable exactly like a regular variable, except use @s instead of @. Undefine
  105. a stored variable by using -@s instead of -@. For example:
  106.  
  107.         @s $script_ver = YTooLZ for ViRC '96 version 4.91
  108.  
  109. The value of $script_ver will not be lost when V96 is closed down.
  110.  
  111. The third type of variable (new in V96 0.80) is the local variable. This type
  112. of variable is the recommended type to use inside your aliases and events.
  113. Local variables are only accessible from the scope that they were created in.
  114. In addition, you can have more than one local variable with the same name,
  115. provided they are in different scope blocks. ViRC '96's garbage collector
  116. automatically deallocates local variables when they fall out of scope - you
  117. cannot deallocate them yourself. Local variables are created with @l instead of
  118. @. Note that local array variables currently aren't supported, as I've found
  119. this to result in a large performance hit. Example:
  120.  
  121.         @l $x = hello
  122.  
  123. Here's a good example of where global (@) variables will not work, and you have
  124. to use locals. Just type /localtest, and observe the (correct, expected)
  125. output:
  126.  
  127. Alias LOCALTEST
  128.   for (@l $i = 0; $i < 10; $i++)
  129.     TextOut > . clBlue Variable $$i in LOCALTEST: $i
  130.     LocalLoop
  131.   endfor
  132. EndAlias
  133.  
  134. Alias LOCALLOOP
  135.   for (@l $i = 0; $i < 10; $i++)
  136.     TextOut > . clBlue Variable $$i in LOCALLOOP: $i
  137.   endfor
  138. EndAlias
  139.  
  140. This code will work correctly, despite the fact that two local variables called
  141. $i are used at the same time, as they are defined as local (@l) variables. If
  142. the @l was changed to @ to make them global variables, typing /localtest would
  143. produce incorrect output as the $i defined in LOCALTEST would be accessible in
  144. LOCALLOOP.
  145.  
  146. You can evaluate a numeric expression by enclosing it in $( and ). For example:
  147.  
  148.         @ $x = $(1+1)
  149.  
  150. As opposed to @ $x = 1+1, which will assign the string "1+1" to the variable
  151. $x, and so _WILL_NOT_WORK_.
  152.  
  153. You can evaluate expressions as complex as you want, including variables and
  154. functions, for example:
  155.  
  156.         @ $x = $((((16/2)*$strpos(xt $3-))+(18/$dfactor))-1)
  157.  
  158. $() is not required in if/while/for statements, as the conditions are evaluated
  159. numerically anyway.
  160.  
  161. In addition, V96 0.60 and above support the C-style ++ and -- operators. What's
  162. more, they're not just a pretty face - they execute a LOT, LOT faster than the
  163. equivalent code @ $i = $($i + 1), and are ideal for loops and things. For
  164. example, to increment $x by one, you could use:
  165.  
  166.         $x++
  167.  
  168. Please note that, unlike variable assignments, you DO NOT prefix this with an
  169. @. V96 0.80 and above support the C-style += and -= operators (BUT NOT *= and
  170. /= etc. yet), e.g.
  171.  
  172.         $x += 4
  173.         $y -= 16
  174.  
  175. Again, these are much faster than the equivalent @ $x = $($x + 4) etc.
  176. ViRCScript doesn't care about spacing when using any of these operators.
  177.  
  178. Pseudovariables (Pvars) are also supported in aliases and events. A typical
  179. Pvar looks like $0, or $7-, and represents a parameter supplied to the alias or
  180. event. $n means the n'th parameter. With events, the first word of the line of
  181. text received from the server is $0, the second word $1, and so on. With
  182. aliases, the alias command is $0, the first parameter supplied is $1, the
  183. second parameter supplied is $2, and so on. In addition, an expression like
  184. $2- means "the second parameter and all subsequent parameters". So, $2- is
  185. equal to $2 $3 $4 $5 $6 $7 $8 .... $n. More about this later.
  186.  
  187. V96 also maintains a number of built-in variables. These are as follows:
  188.  
  189.         $ver    The current version of V96, e.g. 0.60
  190.         $build  The current version V96 in integer form, e.g. 60
  191.         $N      Your nickname
  192.         $U      Your username
  193.         $H      Your hostname
  194.         $ip     Your IP address
  195.         $server The server you're connected to
  196.         $C      The channel the user types the alias in. If the alias
  197.                 is typed in a server window, $C is set to . (a period).
  198.                 If the alias is typed in a query window, $C contains the
  199.                 nick of the person you are querying.
  200.         $null   Equals nothing. Use to set variables to nothing, e.g.
  201.                 @ $x = $null
  202.  
  203. A number of constants are also maintained:
  204.  
  205.         \b      Bold
  206.         \u      Underline
  207.         \i      Italic
  208.         \A      ASCII character 1 -  (used for CTCPs)
  209.  
  210. Note that V96 supports a number of simultaneous server connections, even if
  211. you're on the same channel on both servers!! And you can have a different
  212. nickname on each server. So what nickname does $N correspond to? The answer is,
  213. the active context's nickname. If you use $N from an event, $N is the nickname
  214. on the server which caused the event. $N in an alias refers to the nickname of
  215. the current server connection relating to the window you typed the alias in.
  216. For example, $N in a channel window would be your nick on the server that
  217. you're on that channel on. Sounds confusing? Just use $N and it should work as
  218. you expect it to every time. =]
  219.  
  220. What about $+ you may ask. As most of you know, in mIRC, PIRCH etc. you need
  221. $+ to trim spaces ... in other words, you'd need something like this:
  222.  
  223.         *** $nick ( $+ $user $+ @ $+ $host $+ ) has joined channel $3
  224.  
  225. To display this:
  226.  
  227.         *** MeGALiTH (megalith@jimc.demon.co.uk) has joined channel #quake
  228.  
  229. In V96, spaces are not required before variables and functions, because of its
  230. intelligent parser. So you could do something like this, which looks much
  231. neater:
  232.  
  233.         *** $nick ($user@$host) has joined channel $3
  234.  
  235. The above would totally foul up mIRC and PIRCH. In fact, V96 doesn't care what
  236. you have before or after a variable. This would work:
  237.  
  238.         alkjdsjkadjka$nickjhdakajsdakjdhkjadhk
  239.  
  240. So, the skeptic asks, in this case, how does V96 know whether you want the
  241. variable $nick, $nickj, $nickjhdak, or what? The answer is, it reads your mind.
  242. Well, no, it doesn't - it actually sorts the variables alphabetically and
  243. parses them in reverse order (you what?!??!). This ends up with the right
  244. result. If a variable $nickjhd exists, then it'll parse the line as containing
  245. $nickjhd, otherwise it'll do $nickjh, and if that doesn't exist, $nickj ... and
  246. so on, all the way down to $n. So, again, as with the multiple-$N-on-multiple-
  247. servers thing I described above, V96 is intelligent enough to work out what
  248. you're trying to do, and do it correctly.
  249.  
  250. ViRCScript Statements
  251. =====================
  252.  
  253. TEXTOUT statement
  254. -----------------
  255.  
  256. Usage: TextOut [> window] <colour> <text ...>
  257.  
  258. Displays some text in a window. If the window name is left out, TextOut will
  259. output the text to all channel windows, unless there are none open, in which
  260. case the text will be displayed in the server window. Specifying a channel name
  261. will display the text in that channel (or the server window if the channel
  262. doesn't exist). Specifying . will output the text to the server notices window.
  263. Specifying anything else will create a query window with that name (if it
  264. doesn't already exist) and output the text there. You can use a query window
  265. created "on-the-fly" like this as a simple text output window for your scripts.
  266.  
  267. Colour may be specified in four ways.
  268.  
  269.         (1) Specifying a colour constant. The following colour constants
  270.             are supported (this will be familiar to Delphi 2.0 users):
  271.  
  272.             clBlack             Black
  273.             clMaroon            Maroon
  274.             clGreen             Green
  275.             clOlive             Olive green
  276.             clNavy              Navy blue
  277.             clPurple            Purple
  278.             clTeal              Teal
  279.             clGray              Gray
  280.             clSilver            Silver
  281.             clRed               Red
  282.             clLime              Lime green
  283.             clBlue              Blue
  284.             clFuchsia           Fuchsia
  285.             clAqua              Aqua
  286.             clWhite             White
  287.  
  288.             clBackground        Current color of your Windows background
  289.             clActiveCaption     Current color of the title bar of the active window
  290.             clInactiveCaption   Current color of the title bar of inactive windows
  291.             clMenu              Current background color of menus
  292.             clWindow            Current background color of windows
  293.             clWindowFrame       Current color of window frames
  294.             clMenuText          Current color of text on menus
  295.             clWindowText        Current color of text in windows
  296.             clCaptionText       Current color of the text on the title bar of the active window
  297.             clActiveBorder      Current border color of the active window
  298.             clInactiveBorder    Current border color of inactive windows
  299.             clAppWorkSpace      Current color of the application workspace
  300.             clHighlight         Current background color of selected text
  301.             clHightlightText    Current color of selected text
  302.             clBtnFace           Current color of a button face
  303.             clBtnShadow         Current color of a shadow cast by a button
  304.             clGrayText          Current color of text that is dimmed
  305.             clBtnText           Current color of text on a button
  306.             clInactiveCaptionText   Current color of the text on the title bar of an inactive window
  307.             clBtnHighlight      Current color of the highlighting on a button
  308.             cl3DDkShadow        Windows 95 only: Dark shadow for three-dimensional display elements
  309.             cl3DLight           Windows 95 only: Light color for three-dimensional display elements (for edges facing the light source)
  310.             clInfoText          Windows 95 only: Text color for tooltip controls
  311.             clInfoBk            Windows 95 only: Background color for tooltip controls
  312.  
  313.             The second half of the colors listed here are Windows system
  314.             colors. The color that appears depends on the color scheme users
  315.             are using for Windows. Users can change these colors using the
  316.             Control Panel in Program Manager. The actual color that appears
  317.             will vary from system to system. For example, the color fuchsia
  318.             may appear more blue on one system than another.
  319.  
  320.             For example, to output some blue text in the server window:
  321.  
  322.                 TextOut > . clBlue blah blah blah ...
  323.  
  324.         (2) Specifying an event colour constant. Event colour constants
  325.             correspond to the colour of the corresponding event type the user
  326.             has selected in Client setup/Colours and fonts. This allows scripts
  327.             that you write to automatically adjust to the colours the user
  328.             wants. The following event colour constants are available.
  329.  
  330.             ecJOIN              Join colour
  331.             ecPART              Part colour
  332.             ecQUIT              Quit colour
  333.             ecTOPIC             Topic change colour
  334.             ecMODE              Mode change colour
  335.             ecKICK              Kick colour
  336.             ecPRIVMSG           Private message colour
  337.             ecNOTICE            Notice colour
  338.             ecCTCP              CTCP colour
  339.             ecACTION            Action colour
  340.             ecNICK              Nick change colour
  341.             ecMyChanText        Colour of channel text the user has entered himself
  342.             ecChanText          Colour of channel text other users have entered
  343.             ecMyQueryText       Colour of query text the user has entered himself
  344.             ecQueryText         Colour of query text other users have entered
  345.             ecServText          Colour of server text
  346.             ecError             Colour of error text
  347.             ecScript or ecXDCC  Colour of script (e.g. XDCC) status messages
  348.  
  349.             For example:
  350.  
  351.                 TextOut ecKICK This text will appear in the same colour as channel kicks do.
  352.  
  353.         (3) Specifying a hex RGB value, in the form $bbggrr.
  354.  
  355.  
  356.             For example:
  357.  
  358.                 TextOut $0000FF This text is red.
  359.                 TextOut $00FF00 This text is green.
  360.                 TextOut $FF0000 This text is blue.
  361.                 TextOut $00FFFF This text is yellow.
  362.                 TextOut $FFFFFF This text is white.
  363.                 TextOut $000000 This text is black.
  364.  
  365.         (4) Specifying a decimal RGB value. This is rather useless, unless
  366.             you're specifying the text colour as a random number, e.g.
  367.  
  368.                 TextOut $rand($FFFFFF) This text appears in a random colour.
  369.  
  370. New in 0.80, with ObjectViRCScript, you can also specify the handle of a
  371. TRichEdit object you have created (see OBJECTVS.TXT) to output text to that
  372. TRichEdit control. However, in order for TextOut to recognize the handle as
  373. an ObjectViRCScript object handle, it must be preceded with %. Example to
  374. create a form with a TRichEdit on it and write some text to it (BTW, the
  375. @p $edit.Align = 5 line simply makes the TRichEdit automatically fill the form,
  376. so there's no need to specify a size initally by setting the Left, Top etc.
  377. properties. Align = 5 corresponds to Delphi's Align = alClient. You'll be able
  378. to specify the properties by textual name shortly, but for now you'll just have
  379. to fiddle with the numbers until you get the effect you want!!):
  380.  
  381. @ $form = $new(TForm)
  382. @p $form.Left = 20
  383. @p $form.Top = 20
  384. @p $form.Width = 300
  385. @p $form.Height = 300
  386. @p $form.Visible = 1
  387.  
  388. @ $edit = $new(TRichEdit ownedby $form)
  389. @p $edit.Align = 5
  390. @p $edit.Visible = 1
  391.  
  392. TextOut > %$edit clBlue This text will appear in \bblue\b!!
  393. TextOut > %$edit clRed This text will appear in \bred\b!!
  394.  
  395. IF/ELSE/ENDIF statements
  396. ------------------------
  397.  
  398. Usage: if (condition)
  399.           ...
  400.        [else]
  401.           [...]
  402.        endif
  403.  
  404. Executes a block of code only if a given condition is true. Multiple conditions
  405. can be specified, and are separated with && (boolean AND) or || (boolean OR)
  406. operators. If the condition is false and an ELSE block exists, this code is
  407. executed. The following operators are supported:
  408.  
  409.         Op  | Meaning
  410.       ------+--------------------------
  411.         ==  | Equal to
  412.         === | Strong (exact) comparison (same as == only case-sensitive when comparing strings)
  413.         !=  | Not equal to
  414.         >   | Greater than
  415.         <   | Less than
  416.         >=  | Greater than or equal to
  417.         <=  | Less than or equal to
  418.         +   | Plus
  419.         -   | Minus
  420.         *   | Multiply
  421.         /   | Divide
  422.         ^^  | Power
  423.         &&  | Boolean AND
  424.         ||  | Boolean OR
  425.         !   | Boolean NOT
  426.  
  427. If you're used to C, you'll have no problems. Expressions can be as simple or
  428. as complex as you like - you can nest many levels of brackets if you need to.
  429.  
  430. IF can be used to compare numeric expressions or string expressions. All string
  431. expressions must be enclosed in []'s, just as in ircII.
  432.  
  433. Numeric expression example:
  434.  
  435.         if (2+3 == 5)
  436.            TextOut clBlue Of course it does!!
  437.         endif
  438.  
  439. String expression example:
  440.  
  441.         if ([hello] == [goodbye])
  442.            TextOut clBlue Not unless the laws of physics have changed.
  443.         endif
  444.  
  445. Boolean operators may also be used. && = and, || = or, ! = not.
  446.  
  447.         if (2+3 == 5) && (4*2 == 8)
  448.            TextOut clBlue Naturally.
  449.         endif
  450.  
  451. In fact, you'll rarely have to use the ! operator. You'll see that the
  452. following two statements are equivalent:
  453.  
  454.         if ([$x] != [$y])
  455.         if !([$x] == [$y])
  456.  
  457. Note that spaces are not required (they are ignored by the parser), but may be
  458. included for clarity. For example:
  459.  
  460.         if (2+3==5)&&(10*17==170)&&((5>=2)||(9=16))
  461.  
  462. That's perfectly correct, but impossible to read ;). Adding spaces makes the
  463. statement far clearer:
  464.  
  465.         if (2+3 == 5) && (10*17 == 170) && ((5 >= 2) || (9 == 16))
  466.  
  467. You must enclose string expressions in []'s. This prevents V96 from trying to
  468. numerically evaluate the text between the [ and the ]. For example:
  469.  
  470.         if ([$nick] == [hello])
  471.            TextOut clBlue Blah!!
  472.         endif
  473.  
  474. An ELSE construction is supported too.
  475.  
  476.         @ $x = $?="What does IRC stand for?"
  477.         if ([$x] == [Internet Relay Chat])
  478.            TextOut clGreen Well done!!
  479.         else
  480.            TextOut clRed Wrong!!
  481.         endif
  482.  
  483. WHILE/ENDWHILE statements
  484. -------------------------
  485.  
  486. Usage: while [optimized] (condition)
  487.          ...
  488.        endwhile
  489.  
  490. Executes a block of code while condition is true. If condition is false
  491. initially, the while block will be skipped. See the IF/ELSE/ENDIF statement for
  492. details on how to specify conditions. Beware, as a condition that's always true
  493. will produce an infinite loop and will lock V96 up!! For example:
  494.  
  495.         while (1)
  496.         endwhile
  497.  
  498. In fact, now ViRCScript has a C-like for statement, while is largely
  499. superflous. In fact:
  500.  
  501.         while (condition)
  502.           ...
  503.         endwhile
  504.  
  505. Is functionally-identical to:
  506.  
  507.         for (;condition;)
  508.           ...
  509.         endfor
  510.  
  511. The for statement is used only with a condition, with no initial statement and
  512. no increment statement.
  513.  
  514. In V96 0.82 and above, the new OPTIMIZED keyword is supported. You can use it
  515. like this:
  516.  
  517. while optimized ($i <= 10000)
  518.   $i++
  519. endwhile
  520.  
  521. OPTIMIZED enables specific optimizations which cause tight loops (containing
  522. only one instruction, in this case $j++) to execute around 20% faster. V96 will
  523. check that the loop contains only one instruction if you specify OPTIMIZED, and
  524. if it does not, the keyword will be ignored.
  525.  
  526. You can use all regular commands and functions in an OPTIMIZED while loop
  527. except for HALT, BREAK, CONTINUE, FALLTHROUGH, YIELD, and TEXTOUT. Usage of
  528. these commands in an OPTIMIZED loop may cause undefined (and possibly erratic)
  529. problems.
  530.  
  531. FOR/ENDFOR statements
  532. ---------------------
  533.  
  534. Usage: for [optimized] (initial statement;condition;increment statement)
  535.          ...
  536.        endfor
  537.  
  538. V96's for statement behaves exactly like the for statement in C/C++, so you
  539. should have no problems. For example, the following C code:
  540.  
  541.         for (int i = 0; i < 10; i++)
  542.           printf("%d", i);
  543.  
  544. Is equivalent to the following ViRCScript code:
  545.  
  546.         for (@ $i = 0; $i < 10; $i++)
  547.           TextOut clBlue $i
  548.         endfor
  549.  
  550. (Note the use of the new ++ operator here!!)
  551.  
  552. Note that variables created by the for statement (e.g. the $i above) are not
  553. deallocated at the end, so the following statement should really be added to
  554. the end of the above code fragment:
  555.  
  556.         -@ $i
  557.  
  558. The for and while statements are often interchangable. In fact:
  559.  
  560.         for (x;y;z)
  561.           ...
  562.         endfor
  563.  
  564. Is equivalent to:
  565.  
  566.         x
  567.         while (y)
  568.           ...
  569.           z
  570.         endwhile
  571.  
  572. However, usage of for is much neater in many cases than while. Note that, just
  573. like C, misuse of for can lock the system up!! Compare the following C
  574. fragment:
  575.  
  576.         for (;;)
  577.           ...
  578.  
  579. And the following ViRCScript:
  580.  
  581.         for (;;)
  582.           ...
  583.         endfor
  584.  
  585. Both will lock the system up in an infinite loop (unless, of course, a BREAK
  586. or HALT statement is used somewhere in the loop). So be careful!!
  587.  
  588. In V96 0.82 and above, the new OPTIMIZED keyword is supported. You can use it
  589. like this:
  590.  
  591. for optimized (@ $i = 1; $i <= 10000; $i++)
  592.   $j++
  593. endfor
  594.  
  595. OPTIMIZED enables specific optimizations which cause tight loops (containing
  596. only one instruction, in this case $j++) to execute around 20% faster. V96 will
  597. check that the loop contains only one instruction if you specify OPTIMIZED, and
  598. if it does not, the keyword will be ignored.
  599.  
  600. You can use all regular commands and functions in an OPTIMIZED for loop except
  601. for HALT, BREAK, FALLTHROUGH, YIELD, and TEXTOUT. Usage of these commands in an
  602. OPTIMIZED loop may cause undefined (and possibly erratic) problems.
  603.  
  604. ALIAS/ENDALIAS statements
  605. -------------------------
  606.  
  607. Usage: alias <name> [hotkey]
  608.          ...
  609.        endalias
  610.  
  611. Defines an alias (similar to a procedure or function in other languages).
  612. The parameters of the alias are passed in as $1, $2, $3 and so on, and the
  613. actual alias command itself is passed in as $0. The channel window the alias is
  614. typed in is passed in as $C. $C is set to . if the alias is run from the server
  615. notices window. Optionally, hotkey may be specifed (e.g. F3, or Ctrl+Shift+Z).
  616. When hotkey is pressed, the alias will be executed as if it were typed in the
  617. current window.
  618.  
  619. Aliases can be very useful, for example, consider this:
  620.  
  621.         Alias GO
  622.           Connect
  623.           Join #quake
  624.           Msg Bot !op
  625.           Mode #quake +ooo User1 User2 User3
  626.           Part #quake
  627.           Quit
  628.         EndAlias
  629.  
  630. When the user types /go, V96 will connect to the server, join #quake, /msg Bot
  631. for ops, op User1, User2 and User3, leave #quake, and quit IRC. Aliases can
  632. also be used as functions. Simply assign a value to $fresult as the value of
  633. the function. For example, consider this, a function to pick and return a
  634. random boolean value, either True or False:
  635.  
  636.         Alias RANDBOOL
  637.           @ $x = $rand(2)
  638.           if ($x == 1)
  639.              @ $fresult = True
  640.           else
  641.              @ $fresult = False
  642.           endif
  643.         EndAlias
  644.  
  645. Now:
  646.  
  647.         TextOut clBlue Random boolean expression: $randbool()
  648.  
  649. Another use for aliases is executing frequently-used single commands. For
  650. example, say you're on #quake, and are frequently asked what the current
  651. version of Quake is. You could make an alias like this:
  652.  
  653.         Alias QUAKEVER
  654.           Say $C $1: The current version of Quake is 1.01.
  655.         EndAlias
  656.  
  657. Then, for example, if Dnormlguy asked what the latest version of Quake was,
  658. in the #quake channel window, you could just type /quakever Dnormlguy. V96
  659. would expand $C to #quake, and $1 to the first parameter, Dnormlguy. So, the
  660. text "Dnormlguy: The current version of Quake is 0.92" to the channel.
  661.  
  662. UNALIAS command
  663. ---------------
  664.  
  665. Usage: UnAlias alias [alias ...]
  666.  
  667. Removes one or more aliases. For example, this removes the 3 aliases OP, DEOP
  668. and J.
  669.  
  670.         UnAlias OP DEOP J
  671.  
  672.  
  673. EVENT/ENDEVENT statements (read!! This is changed!!)
  674. ----------------------------------------------------
  675.  
  676. Usage: event <name> "<mask>"
  677.          ...
  678.        endevent
  679.  
  680. Defines an event. Events are the most powerful feature of VS, although also the
  681. hardest to grasp (although this has largely been alleviated now that event
  682. priorities have been removed). The best way to get a feel for events is to look
  683. through V96's built-in events and see how they work.
  684.  
  685. Name is just an arbitrary name to assign to the event. You can call events
  686. anything you like. Mask is the text that must be received from the server to
  687. trigger the event, and can include wildcards.
  688.  
  689. Parameters are passed into the event with the first word received from the
  690. server as $0, the second word as $1, etc. In addition, the sender of the
  691. message's nick is stored in $nick, the username in $user, and the hostname
  692. in $host. If the message originates from the server, $nick is the server, and
  693. $user and $host are empty. Example:
  694.  
  695.         :greygoon!bhess@wilma.widomaker.com NOTICE MeGALiTH :You're not opped!!
  696.  
  697. This is what the server sends when greygoon sends the notice
  698. "You're not opped!!" to MeGALiTH. So, the parameter breakdown would be as
  699. follows:
  700.  
  701.         $0      :greygoon!bhess@wilma.widomaker.com
  702.         $1      NOTICE
  703.         $2      MeGALiTH
  704.         $3      :You're
  705.         $4      not
  706.         $5      opped!!
  707.  
  708.         $nick   greygoon
  709.         $user   bhess
  710.         $host   wilma.widomaker.com
  711.  
  712. Thus the activation mask for a NOTICE is "* NOTICE *". This basically means:
  713. $0 can be anything, $1 must be NOTICE, and $2 can be anything. Any parameters
  714. that are not supplied can be anything - in fact, the * at the end of the mask
  715. is not really necessary, but is included for clarity.
  716.  
  717. More specific masks are executed in preference to less specific masks. For
  718. example, the following event statements are used for private and channel
  719. messages.
  720.  
  721.         Private messages:
  722.  
  723.            Event PrivateMessage "* PRIVMSG *"
  724.  
  725.         Channel messages:
  726.  
  727.            Event ChannelMessage "* PRIVMSG #*"
  728.  
  729. A typical private message received from the server may look like this:
  730.  
  731.         :nick!user@host PRIVMSG YourNick :hello!!
  732.  
  733. A typical channel message might look like this:
  734.  
  735.         :nick!user@host PRIVMSG #quake :hello all!!
  736.  
  737. Therefore, if V96 gets a channel message, the PrivateMessage event is NOT
  738. executed, even though the mask matches, because there's a more specific event
  739. mask that matches, namely ChannelMessage.
  740.  
  741. Note that the <default> event (mask *), which is fired for every line of server
  742. text that is received, is only executed if NO OTHER EVENTS have a mask which
  743. matches the line of server text.
  744.  
  745. In 0.80 and above, event templates are supported. This means that you can use
  746. masks from other events as templates for your own masks, which makes the
  747. events clearer. You use another event mask as a template by putting the name
  748. of the event in ()'s at the beginning of your own mask. For example, the CTCP
  749. event mask is as follows:
  750.  
  751.         * PRIVMSG * :\A*
  752.  
  753. Therefore, if you wanted to make an event that responded to CTCP HELLO, you
  754. could do:
  755.  
  756.         Event CTCPHello "(CTCP)HELLO"
  757.  
  758. V96 would expand the mask (CTCP)HELLO to ...
  759.  
  760.         * PRIVMSG * :\A*HELLO
  761.  
  762. ... which is the correct mask to do what you want. In addition, if you wish to
  763. redefine an event without changing the mask, you could always use the event
  764. mask itself as a mask template, for example:
  765.  
  766.         Event PrivateMessage "(PrivateMessage)"
  767.           ... code for new PrivateMessage event ...
  768.         EndEvent
  769.  
  770. Events that begin with < (with the exception of <default>) are NEVER fired by
  771. events from the server, even if the masks match. You can thus create your own
  772. <On_xxx> events which you can fire manually from code with the FIREEVENT
  773. command.
  774.  
  775. Built-in events
  776. ---------------
  777.  
  778. V96 has a number of built-in events. They are:
  779.  
  780.         <OnConnect> - fired when connected to a server
  781.                       $0 = server name
  782.  
  783.         <OnDisconnect> - fired when disconnected from a server
  784.                          $0 = server name
  785.  
  786.         <OnNotifyJoin> - fired when a user in the notify list joins IRC
  787.                          $0 = nick of user who joined
  788.  
  789.         <OnNotifyQuit> - fired when a user in the notify list leaves IRC
  790.                          $0 = nick of user who left
  791.  
  792.         <OnNewInactiveText> - fired when next is added to an inactive window
  793.                               $0 = 1 if first new line, 0 for subsequent lines
  794.                               $1 = window type (SERVER, CHANNEL, QUERY, or DCC)
  795.                               $2 = window name (e.g. #quake, MeGALiTH, etc).
  796.  
  797.         <OnDCCChatConnect> - fired when a DCC Chat session connects
  798.                              $0 = nick of user who chat connection is with
  799.  
  800.         <OnDCCChatDisconnect> - fired when a DCC Chat session disconnects
  801.                                 $0 = nick of user who chat connection is with
  802.  
  803.         <OnDCCSendConnect> - fired when a DCC Send session connects
  804.                              $0 = nick of user you're sending the file to
  805.                              $1 = filename of file you're sending
  806.  
  807.         <OnDCCSendDisconnect> - fired when a DCC Send session disconnects
  808.                                 $0 = nick of user you're sending the file to
  809.                                 $1 = filename of file you're sending
  810.                                 $2 = 1 if transfer complete, 0 if transfer aborted
  811.  
  812.         <OnDCCGetConnect> - fired when a DCC Send session connects
  813.                             $0 = nick of user you're getting the file from
  814.                             $1 = filename of file you're receiving
  815.  
  816.         <OnDCCGetDisconnect> - fired when a DCC Send session disconnects
  817.                                $0 = nick of user you're getting the file from
  818.                                $1 = filename of file you're receiving
  819.                                $2 = 1 if transfer complete, 0 if transfer aborted
  820.  
  821.         <OnStart>            - fired when ViRC '96 starts up
  822.  
  823.         <OnClose>            - fired when ViRC '96 closes down
  824.  
  825. IMPORTANT NOTE: In 0.82 and later versions of V96, you can define multiple,
  826. individual events for each of the above. This is done by calling the events
  827. <OnXXXX_text>. For example, if you wanted several <OnStart> events, you could
  828. define them as <OnStart_1>, <OnStart_2> etc., and they would each be called
  829. correctly. If you are defining these events in a script, it is STRONGLY
  830. RECOMMENDED that you give these events a unique name, so that it doesn't
  831. interfere with the operation of any other scripts, for example, you could call
  832. an event <OnStart_XYZScript> or <OnDCCGetConnect_XYZScript> if you're writing
  833. a script called XYZScript.
  834.  
  835. UNEVENT command
  836. ---------------
  837.  
  838. Usage: UnEvent event [event ...]
  839.  
  840. Removes one or more events. For example, this removes the 2 events JOIN and
  841. PART:
  842.  
  843.         UnEvent JOIN PART
  844.  
  845. PARSE/ENDPARSE statements
  846. -------------------------
  847.  
  848. Usage: parse text
  849.         ...
  850.        endparse
  851.  
  852. Parses text into the pseudovariables $0 to $9 for the duration of the parse
  853. block. Without doubt one of the most powerful commands in ViRCScript. Its use
  854. is best illustrated by an example:
  855.  
  856.         @ $x = This is a test.
  857.         Parse $x
  858.           TextOut clBlue $0 $1 $2 $3
  859.           TextOut clBlue $3 $2 $1 $0
  860.         EndParse
  861.  
  862. The following will appear on the screen:
  863.  
  864.         This is a test.
  865.         test. a is This
  866.  
  867. The values of the pseudovariables are restored to their previous state at the
  868. end of the parse block. So, they are only valid between Parse and EndParse.
  869. You must assign them to other variables if you want to use them outside the
  870. parse block. You may nest as many parse blocks within each other as you like.
  871.  
  872. What in reality could this be used for? One idea is a #chaos-type question
  873. game, You have a file called QUESTION.TXT which contains questions and answers
  874. in the form:
  875.  
  876.         answer question ...
  877.         answer question ...
  878.         answer question ...
  879.  
  880. And so on. You want some code to pick a random question from the file, putting
  881. the question in $question and the answer in $answer. The following code would
  882. do the trick:
  883.  
  884.         @ $x = $randomread(question.txt)
  885.         Parse $x
  886.           @ $answer = $0
  887.           @ $question = $1-
  888.         EndParse
  889.  
  890. MENUTREE/ENDMENUTREE command
  891. ----------------------------
  892.  
  893. Usage: menutree menutype
  894.          [item1]
  895.          [item2]
  896.          ...
  897.        endmenutree
  898.  
  899. Defines the menu tree for menutype. This command is used to define the
  900. structure of a menu or popup, before code is assigned to each item. The
  901. following values for menutype are currently recognized:
  902.  
  903.      MT_MAINMENU     - define the tree for the main menu
  904.      MT_SERVERPOPUP  - define the tree for the server window popup
  905.      MT_CHANNELTEXT  - define the tree for the channel window text pane popup
  906.      MT_CHANNELNICKS - define the tree for the channel window names pane popup
  907.  
  908. Each item defined between MenuTree and EndMenuTree takes the following format:
  909.  
  910.      ItemName HotKey State Depth Text
  911.  
  912. ItemName is an arbitrary name to give to the menu item. The name will be used
  913. again later to define the code when you click on the menu item. HotKey defines
  914. what hotkey to activate the menu item on. HotKey can be something like F12 or
  915. Ctrl+Shift+A, or <none> if you don't require a hotkey. Note that HotKey is
  916. ignored for menus other than MT_MAINMENU. State determines the menu item's
  917. state. For menu types MT_MAINMENU and MT_SERVERPOPUP, State can take the
  918. following values:
  919.  
  920.         0 - Menu item is enabled
  921.         1 - Menu item is enabled when you're connected to the server, and
  922.             disabled otherwise
  923.         2 - Menu item is disabled when you're connected to the server, and
  924.             enabled otherwise
  925.         3 - Menu item is disabled
  926.  
  927. For menu types MT_CHANNELTEXT and MT_CHANNELNICKS, State can take the following
  928. values:
  929.  
  930.         0 - Menu item is enabled
  931.         1 - Menu item is enabled when you're opped on this channel, and
  932.             disabled otherwise
  933.         2 - Menu item is disabled when you're opped on this channel, and
  934.             enabled otherwise
  935.         3 - Menu item is disabled
  936.  
  937. Depth defines the "depth" of the menu item. For MT_MAINMENU, a depth of 0
  938. represents an entry on the top menu bar. A depth of 1 is a subitem of the
  939. closest item above which has a depth of 0. A depth of 2 is a subitem of the
  940. closest item above that has a depth of 1.
  941.  
  942. Text is the actual text to display on the menu. If an & is present in Text,
  943. you can pull the menu down quickly by pressing Alt and the letter after the &.
  944.  
  945. Here are some example menu tree items, taken from DEFAULT.LIB:
  946.  
  947.   M_FILE       <none> 0 0 &File
  948.   M_NEWCONNECT Ctrl+K 0 1 &New connection ...
  949.   M_SETUP      <none> 0 1 Client s&etup ...
  950.   M_FSEP1      <none> 0 1 -
  951.   M_EXIT       Alt+X  0 1 E&xit
  952.   M_TOOLS      <none> 0 0 &Tools
  953.   M_FINGER     Ctrl+F 0 1 UNIX &finger ...
  954.  
  955. Hopefully by comparing this with what you actually see in the program will
  956. enable you to understand the significance of each field.
  957.  
  958. MENUITEM/ENDMENUITEM command
  959. ----------------------------
  960.  
  961. Usage: menuitem ItemName on MenuType
  962.  
  963. Defines the ViRCScript code to trigger when the user clicks on the menu item
  964. Name on the menu type MenuType. MenuType can take the same values here as with
  965. the MenuTree command detailed above. In the above example, one of the item
  966. lines between MenuTree and EndMenuTree is:
  967.  
  968.   M_NEWCONNECT Ctrl+K 0 1 &New connection ...
  969.  
  970. To define the ViRCScript code to actually make this open a new server window,
  971. you would use:
  972.  
  973.         MenuItem M_NEWCONNECT on MT_MAINMENU
  974.           NewServerWindow
  975.         EndMenuItem
  976.  
  977. For a good example of how this works, see DEFAULT.LIB.
  978.  
  979. Menu items on a MenuType of MT_CHANNELNICKSPOPUP are supplied with the nickname
  980. selected in the names pane of the currently-active channel window as the
  981. parameter $1. For example:
  982.  
  983.         MenuItem M_HELLO on MT_CHANNELNICKSPOPUP
  984.           Say $C Hello, $1!!
  985.         EndMenuItem
  986.  
  987. If the user clicks on abc123's nick in a channel window, and then right-clicks
  988. and selects M_HELLO from the popup menu, the text "Hello, abc123!!" will be
  989. said to the channel.
  990.  
  991. UPDATEMENUS command
  992. -------------------
  993.  
  994. Usage: updatemenus
  995.  
  996. Recreates all menus and popups from the in-memory menu trees and writes the
  997. trees to the registry. After you have changed menu(s) with MenuTree and
  998. MenuItem statements, you must use this command for your changes to take effect
  999. properly. Failure to execute this command when you've finished altering the
  1000. menus can cause unwanted side-effects, as the in-memory menu trees and the
  1001. actual menus and popups become desynchronized from each other.
  1002.  
  1003. NAME statement
  1004. --------------
  1005.  
  1006. Usage: name text
  1007.  
  1008. Names your script text. This isn't really a statement at all. It's used by the
  1009. script loader to display your script's name in the loading progress dialog box.
  1010. It's recommended you use NAME to give your script a sensible name at the top of
  1011. the file, so people know what they're loading.
  1012.  
  1013. MESSAGEBOX command
  1014. ------------------
  1015.  
  1016. Usage: MessageBox text
  1017.  
  1018. Displays a message box on the screen with an OK button, with text as its
  1019. contents. Use this in scripts to inform the user of something.
  1020.  
  1021. CREATEFILE command
  1022. ------------------
  1023.  
  1024. Usage: CreateFile filename
  1025.  
  1026. Creates filename, or truncates it to 0 bytes if it already exists.
  1027.  
  1028. APPENDTEXT command
  1029. ------------------
  1030.  
  1031. Usage: AppendText filename text
  1032.  
  1033. Appends text to the end of filename. In V96 0.80 and above, filename will be
  1034. created if it doesn't already exist.
  1035.  
  1036. MKDIR command
  1037. -------------
  1038.  
  1039. Usage: MkDir dir
  1040.  
  1041. Makes a directory called dir.
  1042.  
  1043. CHDIR command
  1044. -------------
  1045.  
  1046. Usage: ChDir dir
  1047.  
  1048. Changes to the dir directory.
  1049.  
  1050. RMDIR command
  1051. -------------
  1052.  
  1053. Usage: RmDir dir
  1054.  
  1055. Removes the dir directory.
  1056.  
  1057. SETINPUTLINE command
  1058. --------------------
  1059.  
  1060. Usage: SetInputLine channel text
  1061.  
  1062. Sets the command entry box's contents of channel to text. If you wish to set
  1063. the contents of the server window's entry box, specify . as channel (a period).
  1064.  
  1065. EVAL command
  1066. ------------
  1067.  
  1068. Usage: Eval command
  1069.  
  1070. Normally, commands are evaluated before executing them. Placing EVAL before a
  1071. command line causes the line to be evaluated twice before executing. You'd
  1072. probably never have to use this in your scripts, except when evaluating
  1073. expressions that are stored somewhere else, for example, a line in a file.
  1074. To get a random line from a file, evaluate that line, and store in $x, you'd
  1075. use:
  1076.  
  1077.         Eval @ $x = $randomread(filename.txt)
  1078.  
  1079. BREAK command
  1080. -------------
  1081.  
  1082. Usage: Break [if condition]
  1083.  
  1084. Quits from the currently-executing code block. A code block is something like
  1085. the code between if/endif, while/endwhile, parse/endparse etc. If this
  1086. statement is executed outside a code block, execution of your script routine
  1087. will stop (see the HALT command). If a BREAK statement is encountered inside
  1088. a FOR or WHILE loop, control will immediately be transferred out of the loop.
  1089.  
  1090. If a condition is specified, the break will only occur if the condition is
  1091. met, for example, the following code will print 0, 1, 2, 3 and 4 in the server
  1092. window:
  1093.  
  1094.         for (@l $i = 0; $i <= 10; $i++)
  1095.           Break if ($i == 5)
  1096.           TextOut > . clBlue $i
  1097.         endfor
  1098.  
  1099. CONTINUE command
  1100. ----------------
  1101.  
  1102. Usage: Continue [if condition]
  1103.  
  1104. Only used within FOR and WHILE blocks, CONTINUE causes the next iteration of
  1105. the loop to begin immediately, without finishing the current iteration.
  1106.  
  1107. If a condition is specified, the continue will only occur if the condition is
  1108. met, for example, the following code will print 0, 1, 2, 3, 4, 6, 7 and 8 in
  1109. the server window:
  1110.  
  1111.         for (@l $i = 0; $i <= 10; $i++)
  1112.           Continue if ($i == 5)
  1113.           TextOut > . clBlue $i
  1114.         endfor
  1115.  
  1116. HALT command
  1117. ------------
  1118.  
  1119. Usage: Halt [if condition]
  1120.  
  1121. Similar to the BREAK command, only exits from ALL code blocks and terminates
  1122. execution of your script. As with BREAK, an optional condition can be
  1123. specified, and the HALT will only occur if the condition is met.
  1124.  
  1125. FALLTHROUGH command
  1126. -------------------
  1127.  
  1128. Usage: FallThrough
  1129.  
  1130. This powerful command makes event programming much easier. If you've defined a
  1131. special event, but you only want it to execute sometimes, and the rest of the
  1132. time you want the system to behave as if the event was never defined, you can
  1133. use the FallThrough statement to pass the event down to a handler of lower
  1134. priority. A good example is if you're writing, for example, a channel
  1135. statistics script, which catches WHO replies (* 352 *) and processes them,
  1136. without displaying them in the server notices window. However, if the user has
  1137. not typed /chanst, then the regular <default> event should be executed to
  1138. display the WHO on the screen in the normal way. The event would be defined
  1139. like this:
  1140.  
  1141. Event ChanStatWHOReply 5 "* 352 *"
  1142.   if ($doingchanst)
  1143.      ...
  1144.   else
  1145.      FallThrough
  1146.   endif
  1147.  
  1148. YIELD command
  1149. -------------
  1150.  
  1151. Usage: Yield
  1152.  
  1153. Polls the Windows message queue and processes waiting messages. If you're
  1154. writing a script that uses a while loop that takes a long time to execute, it
  1155. may be a good idea to use YIELD to prevent the system from locking up while
  1156. your script is executing. For example, the following will lock V96 up:
  1157.  
  1158.         while (1)
  1159.         endwhile
  1160.  
  1161. However, the following will not lock V96 up, although it'll slow it down a
  1162. little because it is actually executing the while loop over and over again,
  1163. ad infinitum:
  1164.  
  1165.         while (1)
  1166.           Yield
  1167.         endwhile
  1168.  
  1169. The YIELD command is very useful when implementing background processing.
  1170. Adding a YIELD statement to a time-consuming for loop will allow other tasks to
  1171. continue running in the background while the for loop executes.
  1172.  
  1173. IMPORTANT NOTE!! Things can happen while Yield is executing. Even other VS code
  1174. can execute (e.g. if an event occurs during the Yield statement). Therefore,
  1175. you CANNOT assume that variables like $C will retain their value after
  1176. executing Yield, as another VS code section may have changed them. Therefore,
  1177. always save things like $C to your own variables (e.g. $chan) before executing
  1178. Yield if you wish to ensure that the variables don't change from underneath
  1179. your feet.
  1180.  
  1181. BEEP command
  1182. ------------
  1183.  
  1184. Usage: Beep
  1185.  
  1186. The name says it all. ;) Produces a standard Windows beep.
  1187.  
  1188. SETFOCUS command
  1189. ----------------
  1190.  
  1191. Usage: SetFocus window
  1192.  
  1193. Sets focus to window. window can be . to set the focus to the server notices
  1194. window, a channel name, or a nick (query window).
  1195.  
  1196. MIN command
  1197. -----------
  1198.  
  1199. Usage: Min window
  1200.  
  1201. Minimizes window. window can be . to set the focus to the server notices
  1202. window, a channel name, or a nick (query window).
  1203.  
  1204. MAX command
  1205. -----------
  1206.  
  1207. Usage: Max window
  1208.  
  1209. Maximizes window. window can be . to set the focus to the server notices
  1210. window, a channel name, or a nick (query window).
  1211.  
  1212. RESTORE command
  1213. ---------------
  1214.  
  1215. Usage: Restore window
  1216.  
  1217. Restores window. window can be . to set the focus to the server notices window,
  1218. a channel name, or a nick (query window).
  1219.  
  1220. CLOSE command
  1221. -------------
  1222.  
  1223. Usage: Close window
  1224.  
  1225. Closes window. window can be . to set the focus to the server notices window,
  1226. a channel name, or a nick (query window).
  1227.  
  1228. DDE command
  1229. -----------
  1230.  
  1231. Usage: DDE service topic "item" text
  1232.  
  1233. Suntactically identical to mIRC's command of the same name. Connects to a DDE
  1234. server using the details supplied and sends text by DDE. This command can also
  1235. be used as a function, i.e. $dde(service topic "item" text), and will return
  1236. any data received from the DDE server as a result of the DDE command.
  1237.  
  1238. SAY command
  1239. -----------
  1240.  
  1241. Usage: Say channel text
  1242.  
  1243. Sends the message text to channel. Use in scripts to send text to a channel. I
  1244. believe this has been undocumented since around 0.30. =]
  1245.  
  1246. REHASHREGISTRY command
  1247. ----------------------
  1248.  
  1249. Usage: RehashRegistry
  1250.  
  1251. Makes V96 reload all its settings from the registry. If you're writing a
  1252. program which modifies any of the in-registry settings while V96 is running,
  1253. the program should send a RehashRegistry command to V96 via DDE (see
  1254. VIRCDDE.TXT) to make V96 reload everything from the registry.
  1255.  
  1256. SIMULATESERVERDATA command
  1257. --------------------------
  1258.  
  1259. Usage: SimulateServerData text
  1260.  
  1261. Puts text directly into ViRC '96's received data buffer, making V96 behave as
  1262. if text was received from the server. This is very useful as it allows you to
  1263. test new events you've written offline, and, possibly more usefully, to simply
  1264. make DCC connections to a certain IP address and port from a script. In clients
  1265. like mIRC which don't have this function, you have to send a CTCP to yourself,
  1266. but this isn't a good idea as you have to wait for the request to come back,
  1267. which is subject to server lag, and won't work if you're not connected to an
  1268. IRC server. This command can get around that. For example:
  1269.  
  1270.         SimulateServerData :test!virc@megalith.co.uk PRIVMSG blah :This is a test!!
  1271.  
  1272. This would make it appear exactly as if you received a private message from
  1273. a user whose nick is test and whose email address is virc@megalith.co.uk. There
  1274. is no way to differentiate between real and simulated server events in your
  1275. scripts.
  1276.  
  1277. FIREEVENT command
  1278. -----------------
  1279.  
  1280. Usage: FireEvent event parameters
  1281.  
  1282. Fires event with parameters. This can either be used to pretend that an event
  1283. was fired by ViRC '96, for example:
  1284.  
  1285.         FireEvent <OnConnect>
  1286.  
  1287. Or, you can define your own custom events, for example <OnOpNick>, which you
  1288. could then fire manually, say, in your MODE event:
  1289.  
  1290.         FireEvent <OnOpNick> $C $nick
  1291.  
  1292. If no parameters are specified, the event is fired unconditionally. If
  1293. parameters are specified, the event is only fired if the event's mask matches
  1294. the parameters specified. You may fire a range of events by including a
  1295. wildcard, for example:
  1296.  
  1297.         FireEvent <OnConnect*
  1298.  
  1299. This would fire all events whose names begin with the string <OnConnect.
  1300.  
  1301. IRC commands
  1302. ------------
  1303.  
  1304. Usage: [^][*]command ...
  1305.  
  1306. Regular IRC commands may be used in VS (of course ;), only the slash prefix is
  1307. optional and should be left out, and the code looks neater without it. In
  1308. addition, the command can be prefixed with ^, * or ^*.
  1309.  
  1310. A prefix of ^ surpresses the output of any text that the command directly
  1311. causes. For example, V96 contains code in its MSG command to display the
  1312. message you're sending on the screen. ^MSG will send the message, but surpress
  1313. the next output.
  1314.  
  1315. A prefix of * passes the command straight into V96's built-in command
  1316. interpreter, without executing any aliases. This is very useful if you're
  1317. trying to override built-in commands, as, for example, if you want to call
  1318. V96's MSG command in your new MSG alias, you need to call the command as *MSG
  1319. to avoid the alias calling itself recursively.
  1320.  
  1321. Both prefixes can be combined as ^*. Please note that a prefix of *^ is
  1322. INVALID, and will cause an error.
  1323.  
  1324. The following code will change the text displayed when the user uses the /msg
  1325. command to something a little more fancy, demonstrating how to override a
  1326. built-in command:
  1327.  
  1328. Alias MSG
  1329.   TextOut ecPRIVMSG [*>\b$1\b<*]\t$2-
  1330.   ^*Msg $1-
  1331. EndAlias
  1332.  
  1333. ViRCScript Functions
  1334. ====================
  1335.  
  1336. The current implementation of ViRCScript is almost complete, except for the
  1337. file I/O functions which will be added later.
  1338.  
  1339. Getting input from the user
  1340. ---------------------------
  1341.  
  1342. $? pseudofunction
  1343. -----------------
  1344.  
  1345. Usage: $?="prompt"
  1346.  
  1347. Prompts the user to enter some text, displaying prompt in the text entry dialog
  1348. box. This is similar to mIRC's $? "function".
  1349.  
  1350. STRTRIM function
  1351. ----------------
  1352.  
  1353. Usage: $strtrim(text)
  1354.  
  1355. Removes control characters and the preceding colon, if present, from text. This
  1356. is very useful, as many lines received from the IRC server contain parameters
  1357. prefixed by a colon.
  1358.  
  1359. Example: Consider this line of server text.
  1360.  
  1361.         :nick!user@host PRIVMSG #channel :well, what's up everybody!!
  1362.  
  1363. To extract the actual message sent to the channel correctly, you would use
  1364. $strtrim($3-).
  1365.  
  1366. DECODEPINGINTERVAL function
  1367. ---------------------------
  1368.  
  1369. Usage: $decodepinginterval(integer)
  1370.  
  1371. Converts the ping-encoded integer specified to a human-readable time interval.
  1372. This function is only useful to decode received pings. To decode normal time
  1373. intervals, use the DECODEINTERVAL function.
  1374.  
  1375. DECODEINTERVAL function
  1376. -----------------------
  1377.  
  1378. Usage: $decodeinterval(integer)
  1379.  
  1380. Converts the integer supplied as the parameter to a human-readable time
  1381. interval. For example:
  1382.  
  1383.         $decodeinterval(38) = 38 seconds
  1384.         $decodeinterval(60) = 1 minute
  1385.         $decodeinterval(61) = 1 minute 1 second
  1386.         $decodeinterval(3728) = 1 hour 2 minutes 8 seconds
  1387.  
  1388. UPPER function
  1389. --------------
  1390.  
  1391. Usage: $upper(text)
  1392.  
  1393. Converts the given text to upper case. For example:
  1394.  
  1395.         $upper(blah) = BLAH
  1396.  
  1397. LOWER function
  1398. --------------
  1399.  
  1400. Usage: $lower(text)
  1401.  
  1402. Converts the given text to lower case. For example:
  1403.  
  1404.         $lower(BLAH) = blah
  1405.  
  1406. STRPOS function
  1407. ---------------
  1408.  
  1409. Usage: $strpos(needle haystack)
  1410.  
  1411. Finds needle within haystack, and returns the character position of needle.
  1412. 0 is returned if needle is not found in haystack. For example:
  1413.  
  1414.         $strpos(cd abcdefg) = 3
  1415.         $strpos(blah hahahahha) = 0
  1416.  
  1417. RAND function
  1418. -------------
  1419.  
  1420. Usage: $rand(n)
  1421.  
  1422. Returns a random integer in the range 0 to n - 1. For example, $rand(1000) may
  1423. return 0, 273, or 879, but never -112 or 1000.
  1424.  
  1425. RANDOMREAD function
  1426. -------------------
  1427.  
  1428. Usage: $randomread(file)
  1429.  
  1430. Returns a randomly-selected line from file. This is useful for quote or slap
  1431. scripts.
  1432.  
  1433. ISON function
  1434. -------------
  1435.  
  1436. Usage: $ison(nick channel)
  1437.  
  1438. Returns true (1) if nick is on channel, otherwise returns false (0). Example:
  1439.  
  1440.         if $ison(MeGALiTH #quake)
  1441.            Msg MeGALiTH Hi there!!
  1442.         endif
  1443.  
  1444. ISOP function
  1445. -------------
  1446.  
  1447. Usage: $isop(nick channel)
  1448.  
  1449. Returns true (1) if nick is an op on channel. If nick is a non-op on channel,
  1450. or if nick is not on channel, returns false (0).
  1451.  
  1452. WILDMATCH function
  1453. ------------------
  1454.  
  1455. Usage: $wildmatch(text mask)
  1456.  
  1457. Matches text against mask, which can contain wildcards. Examples:
  1458.  
  1459.         $wildmatch(blah *lah) = 1
  1460.         $wildmatch(blah bla*) = 1
  1461.         $wildmatch(blah *la*) = 1
  1462.         $wildmatch(blah *) = 1
  1463.         $wildmatch(blah *hah) = 0
  1464.  
  1465. Mask comparisons are case-insensitive. text may contain spaces. mask, however,
  1466. may not.
  1467.  
  1468. MASKMATCH function
  1469. ------------------
  1470.  
  1471. Usage: $maskmatch(text mask)
  1472.  
  1473. Matches text against mask. Use MASKMATCH, and _not_ WILDMATCH, if you're trying
  1474. to match a nick!user@host-style mask. Example:
  1475.  
  1476.         $maskmatch(MeGALiTH!~megalith@jimc.demon.co.uk *!*megalith@*demon.co.uk) = 1
  1477.  
  1478. Mask comparisons are case-insensitive.
  1479.  
  1480. NICKCOUNT function
  1481. ------------------
  1482.  
  1483. Usage: $nickcount(channel)
  1484.  
  1485. Returns the number of users on channel. If channel doesn't exist, the function
  1486. will return 0.
  1487.  
  1488. OPCOUNT function
  1489. ----------------
  1490.  
  1491. Usage: $opcount(channel)
  1492.  
  1493. Returns the number of ops on channel. If channel doesn't exist, or if there are
  1494. no ops, the function will return 0.
  1495.  
  1496. PEONCOUNT function
  1497. ------------------
  1498.  
  1499. Usage: $peoncount(channel)
  1500.  
  1501. Returns the number of peons (non-ops) on channel. If channel doesn't exist, or
  1502. if there are no peons, the function will return 0.
  1503.  
  1504. NICKS function
  1505. --------------
  1506.  
  1507. Usage: $nicks(channel num)
  1508.  
  1509. Returns the num'th user on channel. For example, $nicks(#quake 45) will return
  1510. the nick of the 45th user on channel #quake (the list is sorted
  1511. alphabetically, with ops at the top, followed by peons). If channel doesn't
  1512. exist, or there is no user at num (i.e. if num is less than 1 or greater than
  1513. $nickcount), the function will return nothing.
  1514.  
  1515. OPS function
  1516. ------------
  1517.  
  1518. Usage: $ops(channel num)
  1519.  
  1520. Returns the num'th op on channel. For example, $ops(#quake 3) will return the
  1521. nick of the 3rd op on channel #quake (the list is sorted alphabetically). If
  1522. channel doesn't exist, or there is no op at num (i.e. if num is less than 1 or
  1523. greater than $opcount), the function will return nothing.
  1524.  
  1525. PEONS function
  1526. --------------
  1527.  
  1528. Usage: $peons(channel num)
  1529.  
  1530. Returns the num'th peon (non-op) on channel. For example, $peons(#quake 19)
  1531. will return the nick of the 19th peon on channel #quake (the list is sorted
  1532. alphabetically). If channel doesn't exist, or there is no peon at num (i.e. if
  1533. num is less than 1 or greater than $peoncount), the function will return
  1534. nothing.
  1535.  
  1536. FILEEXISTS function
  1537. -------------------
  1538.  
  1539. Usage: $fileexists(filename)
  1540.  
  1541. Returns true (1) if filename exists, otherwise returns false (0).
  1542.  
  1543. SUBSTR function
  1544. ---------------
  1545.  
  1546. Usage: $substr(text start num)
  1547.  
  1548. Returns num characters at start from text. Exactly equivalent to Delphi's
  1549. Copy(text, start, num) function or VB's Mid$(text, start, num) function.
  1550. Example:
  1551.  
  1552.         $substr(abcdef 2 3) = bcd
  1553.  
  1554. GETINPUTLINE function
  1555. ---------------------
  1556.  
  1557. Usage: $getinputline(channel)
  1558.  
  1559. Gets the current contents of the command entry box in channel. To do this for
  1560. the server notices window, specify . as channel (a period).
  1561.  
  1562. LENGTH function
  1563. ---------------
  1564.  
  1565. Usage: $length(text)
  1566.  
  1567. Returns the length of text in characters. Example:
  1568.  
  1569.         $length(hello) = 5
  1570.  
  1571. CHANNELCOUNT function
  1572. ---------------------
  1573.  
  1574. Usage: $channelcount()
  1575.  
  1576. Returns the number of open channels.
  1577.  
  1578. CHANNELS function
  1579. -----------------
  1580.  
  1581. Usage: $channels(num)
  1582.  
  1583. Returns the name of open channel number num. For example, if you have one
  1584. channel open, #quake, $channels(1) will return #quake. If the channel number
  1585. num specified does not exist, the function will return nothing.
  1586.  
  1587. GETSETTING function
  1588. -------------------
  1589.  
  1590. Usage: $getsetting(section value)
  1591.  
  1592. This is a very powerful function which allows a script to obtain any ViRC '96
  1593. user setting that it's stored in the registry. For example, the default event
  1594. library that comes with V96, DEFAULT.LIB, uses this function to determine
  1595. whether to output text in a query window or not, depending on whether the user
  1596. has chosen to use a query window or not in the Options tab of the Client Setup
  1597. dialog.
  1598.  
  1599. The best way to find the values for section and value is to load up REGEDIT (it
  1600. comes with Windows 95 and NT) and to look in
  1601. HKEY_CURRENT_USER/Software/MeGALiTH Software/Visual IRC '96. All available
  1602. sections are visible there.
  1603.  
  1604. Examples:
  1605.  
  1606.         $getsetting(Options QueryEnabled)
  1607.         $getsetting(Options AutoRejoin)
  1608.         $getsetting(SOCKS setup Enabled)
  1609.         $getsetting(IDENTD setup Port)
  1610.  
  1611. GETUSERLEVEL function
  1612. ---------------------
  1613.  
  1614. Usage: $getuserlevel(mask)
  1615.  
  1616. Returns the userlevel of mask in your userlist. For example, if
  1617. *!*blah@*hah.com is in your userlist with level 3,
  1618. $getuserlevel(user!nablah@spahah.com) would return 3. If the user cannot be
  1619. found in the userlist, the function will return 0.
  1620.  
  1621. GETBANLEVEL function
  1622. ---------------------
  1623.  
  1624. Usage: $getbanlevel(mask)
  1625.  
  1626. Returns the banlevel of mask in your banlist. If the user cannot be found in
  1627. the banlist, the function will return 0.
  1628.  
  1629. GETPROTLEVEL function
  1630. ---------------------
  1631.  
  1632. Usage: $getprotlevel(mask)
  1633.  
  1634. Returns the protlevel of mask in your protlist. If the user cannot be found in
  1635. the protlist, the function will return 0.
  1636.  
  1637. TIME function
  1638. -------------
  1639.  
  1640. Usage: $time(format)
  1641.  
  1642. Returns the current system time in a human-readable format (hh:mm:ss xx). For
  1643. example, $time() may return 11:52:48 AM. If you wish, you may specify an
  1644. optional format string to format the date/time in any way you wish. For
  1645. example:
  1646.  
  1647.         $time(dd/mm/yy hh:mm:ss) - might return 12/07/96 19:21:18
  1648.         $time(ss) - might return 18
  1649.  
  1650. DATE function
  1651. -------------
  1652.  
  1653. Usage: $date()
  1654.  
  1655. Returns the current system date in default system format. This format is
  1656. determined by your Windows locale (internationalization) settings, and may be
  1657. something like 17th June 1996.
  1658.  
  1659. CTIME function
  1660. --------------
  1661.  
  1662. Usage: $ctime()
  1663.  
  1664. Used to calculate time intervals, measured in seconds. The actual value
  1665. returned is the number of seconds that Windows has been running, although this
  1666. may change in the future and cannot be relied upon. The number returned by
  1667. $ctime() increases by 1 every second. For example:
  1668.  
  1669.         @ $x = $ctime()
  1670.         for (@ $i = 0; $i < 1000; @ $i = $($i + 1))
  1671.           Yield
  1672.         endfor
  1673.         TextOut clBlue *** An empty 1000-iteration for loop takes $($ctime() - $x) seconds to complete.
  1674.  
  1675. Notice how $ctime() is used here to calculate a time interval - the actual
  1676. meaning of the value returned by $ctime() is insignificant.
  1677.  
  1678. The $ctime() function can also be used as a timer. For example, to wait for
  1679. 20 seconds before quitting V96, you could use the following code:
  1680.  
  1681.         @ $x = $ctime()
  1682.         while ($ctime() - $x) < 20
  1683.           Yield
  1684.         endwhile
  1685.         Exit
  1686.  
  1687. MTIME function
  1688. --------------
  1689.  
  1690. Usage: $mtime()
  1691.  
  1692. Used to calculate time intervals, measured in milliseconds. Use for measuring
  1693. time intervals. The number returned by $mtime() increases by 1 every
  1694. millisecond.
  1695.  
  1696. IDLETIME function
  1697. -----------------
  1698.  
  1699. Usage: $idletime()
  1700.  
  1701. Returns the amount of time the user has been idle for in seconds. Can be used
  1702. to implement auto-away scripts. For example, the following code will wait until
  1703. the user has been idle for 2 minutes (120 seconds) and will then set him away:
  1704.  
  1705.         while ($idletime() < 120)
  1706.           Yield
  1707.         endwhile
  1708.         Away Automatically set away after 2 minutes
  1709.  
  1710. IDLEMTIME function
  1711. ------------------
  1712.  
  1713. Usage: $idlemtime()
  1714.  
  1715. Returns the amount of time the user has been idle for in milliseconds. The same
  1716. as $idletime(), only returns a value in milliseconds rather than seconds.
  1717.  
  1718. CURRENTCHANNEL function
  1719. -----------------------
  1720.  
  1721. Usage: $currentchannel()
  1722.  
  1723. Returns the name of the channel window that currently has the focus. If a
  1724. channel window does not have the focus, this function will return . (a period).
  1725. Note that, in an alias, $C and $currentchannel() are equivalent, however, in an
  1726. event, $currentchannel() returns the correct value, whereas $C is undefined.
  1727. Useful if you want to write some text to the channel window the user currently
  1728. has the focus set to (so he/she won't miss the text!!).
  1729.  
  1730. ISQUERYING function
  1731. -------------------
  1732.  
  1733. Usage: $isquerying(nick)
  1734.  
  1735. Returns 1 if a query window is currently open for nick, and 0 otherwise.
  1736.  
  1737. ASC function
  1738. ------------
  1739.  
  1740. Usage: $asc(char)
  1741.  
  1742. Returns the ASCII value for char. For example, $asc(A) = 65, as the ASCII code
  1743. for the character A is 65.
  1744.  
  1745. CHAR function
  1746. -------------
  1747.  
  1748. Usage: $char(value)
  1749.  
  1750. Returns the character for value. For example, $asc(65) = A, as the character
  1751. A corresponds to the ASCII code 65.
  1752.  
  1753. TIMECONNECTED function
  1754. ----------------------
  1755.  
  1756. Usage: $timeconnected()
  1757.  
  1758. Returns the number of seconds that you've been connected to the server for. If
  1759. you're not currently connected to the server, this will return 0. Usefully, the
  1760. value of this function is not reset to 0 until after <OnDisconnect> has been
  1761. fired. Therefore, your script can report the total time connected to the server
  1762. when the user disconnects by adding a line of code to the <OnDisconnect>
  1763. event.
  1764.  
  1765. OPENDIALOG function
  1766. -------------------
  1767.  
  1768. Usage: $opendialog(title|filespecdescription|filespec ...)
  1769.  
  1770. Displays a COMDLG32.DLL standard file open dialog, which has the title title,
  1771. and displays files of type filespecdescription and filespec. If
  1772. filespecdescription and filespec are omitted, all files (*.*) are displayed.
  1773. Use of this function is best illustrated with a few examples:
  1774.  
  1775.         // Prompts the user for a script and /loads it
  1776.         Load $opendialog(Select a ViRCScript script to load|ViRCScript files (*.vsc)|*.vsc)
  1777.  
  1778.         // Prompts the user to select any file, and assigns its name to $x
  1779.         @ $x = $opendialog(Select any file)
  1780.  
  1781.         // Prompts the user for a .TXT or a .DOC file, and DCC SENDs it to the nick abc123
  1782.         DCC Send abc123 $opendialog(Select a text file|Text files|*.txt|Word documents|*.doc)
  1783.  
  1784. If the user presses the Cancel button on the dialog, an empty string is
  1785. returned, for example:
  1786.  
  1787.         @ $x = $opendialog(blah blah blah)
  1788.         if ([$x] == [])
  1789.            MessageBox You must select a filename!!
  1790.            Halt
  1791.         endif
  1792.  
  1793. SAVEDIALOG function
  1794. -------------------
  1795.  
  1796. Usage: $opendialog(title|filespecdescription|filespec ...)
  1797.  
  1798. Very similar to the OPENDIALOG function documented above, except the dialog has
  1799. a Save button instead of an Open button. In addition, if the file the user
  1800. selects already exists, they will be prompted whether they wish to overwrite
  1801. it. If no file is selected, the function returns an empty string.
  1802.  
  1803. For examples, see the OPENDIALOG function documented above.
  1804.  
  1805. READLINE function
  1806. -----------------
  1807.  
  1808. Usage: $readline(linenum filename)
  1809.  
  1810. Returns line number linenum from filename. For example, $readline(1 blah.txt)
  1811. will return the 1st line from the file blah.txt. If you specify an invalid
  1812. line number, the function returns an empty string.
  1813.  
  1814. GETLINESINFILE function
  1815. -----------------------
  1816.  
  1817. Usage: $getlinesinfile(filename)
  1818.  
  1819. Returns the number of lines in filename. If filename doesn't exist, the
  1820. function will return -1.
  1821.  
  1822. GETPATH function
  1823. ----------------
  1824.  
  1825. Usage: $getpath(id)
  1826.  
  1827. Returns one of the stock ViRC '96 paths (see Client setup/Paths). id can be one
  1828. of the following:
  1829.  
  1830.         virc                    - returns the base ViRC '96 directory
  1831.         upload                  - returns the V96 upload directory
  1832.         download                - returns the V96 download directory
  1833.         script                  - returns the V96 script directory
  1834.         sound                   - returns the V96 sound directory
  1835.  
  1836. GETCURRENTDIR function
  1837. ----------------------
  1838.  
  1839. Usage: $getcurrentdir()
  1840.  
  1841. Returns the current directory on the current drive. The directory name returned
  1842. by this function ALWAYS ends in a bashslash (\).
  1843.  
  1844. GETADDRESS function
  1845. -------------------
  1846.  
  1847. Usage: $getaddress(nick)
  1848.  
  1849. Gets the email (user@host) address of nick. If the address cannot be retrieved
  1850. for some reason, the function will return unknown@unknown.
  1851.  
  1852. CURRENTSERVER_ACTIVEWINDOW function
  1853. -----------------------------------
  1854.  
  1855. Usage: $currentserver_activewindow()
  1856.  
  1857. This horribly-named function is exactly the same as $activewindow(), except for
  1858. the fact that, if the active window does NOT belong to the current server
  1859. connection (e.g. if the active window is a channel from a different server to
  1860. the one that the alias/event was executed in), the function will return . as if
  1861. the active window was the server notices window for the current server. If you
  1862. don't understand this, you won't have to use this function. :)
  1863.  
  1864. ISDCCCHATTING function
  1865. ----------------------
  1866.  
  1867. Usage: $isdccchatting(nick)
  1868.  
  1869. Returns 1 if a DCC Chat connection is currently open with nick, and 0 if no
  1870. DCC Chat connection is currently open with nick.
  1871.  
  1872. ENCODEIP function
  1873. -----------------
  1874.  
  1875. Usage: $encodeip(IP)
  1876.  
  1877. Encodes IP to unsigned long format. This lets you connect to an IP address and
  1878. send stuff via a DCC Chat connection, for example, just like telnet. For
  1879. example, my mail server is 194.217.242.145, so, in a script, you could use the
  1880. following line to start an SMTP connection with my mail server:
  1881.  
  1882.         CTCP $N DCC CHAT chat $encodeip(194.217.242.145) 25
  1883.  
  1884. By faking an incoming DCC Chat connection, this neat little trick lets you do
  1885. all sorts of things, like, for example, making raw connections to IRC servers
  1886. etc. without the use of the ObjectViRCScript TSockets class.
  1887.  
  1888. GETLAG function
  1889. ---------------
  1890.  
  1891. Usage: $getlag()
  1892.  
  1893. Gets the current lag-ness of the active server connection. The lag is returned
  1894. in tenths of seconds (e.g. 10 means 1 second of lag). If the lag is unknown,
  1895. this function will return -1.
  1896.  
  1897. MESSAGEDLG function
  1898. -------------------
  1899.  
  1900. Usage: $messagedlg(type text)
  1901.  
  1902. Displays a message box on the screen, of type type, which contains text, and
  1903. returns which button the user pressed. type is calculated by selecting either
  1904. none or one item from each of the 3 groups, and adding the numbers together.
  1905.  
  1906. Group 1:
  1907.  
  1908. 0       Display OK button only.
  1909. 1       Display OK and Cancel buttons.
  1910. 2       Display Abort, Retry, and Ignore buttons.
  1911. 3       Display Yes, No, and Cancel buttons.
  1912. 4       Display Yes and No buttons.
  1913. 5       Display Retry and Cancel buttons.
  1914.  
  1915. Group 2:
  1916.  
  1917. 16      Display a STOP icon.
  1918. 32      Display a question mark icon.
  1919. 48      Display an exclamation mark icon.
  1920. 64      Display an "i" icon.
  1921.  
  1922. Group 3:
  1923.  
  1924. 0       First button is default.
  1925. 256     Second button is default.
  1926. 512     Third button is default.
  1927.  
  1928. For example, if you wanted a message dialog that had Yes and No buttons,
  1929. displayed a question mark icon, and whose second button (No) was default, you
  1930. would specify type as 292 (which is 4+32+256).
  1931.  
  1932. The value returned by this function depends on the button the user pressed:
  1933.  
  1934. 1       OK button selected.
  1935. 2       Cancel button selected.
  1936. 3       Abort button selected.
  1937. 4       Retry button selected.
  1938. 5       Ignore button selected.
  1939. 6       Yes button selected.
  1940. 7       No button selected.
  1941.  
  1942. ALIASEXISTS function
  1943. --------------------
  1944.  
  1945. Usage: $aliasexists(name)
  1946.  
  1947. Returns 1 if the alias name exists, and 0 if it does not.
  1948.  
  1949. EVENTEXISTS function
  1950. --------------------
  1951.  
  1952. Usage: $eventexists(name)
  1953.  
  1954. Returns 1 if the event name exists, and 0 if it does not.
  1955.  
  1956. GETUSER function
  1957. ----------------
  1958.  
  1959. Usage: $getuser()
  1960.  
  1961. If the -user parameter was specified on V96's command line, this function
  1962. returns the name of the user. If -user was not specified, this function returns
  1963. an empty string.
  1964.  
  1965. OPSTRIP function
  1966. ----------------
  1967.  
  1968. Usage: $opstrip(nick)
  1969.  
  1970. Strips any trailing @ or + from nick. If, for example, you are using
  1971. the SELECTEDNICK function to get the currently-selected nick in a channel nicks
  1972. list, you must use the OPSTRIP function on the nick before performing any
  1973. operations to make sure that the op (@) and/or voice (+) prefixes are removed.
  1974.  
  1975. SELECTEDNICK function
  1976. ---------------------
  1977.  
  1978. Usage: $selectednick(channel)
  1979.  
  1980. Returns the nick selected in channel's nicks list. If channel is not a valid
  1981. channel window, or if no nick is selected in channel's nicks list, this
  1982. function will return an empty string. The nick returned may be prefixed with
  1983. op (@) and/or voice (+) flags, which should be stripped off with the OPSTRIP
  1984. function before the nick can be used with other IRC commands (e.g. MODE, KICK
  1985. etc.).
  1986.  
  1987. Set-handling commands and functions
  1988. ===================================
  1989.  
  1990. V96 0.82 and above support sets, a very powerful feature similar to Delphi's
  1991. set capability. ObjectVS set properties are supported (see OBJECTVS.TXT), but
  1992. sets work well in regular VS without objects too.
  1993.  
  1994. Basically, a set can contain one or more elements, each which is one word. It's
  1995. as simple as that. For example, consider this data:
  1996.  
  1997.         Patricia        - Female, long dark hair, brown eyes, married
  1998.         Mark            - Male, short dark hair, blue eyes, not married
  1999.         Sarah           - Female, short red hair, black eyes, not married
  2000.  
  2001. You could represent this data in VS easily by use of sets:
  2002.  
  2003.         @ $Patricia = [sexFemale,hairLong,hairDark,eyesBrown,msMarried]
  2004.         @ $Mark = [sexMale,hairShort,hairDark,eyesBlue]
  2005.         @ $Sarah = [sexFemale,hairShort,hairRed,eyesBlack]
  2006.  
  2007. Note that all sets are surrounded by []'s and each set element is separated
  2008. from the next by a comma.
  2009.  
  2010. Once $Patricia and $Mark are defined, you can use, for example, the ISINSET
  2011. function as follows:
  2012.  
  2013.         $IsInSet([sexMale] $Mark)                       == 1
  2014.         $IsInSet([sexFemale,eyesBrown] $Patricia)       == 1
  2015.         $IsInSet([sexFemale,hairDark] $Sarah)           == 0
  2016.  
  2017. If Sarah dyes her hair black and grows it long, the ADDTOSET and REMOVEFROMSET
  2018. functions can be used:
  2019.  
  2020.         @ $Sarah = $RemoveFromSet($Sarah [hairShort,hairRed])
  2021.         @ $Sarah = $AddToSet($Sarah [hairLong,hairBlack])
  2022.  
  2023. On IRC, of course, you'd hardly ever represent personal information using sets.
  2024. :) What sets are very useful for is storing user flags, for example:
  2025.  
  2026.         @s $userflags.$nick = [AutoOp,Protected,OnUserlist]
  2027.  
  2028. Then when a user joins a channel you could use something like this to auto-op
  2029. them:
  2030.  
  2031.         if ($IsInSet([AutoOp] $userflags.$nick))
  2032.            Mode +o $nick
  2033.         endif
  2034.  
  2035. Or a set could be used to hold a list of nicknames for some purpose - the
  2036. possibilities are practically endless.
  2037.  
  2038. Anyway. Now I'll document these set functions individually.
  2039.  
  2040. ISINSET function
  2041. ----------------
  2042.  
  2043. Usage: $IsInSet(set1 set2)
  2044.  
  2045. Returns 1 if every element in set1 is also in set2, and 0 otherwise.
  2046.  
  2047. ADDTOSET function
  2048. -----------------
  2049.  
  2050. Usage: $AddToSet(set1 set2)
  2051.  
  2052. Additionally combines set1 and set2, and returns a new set containing all the
  2053. elements in both set1 and set2.
  2054.  
  2055. Note that ADDTOSET also cleans up the set, removing any spaces and duplicate
  2056. items. Hence it's sometimes useful to use ADDTOSET with set1 or set2 as an
  2057. empty set [] to clean it up, for example:
  2058.  
  2059.         @ $x = [     blue,      BLACK,    blAck, green         ]
  2060.         @ $y = $AddToSet([] $x)
  2061.  
  2062. $y will now contain [blue,BLACK,green]. Spaces and duplicate items (BLACK and
  2063. blAck, set operations are case-insensitive) have been removed.
  2064.  
  2065. REMOVEFROMSET function
  2066. ----------------------
  2067.  
  2068. Usage: $RemoveFromSet(set1 set2)
  2069.  
  2070. Returns a new set containing all the items in set1 that are not also in set2.
  2071.  
  2072. Note that REMOVETOSET also cleans up the set. For more information on cleaning
  2073. sets, see the note at the bottom of the ADDTOSET function above.
  2074.