G-Lock Software

HomeProductsForumsFAQDownloadsRegistration













 Parse incoming email message - process unsubscribe request
 Home \ Products \ G-Lock Email Processor \ User Guide \ Script Syntax

On the simplest level, a program is a sequence of tokens delimited by separators. A token is the smallest meaningful unit of text in a program. A separator is either a blank or a comment. Strictly speaking, it is not always necessary to place a separator between two tokens; for example, the code fragment

Size:=20;Price:=10;

is perfectly legal. Convention and readability, however, dictate that we write this as

Size := 20;

Price := 10;

Tokens are categorized as special symbols, identifiers, reserved words, numerals, labels, and character strings. A separator can be part of a token only if the token is a character string. Adjacent identifiers, reserved words, numerals, and labels must have one or more separators between them.

Since Fields Processor script language is case-insensitive, an identifier like CalculateValue could be written in any of these ways:

CalculateValue

calculateValue

calculatevalue

CALCULATEVALUE

 Comments

Comments are ignored by the script, except when they function as separators. There are several ways to construct comments:

{ Text between a left brace and a right brace constitutes a comment. }

// Any text between a double-slash and the end of the line constitutes a comment.

 Assignment Statements

An assignment statement has the form

variable := expression;

where variable is any variable referenceincluding a variable, variable typecast, dereferenced pointer, or component of a structured variableand expression is any assignment-compatible expression.

The := symbol is sometimes called the assignment operator.

An assignment statement replaces the current value of variable with the value of expression. For example,

I := 3;

assigns the value 3 to the variable I. The variable reference on the left side of the assignment can appear in the expression on the right. For example,

I := I + 1;

increments the value of I.

 Compound Statements

A compound statement is a sequence of other (simple or structured) statements to be executed in the order in which they are written. The compound statement is bracketed by the reserved words begin and end, and its constituent statements are separated by semicolons. For example:

begin

  Z := X;

  X := Y;

  Y := Z;

end;

Compound statements are essential in contexts where Fields Processor script syntax requires a single statement. In addition to program, function, and procedure blocks, they occur within other structured statements, such as conditionals or loops. For example:

begin

  I := SomeConstant;

  while I > 0 do

  begin

    ...

    I := I - 1;

  end;

end;

 Control Loops

Loops allow you to execute a sequence of statements repeatedly, using a control condition or variable to determine when the execution stops. Fields Processor Language has three kinds of control loop: repeat statements, while statements, and for statements.

You can use the standard Break and Continue procedures to control the flow of a repeat, while, or for statement. Break terminates the statement in which it occurs, while Continue begins executing the next iteration of the sequence.

Repeat Statements

The syntax of a repeat statement is

repeat statement1; ...; statementn; until expression

where expression returns a Boolean value. (The last semicolon before until is optional.) The repeat statement executes its sequence of constituent statements continually, testing expression after each iteration. When expression returns True, the repeat statement terminates. The sequence is always executed at least once because expression is not evaluated until after the first iteration.

Examples of repeat statements include

repeat

  K := I mod J;

  I := J;

  J := K;

until J = 0;

While Statements

A while statement is similar to a repeat statement, except that the control condition is evaluated before the first execution of the statement sequence. Hence, if the condition is false, the statement sequence is never executed.

The syntax of a while statement is

while expression do statement

where expression returns a Boolean value and statement can be a compound statement. The while statement executes its constituent statement repeatedly, testing expression before each iteration. As long as expression returns True, execution continues.

Examples of while statements include

while Length(S) > 0 do

begin

  N := N + Copy(S,Length(S),1);

  Delete(S,Length(S),1)

end;

For Statements

A for statement, unlike a repeat or while statement, requires you to specify explicitly the number of iterations you want the loop to go through. The syntax of a for statement is

for counter := initialValue to finalValue do statement

or

for counter := initialValue downto finalValue do statement

where

counter is a local variable (declared in the block containing the For statement) of ordinal type, without any qualifiers.

initialValue and finalValue are expressions that are assignment-compatible with counter.

statement is a simple or structured statement that does not change the value of counter.

The for statement assigns the value of initialValue to counter, then executes statement repeatedly, incrementing or decrementing counter after each iteration. (The for...to syntax increments counter, while the for...downto syntax decrements it.) When counter returns the same value as finalValue, statement is executed once more and the for statement terminates. In other words, statement is executed once for every value in the range from initialValue to finalValue. If initialValue is equal to finalValue, statement is executed exactly once. If initialValue is greater than finalValue in a for...to statement, or less than finalValue in a for...downto statement, then statement is never executed. After the for statement terminates, the value of counter is undefined.

For purposes of controlling execution of the loop, the expressions initialValue and finalValue are evaluated only once, before the loop begins. Hence the for...to statement is almost, but not quite, equivalent to this while construction:

begin

  counter := initialValue;

  while counter <= finalValue do

  begin

    statement;

    counter := Succ(counter);

  end;

