home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 2 BBS / 02-BBS.zip / v611docs.zip / VMAIN611.ZIP / VC10-AA < prev    next >
Text File  |  1993-10-08  |  7KB  |  169 lines

  1.                                             VBBS 6.11 Documentation -- 10-A-1
  2.  
  3.  
  4.          ╔════════════════════════════════════════════════════════════════╗
  5.          ║  CHAPTER TEN ANNEX A     NUMBER AND STRING HANDLING            ║
  6.          ╚════════════════════════════════════════════════════════════════╝
  7.  
  8.  
  9.          NUMERIC OPERATORS
  10.          ═════════════════
  11.  
  12.                 VSCRIPT supports the following mathematical operators:
  13.  
  14.                        +  Addition           -  Subtraction
  15.                        *  Multiplication     /  Division
  16.                        ^  Exponentiation
  17.  
  18.          All math commands in the script language are performed from
  19.          left-to-right.  Parentheses can NOT be used in a formula, so
  20.          any math that needs to be done in a hierarchical format must be
  21.          done over more than one line.  Also, remember the restriction
  22.          on 'tokens' - a math symbol counts as a token, so only two math
  23.          operations can be performed on one line.
  24.  
  25.                    Example:                   Results:
  26.                    $a= 2 * 2 + 4              => 4 + 4       => 8
  27.                    $b = $a + 2 / 5            => 10 / 5      => 2
  28.                    $c = $b + 5 - 4            => 7 - 4       => 3
  29.                    $d = 4 / $b ^ 3            => 2 * 2 * 2   => 8
  30.  
  31.  
  32.          NUMERIC FUNCTIONS
  33.          ═════════════════
  34.  
  35.          INT 0 ->  <variable1> = <value2> INT 0
  36.  
  37.                This function takes the number stored in <value2> and
  38.            rounds down to the next lower whole number.  The resulting
  39.            integer is then stored in <variable1>.  Remember: negative
  40.            numbers also round down with this function as shown below:
  41.  
  42.                $total = -11.25 INT 0 returns a value of -12, not -11.
  43.  
  44.          SQR 0 ->  <variable1> = <value2> SQR 0
  45.  
  46.                This function returns the square root of the absolute
  47.            value of the number stored in <value2>.  The result is then
  48.            stored in <variable1>.  Note: The absolute value of a number
  49.            equals its positive value, ie absolute of -11 = 11.
  50.  
  51.          RND ->  <variable1> = <value1> RND <value2>
  52.  
  53.                This function generates a random number between the two
  54.            <value>'s.  If <value1> is smaller than <value2> then the
  55.            result will not include either number.  If <value1> is larger
  56.            than <value2> then the result can include either number.
  57.  
  58.  
  59.                                             VBBS 6.11 Documentation -- 10-A-2
  60.  
  61.  
  62.              Example:                Results:
  63.              $a = 4.15 * 4 + .25     => 16.85
  64.              $b = $a INT 0           => 16
  65.              $c = $b SQR 0           => 4
  66.              $d = $a INT 0 SQR 0     => 4
  67.              $e = $b RND $c          => a random number from 4 to 16
  68.              $f = $c RND $b          => a random number from 5 to 15
  69.  
  70.  
  71.          STRING OPERATORS
  72.          ════════════════
  73.  
  74.            & ->  <variable1> = <token3> & <token5> & <token7>
  75.  
  76.                This allows you to link together many variables and strings
  77.            to print as a single variable, effectively adding many tokens
  78.            together. ex: $Junk = "This is" & " one big " & "statement!"
  79.  
  80.  
  81.          STRING FUNCTIONS
  82.          ════════════════
  83.  
  84.                In addition to the '&' operators there are some functions
  85.            for use with strings and variables that store strings.
  86.  
  87.          ASC 0 ->  <variable1> = <string2> ASC 0
  88.  
  89.                This function finds the ASCII code of the first character
  90.            in <string2> and stores it in <variable1>.
  91.  
  92.          CHR 0 ->  <variable1> = <value2> CHR 0
  93.  
  94.                This function takes <value2> and places the character with
  95.            the matching ASCII code into <variable1>.
  96.  
  97.          LEN 0 ->  <variable1> = <string2> LEN 0
  98.  
  99.                This function returns the number of characters within
  100.            <string2> and places the result in <variable1>.
  101.  
  102.          UPPER 0 ->  <variable1> = <string2> UPPER 0
  103.  
  104.                This function returns the upper case equivalent of what is
  105.            in <string2>.  It only changes the lower case letters, leaving
  106.            all numbers and symbols as they are in the original <string2>.
  107.  
  108.          INSTR ->  <variable1> = <string2> INSTR <string3>
  109.  
  110.                This function scans <string2> to see if <string3> exists
  111.            within it.  It returns a 0 to <variable1) if it is not found,
  112.            otherwise it returns the position of <string3>.
  113.  
  114.  
  115.                                             VBBS 6.11 Documentation -- 10-A-3
  116.  
  117.  
  118.          MID   ->  <variable1> = <string2> MID <value3>
  119.          LEFT  ->  <variable1> = <string2> LEFT <value3>
  120.  
  121.                These functions return portions of a string. MID starts
  122.            at the character <value3> and returns the rest of the string.
  123.            LEFT starts at the left-most character and returns a number
  124.            of characters equal to <value3>.
  125.  
  126.            Example:                      Results:
  127.            $a = "aBc2" & "05 D" & "e╫Fg" => "aBc205 De╫Fg"
  128.            $b = $a MID 10                => ╫Fg
  129.            $c = $b ASC 0                 => 215 - the ASCII code for ╫
  130.            $d = $a LEFT 6 MID 4          => 205
  131.            $e = $d CHR 0                 => ═   - the ASCII 205 character
  132.            $f = $a INSTR "205"           => 4   - the 205 is in the string
  133.                                                   and the 2 is located in
  134.                                                   the 4th position.
  135.            $g = $a LEN 0                 => 12
  136.            $h = $a UPPER 0               => "ABC205 DE╫FG"
  137.  
  138.            Note: The quotes in the strings are not an actual part of the
  139.                  strings.  They are there only to denote the beginning
  140.                  and end of a single token.
  141.  
  142.  
  143.          STRING ALTERATIONS
  144.          ══════════════════
  145.  
  146.                There are a few commands that actually allow you to alter
  147.            the format of a variable.  All of them use the same syntax and
  148.            are described below.
  149.  
  150.          JC ->  JC <variable1> <value2>
  151.          JL ->  JL <variable1> <value2>
  152.          JR ->  JR <variable1> <value2>
  153.  
  154.                These commands all take what is stored within <variable1>
  155.            and pad it with extra spaces.  JC centers the <variable1> in
  156.            a field of <value2> spaces.  JL places it along the left margin
  157.            and JR places it on the right margin in a similar field.
  158.  
  159.            Example:                     Results:
  160.            $size = 14
  161.            $a = "Greed!"                => $a now has the value:
  162.            JC $a $size                     "    Greed!    "
  163.            $b = "Green!"                => $b now has the value:
  164.            JL $b $size                     "Green!        "
  165.            $c = "Groan!"                => $c now has the value:
  166.            JR $c $size                     "        Groan!"
  167.  
  168.  
  169.