Operators are ScriptFTP symbols used for performing arithmetical or logical operations, there are also operators for comparison and text string concatenation. The behavior of operators, like in any othe programming language, is very similar to commands. They usually take two values or variables and return one. The operators supported by ScriptFTP are the following:

Arithmetical operators

  •   +  Sum.
  •     Substract.
  •   *  Multiply.
  •   /  Divide.

As the ScriptFTP language is intended for batch operations and automatic transfers, more complex operations such as square roots or powers are not supported.

# Assign 32 to the $A variable
# Assign 1 to the $B variable
# $C is the sum of $A and $B
# $D is the result of substracting 1 to $A
# Multiplying 5 and 7 you get $E
# The use of parenthesis is also allowed:
# If you try to use a text value in an arithmethical
# expression it's interpreted as a zero:
$thisiszero= 5*"abcdef"

Comparison operators

  •   <  Less than.
  •   >  Greater than.
  •   <=  Less or equal than.
  •   >=  Greater or equal than.
  •   ==  Equal.
  •   !=  Not equal.

The ScriptFTP language is typeless. There are no data types and every value is stored as a text string, even numbers. Every logical operation like the IF statement or the logical operators below rely on the interpretation of true as the text “TRUE” and false as “FALSE”. This means that the logical operators will indeed return a text value containing “TRUE” or “FALSE”. Let’s see an example:

# Store 4 in the variable $A
# Store 3 in the variable $B
# Is $B greater than $A? Store the result in $R
$R= $B > $A
# Show the content of $R in the ScriptFTP window
# FALSE should be printed
# If $B was greater than $A show a message, else show other message
    PRINT("The value stored in $B is greater than the one stored in $A")
    PRINT("The value stored in $B is not greater than the one stored in $A")
# You should see the second message

Logical operators

  •   AND   Logical AND operation.
  •   OR   Logical OR operation.

The logical operators returns “TRUE” or “FALSE”, this is because, as stated before, ScriptFTP language is typeless. Every value is stored as text and the logical values true or false are stored as “TRUE” or “FALSE” respectively.

# Assign some values:
# If $a is less or equal than 4 and $mytext is equal to "abcdef"
# show a message in the ScriptFTP window
IF(($A <= 4) AND ($mytext=="abcdef"))
    PRINT("Both conditions were true")
# Assign to $mylogicalvalue the result of
# two comparisons combined with the OR operator
$mylogicalvalue= (3 > $a) OR (4 < 2)
# As the first comparison is true and the second
# is false, $mylogicalvalue should store "TRUE"
#Connect to the server and upload three files
$result1=PUTFILE("C:\My Documents\notes.txt")
# Check if an error ocurred:
# If result1 is different than "OK" or
# result2 is different than "OK" or
# result3 is different than "OK" show an error
IF(($result1!="OK") OR ($result2!="OK") OR ($result2!="OK"))
    PRINT("An error was found uploading files")
    PRINT("Files uploaded correctly")

Text value operators

  •   .  Concatenate two values or variables.
# Show "thisisScriptFTP" on the ScriptFTP window
# Show "this is ScriptFTP" on the ScriptFTP window
$complete_text_with_spaces=$text1." ".$text2." ".$text3
# Print "Hello World!" three times on the ScriptFTP window
PRINT("Hello World!")
PRINT("Hello"." "."World!")
PRINT("He"."llo"." Wo"."rld!")