end

The difference between this construction and the for...to statement is that the while loop re-evaluates finalValue before each iteration. This can result in noticeably slower performance if finalValue is a complex expression, and it also means that changes to the value of finalValue within statement can affect execution of the loop.

Examples of for statements:

for I := 65 to 123 do

 S:= S + Chr(i);

for I := Length(S) downto 0 do

 N := N + Copy(S,1,1);

for I := 1 to 10 do

  for J := 1 to 10 do

  begin

   some operatos

  end;

 Case Statements

The case statement provides a readable alternative to complex nested if conditionals. A case statement has the form

case selectorExpression of

  caseList1: statement1;

  ...

  caseListn: statementn;

end

where selectorExpression is any expression of an ordinal type (string types are invalid) and each caseList is one of the following:

A numeral, declared constant, or other expression that the compiler can evaluate without executing your program. It must be of an ordinal type compatible with selectorExpression. Thus 7, True, 4 + 5 * 3, 'A', and Integer('A') can all be used as caseLists, but variables and most function calls cannot. (A few built-in functions can occur in a caseList.)

A subrange having the form First..Last, where First and Last both satisfy the criterion above and First is less than or equal to Last.

A list having the form item1, ..., itemn, where each item satisfies one of the criteria above.

Each value represented by a caseList must be unique in the case statement; subranges and lists cannot overlap. A case statement can have a final else clause:

case selectorExpression of

  caseList1: statement1;

  ...

  caseListn: statementn;

else

  statements;

end

where statements is a semicolon-delimited sequence of statements. When a case statement is executed, at most one of statement1 ... statementn is executed. Whichever caseList has a value equal to that of selectorExpression determines the statement to be used. If none of the caseLists has the same value as selectorExpression, then the statements in the else clause (if there is one) are executed.

The case statement

case I of

  1..5: Caption := 'Low';

  6..9: Caption := 'High';

  0, 10..99: Caption := 'Out of range';

else

  Caption := '';

end;

is equivalent to the nested conditional

if I in [1..5] then

  Caption := 'Low'

  else if I in [6..10] then

    Caption := 'High'

    else if (I = 0) or (I in [10..99]) then

      Caption := 'Out of range'

      else

        Caption := '';

 If Statements

There are two forms of if statement: if...then and the if...then...else. The syntax of an if...then statement is

if expression then statement

where expression returns a Boolean value. If expression is True, then statement is executed; otherwise it is not. For example,

if J <> 0 then Result := I/J;

The syntax of an if...then...else statement is

if expression then statement1 else statement2

where expression returns a Boolean value. If expression is True, then statement1 is executed; otherwise statement2 is executed. For example,

if J = 0 then

  Exit

else

  Result := I/J;

The then and else clauses contain one statement each, but it can be a structured statement. For example,

if J <> 0 then

begin

  Result := I/J;

  Count := Count + 1;

end

else if Count = Last then

  Done := True

else

  Exit;

Notice that there is never a semicolon between the then clause and the word else. You can place a semicolon after an entire if statement to separate it from the next statement in its block, but the then and else clauses require nothing more than a space or carriage return between them. Placing a semicolon immediately before else (in an if statement) is a common programming error.

 Character Strings

You can assign the value of a string constantor any other expression that returns a stringto a variable. The length of the string changes dynamically when the assignment is made. Examples:

MyString := 'Hello Alex!';

MyString := 'Hello ' + 'Alex';

MyString := MyString + '!';

MyString := ' ';               { space }

MyString := '';                { empty string }

 

 

G-Lock Email Processor
  User Guide

Getting Started
Program Main Window
Process Bounced Emails
Process Remove Requests
Process Subscribe Requests
Process Confirmation Letters
Detect and Remove Spam Emails
Creating Accounts
Creating New Rule

Program Settings
General Settings
Inbox Explorer Settings

Setting up Filters
Principle of Email Filtering
Using Regular Expressions
Filter By Size
Filter By Header/Body
Filter By Subject

Setting up Field Extractor
Field Extractor Window
Source Box
Generate Value From Mask
Create Fields From Database
Create Fields From Clipboard
Create Table In External Database

Setting up Fields Processor
General Settings
Script Syntax

Setting up Bounced Emails Processor
Hard & Soft Bounced Emails
Exclusion List

Setting up Actions

MS Windows Script
General Settings

Database Manager
General Settings
Connection Info
Custom SQL
Working With Table In Excel
Get Identity Value From Table

Write To File
General Settings

Save Attachment
General Settings

Forward Email
General Settings
Additional Settings

Send Email
General Settings
Additional Settings
HTML Settings

Log
Outbox
Inbox Explorer

See also

Services
  Registration
Affiliate
 
Support
  Users Forum
Contact us
 
Info
  Trojan Port List
Privacy Statement
Media and Press Information
 
  Add to Favorites
 
 
   
 
 
   

 

Home | Products | Forums | FAQ | Downloads | Registration