home *** CD-ROM | disk | FTP | other *** search
/ Online Praxis 1998 February / Image.iso / cd-rom / tools / chat / virc96.exe / VSCRIPT.TXT < prev    next >
Encoding:
Text File  |  1997-02-25  |  89.5 KB  |  2,586 lines

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