Conditionals.
Simple tasks can be processed with the help of a
static template, when all files are renamed according to a single
rule. But in the most complicated cases you will be able to rename
files only with a dynamic template, i.e. the template which can
change itself during the renaming process. One of the most simple
examples of a dynamic template is a template that renames portrait
photos as "prtr-1234.jpg" and landscape photos as
"lnds-1234.jpg".
To make a template dynamic, you should use external
variables or conditionals. External variables require some kind of
knowledge in programming languages while you don't have to know any
specific things to use conditionals.
Conditionals (conditions) are marked with "*CON".
You can use any SR datatype (text, counter, another var, condition,
xvar or external) as the objects of conditionals. You can also use
ordinary numbers and text lines like "23" or "hello". To add a
conditional, press [Var Editor] in the main window. Move your eyes
to the "Conditional" label.
The structire of a conditional is similar to that
of "if ... then ... else..." statement in most programming
languages.
If var1 (relation) var2 then result=str11+str12 else
result=str21+str22; Var1 and var2 is any SR datatype.
Relations:
var1 equals var2: 'aa' and 'bb' - no; 98 and 97 - no.
var1 doesn't equal var2: 'aa' and 'bb' - yes.
var1 contains var2: 'abcd' and 'bc' - yes.
var1 doesn't contain var2: 'abcd' and 'mn' - yes.
var1 < var2: 'ab' and 'cd' - yes; 5 and 3 - no.
var1 <= var2: 'ef' and 'cd' - no; 12 and 12 - yes.
var1 > var2: 'abd' and 'abc' - yes; 3 and 10 - no.
var1 >= var2: 'qwe' and 'qwe' - yes, 4 and 3 -
yes.
length() is the same, but it is the length of the var's
result that matters: length 'abc'=3, length '2'=1, length "*XVR
FILE DATE DAY" = 2 and so on.
Example: if var1 length()> 3 then... (it is the same as
Delphi's if length(var)>3 then...)
There is a difference between numbers and strings. if var1 and var2
are both numbers, they are compared as numbers, but if at least one
of them is not a number, they are compares as strings. For
instance, 345>8, if they are compared as numbers, but
'345'<'8', if they are strings, because the symbol '3' precedes
'8'. If you need to compare numbers as strings, add some non-digit
symbol to the end of either var1 or var2, and they will be regarded
as strings, for example '123;'.
String as a set of symbols: (for var2 only). If this
checkbox is checked, var1 will be in some relation with any symbol
of var2:
var1 equals var2 - if var1 equals any symbol from var2
then... (makes sence with length(var1)=1 only)
var1 doesn't equal var2 - if var1 doesn't equal any symbol
form var2, then... (makes sence with length(var1)=1 only)
var1 contains var2 - if var1 contains at least one symbol
from var2 then...
var1 doesn't contain var2 - if var1 doesn't contain any
symbol from var2 then...
For other relations this function is useless.
Case sensitive search: If checked, 'Abc' is not equal
'abc'. If not checked, they are considered equal.
Note: the main constriction can be shortened as you need, for
example instead of using
If var1 (relation) var2 then result=str11+str12 else
result=str21+str22
you may use this:
If var1 (relation) var2 then result=str11 else
result=str21
or this:
If var1 (relation) var2 then result=str11
or even this:
If var1 (relation) var2 then result= else result=str22.
Relating lesson: Lesson-C.
Relating lesson: Lesson-D.
Go to the main page.