(v7.50.0001, 28-aug-2008).
Code: Select all
v7.50.0001 - 2008-08-28 13:16
*** Scripting syntax enhanced:
(1) Blocking of variable interpolation
Variables embedded in double-quoted or unquoted strings are
replaced with their corresponding value. Now, you can block
variables from this so-called variable interpolation by
putting them inside single-quoted strings.
This applies to all types of variables in XYplorer scripting:
1. xy native vars (<date>...)
2. environments vars (%TMP%...)
3. user vars in scripting ($a...)
(2) Introduction of a concatenation operator
Strings and variables now can be concatenated by . (dot). Any
number of blanks surrounding the concatenator are ignored. The
following scripts are identical:
::msg "Hi there!"
::msg "Hi "."there!"
::msg "Hi " . "there!"
::msg "Hi " . "there!"
::msg "Hi"." "."there!"
Examples
~~~~~~~~
::msg "The time is " . <date hh:nn:ss> . "."
> The time is 08:40:17.
Variable is outside of any quotes and simply resolved.
::msg "The time is <date hh:nn:ss>."
> The time is 08:40:17.
Variable is in dbl-quotes and interpolated.
::msg 'The time is <date hh:nn:ss>.'
> The time is <date hh:nn:ss>.
Variable is not resolved because it's in sgl-quotes.
::msg "The time is '<date hh:nn:ss>'."
> The time is '08:40:17'.
Variable is resolved because it's in a dbl-quoted string.
The additional sgl-quotes do not count because they themselves
are inside a dbl-quoted string.
::set $a, "Hi!"; msg $a
> Hi!
::set $a, "Hi!"; msg "$a"
> Hi!
::set $a, "Hi!"; msg '$a'
> $a
::msg '%TMP% = ' . %TMP%
> %TMP% = C:\Temp
::set $date, <date>; msg '$date = ' . $date
> $date = 28.08.2008 12:23:12
This would not have been possible with the previous syntax.
Since unquoted dots are now interpreted as concatenators you must
quote your dots if you want them as dots:
Old: ::msg Hi.
Now: ::msg "Hi." OR ::msg Hi."."
BTW, you could also use single quotes here, of course. They make a
difference to dbl-quotes only if variables are included.
Note that sgl-quotes within sgl-quotes have to be doubled
(analogue to dbl-quotes within dbl-quotes)!
:: msg 'You can''t!'
> You can't!
But dbl-quotes within sgl-quotes (and vice versa) do not have to
doubled:
:: msg 'Hi, "baby"!'
> Hi, "baby"!
You can, of course, as well concatenate variables using the dot.
But the dot is not necessary since interpolation sets in in
unquoted and dbl-quoted strings:
::set $a, 1; set $b, 2; msg $a.$b
::set $a, 1; set $b, 2; msg $a$b
::set $a, 1; set $b, 2; msg "$a$b"
> all the same: 12
If a variable is undefined it will not be replaced by anything:
::set $a, 1; msg $a.$b
> 1$b
The new syntax allows for special options with Batch Rename
scripts. This will be resolved to the modified date of each
selected file (the date variable is resolved by the rename
function, not by the script parser!):
::rename b, '*-<datem yyyy>', p
This will be resolved to the modified date of the focused &
selected file (the date variable is resolved by the script
parser):
::rename b, "*-".<datem yyyy>, p
::rename b, "*-<datem yyyy>", p
::rename b, *-<datem yyyy>, p
(all are identical)
! Scripting: Resolved variables were resolved again (aka repeated
processing). Fixed. For example:
::set $a, "$b"; set $b, "B"; msg $a and $b;
was: > B and B = WRONG
now: > $b and B = OKAY
*** Scripting: Now variable names must conform to strict rules.
(1) Variables are represented by a dollar sign followed by the
name of the variable.
(2) The variable name is case-sensitive (this is NOT new).
(3) A valid variable name starts with a letter or underscore,
followed by any number of letters, numbers, or underscores.
(4) A letter is a-z, A-Z (different here from PHP which also
allows the ASCII characters from 127 through 255).
Good variables: $a, $ABC, $good_variable, $a1, $a_, $_a, $_
Bad variables: a, ABC, $1, $ä, $., $
This change also allows to handle the following issue in previous
versions, where variable parsing had ignored word boundaries
because word boundaries had been allowed inside variables:
::set $a, "1"; set $ab, "2"; msg $ab;
was: > 1b = WRONG
now: > 2 = OKAY
Also the order of variable declaration is now completely
irrelevant.
- Scripting "addstr" command removed. Reason: same can be done
using concatenators now.
Before:
::addstr $x, 1,2,3,4,5,6,7,8,9,10,11
> $x = "12345678910"
The 11th argument is discarded.
Now:
::set $x, 1.2.3.4.5.6.7.8.9.10.11
> $x = "1234567891011"
Any number of parts can be concatenated.
! Scripting: Arguments containing the characters ~ AND % anywhere
where converted to UPPERCASE. Arguments containing the characters ~
AND % AND \ were cropped after (and including) \. Extremely
bizarre bug. Fixed.
* XYplorer Variables: The following deprecated date variables are
not supported anymore from now on:
<dyyyymmdd_hhnnss> : date now
<myyyymmdd_hhnnss> : modified date of current item
<srcmyyyymmdd_hhnnss> : modified date of source item
Use these forms instead:
<date yyyymmdd_hhnnss> : date now
<datem yyyymmdd_hhnnss> : modified date of current item
<srcdatem yyyymmdd_hhnnss> : modified date of source item