DEdit – Database Editor

Documentation version 1.0 , 2009-06-08

Command examples

Logical commands: $And{}, $Or{}, $Not{}, $>{}, $>={}, $<{}, $<={}, $=={}, $!={}

All of the ‘logical’ commands are used to compare/evaluate the given parameters and return a Boolean value of false or true.

This returned Boolean value is not shown in the text output directly.

They are used in combinations with commands depending on Boolean values such as $If{}, $Break{} and $Exclude{}.

(see tutorial 3)

The following examples show the effect of the commands, creating case-dependent output using the $If{} command.


Example 1:



Output of $==: $=={5,2}

Output of $If($==): $If{$=={5,2},<true!>,<false!>}

Output of $==:

Output of $If($==): false!

Both lines of the script use the $=={} command to compare the two numbers 5 and 2. As these numbers are not equal, the
command itself returns the value false. The first line, however, does not produce any output, as Boolean values are not shown
in the text.

The second line uses the command within the condition parameter of the $If{} command. As the value is false the second of the
two output-options of the $If{} command is printed.


Example 2:




Num1 = $Var{num1}


Num2 = $Var{num2}

Output of $==: $=={num1,num2}

Output of $If($==): $If{$=={num1,num2},<true!>,<false!>}

Num1 = 5

Num2 = 3

Output of $==:

Output of $If($==): false!

This example is very similar to the first, but instead of comparing two numbers directly, it compares the values of two variables.

This will be the most common situation. The first line defines a new number (integer) variable of name num1 with the given
value of 5. (The “1” defines the variable as “array” of only 1 entry, which is a simple, single number...)

The second line displays the value of the variable. Line 2 and 3 repeat this for another variable with name num2.

The remaining two lines are identical to the first example, just using the variables rather than the numbers directly.


Example 3:





$Var{num1} == $Var{num2}  is $If{$=={num1,num2},<true!>,<false!>}

$Var{num1} != $Var{num2}  is $If{$!={num1,num2},<true!>,<false!>}

$Var{num1} >= $Var{num2}  is $If{$>={num1,num2},<true!>,<false!>}

$Var{num1} <= $Var{num2}  is $If{$<={num1,num2},<true!>,<false!>}

$Var{num1} > $Var{num2}  is $If{$>{num1,num2},<true!>,<false!>}

$Var{num1} < $Var{num2}  is $If{$<{num1,num2},<true!>,<false!>}

5 == 3  is false!

5 != 3  is true!

5 >= 3  is true!

5 <= 3  is false!

5 > 3  is true!

5 < 3  is false!

This example simply list the various number comparison commands. Nothing special here.


Example 4:



$If{$=={<test1>,<test1>},<same string>,<different string>}

$If{$=={<test1>,<test2>},<same string>,<different string>}

$If{$=={<test1>,<TEST1>},<same string>,<different string>}


$If{$!={<test1>,<test1>},<different string>,<same string>}

$If{$!={<test1>,<test2>},<different string>,<same string>}

$If{$!={<test1>,<TEST1>},<different string>,<same string>}

same string

different string

different string


same string

different string

different string

This example shows that the commands $=={} and $!={} can be used to compare strings as well.
Note that they compare exact and thus also case-sensitive!


Example 5:



P = $If{ $=={1,1} , <true>, <false> }

Q = $If{ $=={0,1} , <true>, <false> }

NOT P     = $If{ $Not{$=={1,1}} , <true>, <false> }

NOT Q    = $If{ $Not{$=={0,1}} , <true>, <false> }

P AND Q = $If{ $And{$=={1,1},$=={0,1}} , <true>, <false> }

P OR Q    = $If{ $Or{$=={1,1},$=={0,1}} , <true>, <false> }

P = true

Q = false

NOT P     = false

NOT Q    = true

P AND Q = false

P OR Q    = true

The commands $And{}, $Or{}, $Not{} combine Boolean values logical. In this example we create two Boolean values (P & Q)

with the command $=={}.

The other lines show how these values combine logically.

Programmers should note that a Boolean variable is not simply an integer number of 0 or 1.

One can not assign a Boolean to an integer variable. However, one can use the $If{} command to assign case dependent values

as shown in the next example.


Example 6:








$SetVar{str,$If{$=={1,0},<first choice>,<second choice>}}




second choice

Using the $If{} command in a $SetVar{} we can assign a value to the variable depending on the Boolean expression.

Note, that we could also use this to assign string variables, as shown in the second part of the example.