Monday, March 17, 2008

v6.80.0114 - 2008-03-17 12:29

  • + Scripting got new commands:
      - StrLen
        Action: Returns the length of a string.
        Syntax: StrLen OutputVar, String
        Examples:
          ::strlen $a, "abcdef";  // 6
          ::strlen $a, <curitem>; // length of current item

      - StrPos
        Action: Returns position of first occurrence of a string.
        Syntax: StrPos OutputVar, Haystack, Needle, [Start],
                [MatchCase]
          - OutputVar: Required, anything goes, case matters.
          - Haystack:  String to search in.
          - Needle:    String to search for.
          - Start:     [optional; defaults to 0] Allows you to specify
            which position in haystack to start searching. The
            position returned is still relative to the beginning
            of haystack.
          - MatchCase: [optional; defaults to 0] Compare method.
            0: A=a
            1: A<>a
        Examples:
          ::strpos $a, "abcabc", "a";      // returns 0
          ::strpos $a, "abcabc", "d";      // returns -1 (not found)
          ::strpos $a, "abcAbc", "A";      // returns 0
          ::strpos $a, "abcAbc", "A", , 1; // returns 3
          ::strpos $a, "abcAbc", "a", 1;   // returns 3
          ::strpos $a, "abcAbc", "a", 10;  // returns -1 (not found)
          ::strpos $a, "abcAbc", ""; // returns -1 (not found)
          ::strpos $a, "", "a";      // returns -1 (not found)
          ::strpos $a, "", "";       // returns -1 (not found)

      - Incr
        Action: Increment a numerical value.
        Syntax: Incr OutputVar, [Value], [Increment=1]
          - OutputVar: Required, anything goes, case matters.
          - Value:     Value defaults to OutputVar(!);
            can be negative.
          - Increment: Defaults to 1; can be negative.
        Examples:
          ::incr $a;          // returns $a + 1
          ::set $a, 5; incr $a;  // returns 6 (5 + 1)
          ::incr $a, 1;       // returns 2 (1 + 1)
          ::incr $a, 1, 2;    // returns 3 (1 + 2)
          ::incr $a, -1, 2;   // returns 1 (-1 + 2)
          ::incr $a, 1, -2;   // returns -1 (1 - 2)
          ::incr $a, -1, -2;  // returns -3 (-1 - 2)
          ::incr $a, "Paul";  // returns 1 (0 + 1)
          ::incr $a, "3Paul"; // returns 4 (3 + 1)
  • * Scripting: Renamed "Add" renamed to "AddStr". Reason: "Add" implies a numerical operation.
  • * Scripting: Renamed "Mid" to "SubStr". Also changed its syntax as to match SubStr in PHP. So forget yesterday's "Mid", here's "SubStr":
      - SubStr
        Action: returns part of a string
        Syntax: SubStr OutputVar, String, [Start], [Length]
          - OutputVar: Required, anything goes, case matters.
          - String:    Input string.
          - Start:     Start of returned part; defaults to 0, first
            position is 0. If Start is negative, the returned string
            will start at the start'th character from the end of
            string.
          - Length:    Length of returned part (number of characters).
            If missing then the whole string is returned (beginning
            from Start). If Length is negative, then that many
            characters will be omitted from the end of string
            (after the start position has been calculated when
            Start is negative). If Start denotes a position beyond
            this truncation, an empty string will be returned.
        Examples:
          ::substr $a, "abcdef", 1;       // returns "bcdef"
          ::substr $a, "abcdef", 1, 1;    // returns "b"
          ::substr $a, "abcdef", -1);     // returns "f"
          ::substr $a, "abcdef", -2);     // returns "ef"
          ::substr $a, "abcdef", -3, 1);  // returns "d"
          ::substr $a, "abcdef", 0, -1);  // returns "abcde"
          ::substr $a, "abcdef", 2, -1);  // returns "cde"
          ::substr $a, "abcdef", 4, -4);  // returns ""
          ::substr $a, "abcdef", -3, -1); // returns "de"
  • + New variable: <focitem> = currently focused item in tree or list. Useful in scripting; for example, this works in tree or list depending on focus:
      ::copytext <focitem>
    Note that, contrary to <curitem>, <focitem> will also return the focused item if it is not selected.
  • * Scripting RegExReplace: Now caret (^) & dollar ($) match the beginning & end of every line, before they'd only match the very start and very end of the entire string.