G-Lock Software

HomeProductsForumsFAQDownloadsRegistration













 Parse incoming email message - process unsubscribe request
 ... \ G-Lock Email Processor \ User Guide \ Fields Processor General Settings

Fields Processor allows you to automatically perform various operations with the data extracted by Field Extractor.

Fields Processor works as a Pascal-like language interpreter. The basic differences from the standard Pascal are:

 - all variables stored as variants;

 - no need to declare variables, labels and functions. Field Processor creates variables dynamically on first assignment. Variable type depends on the last value assigned, type checking is not carried out.

With Fields Processor you are able to execute: 

Expressions syntax:
 

Arithmetic operators:
 

+, -, *, /, ^ (power), SHL, SHL
Bitwise operators:
 
BITOR,BITAND,BITXOR,BITNOT
Logical operators: >, <, >=, <=, =, <>, AND, OR, NOT, constants TRUE and FALSE.
 
Operators precedence standard: BEGIN... END
IF... THEN... ELSE
CASE
FOR... TO/DOWNTO... DO
WHILE... DO
REPEAT... UNTIL
BREAK
CONTINUE
GOTO
EXIT
USES
INCLUDE
 

String functions/procedures:
 

Val

Val converts the string value S to its numeric representation, as if it were read from a text file with Read.

procedure Val(S; var V; var Code: Integer);
 

IntToStr

IntToStr converts an integer into a string containing the decimal representation of that number.

function IntToStr(Value: Integer): string;
 

StrToInt StrToInt converts the string S, which represents an integer-type number in either decimal or hexadecimal notation, into a number.

function StrToInt(const S: string): Integer;
 
StrToIntDef StrToIntDef converts the string S, which represents an integer-type number in either decimal or hexadecimal notation, into a number.

function StrToIntDef(const S: string; Default: Integer): Integer;
 
FloatToStr FloatToStr converts the floating-point value given by Value to its string representation. The conversion uses general number format with 15 significant digits.

function FloatToStr(Value: Extended): string;
 
StrToFloat Use StrToFloat to convert a string, S, to a floating-point value. S must consist of an optional sign (+ or -), a string of digits with an optional decimal point, and an optional mantissa. The mantissa consists of 'E' or 'e' followed by an optional sign (+ or -) and a whole number. Leading and trailing blanks are ignored.

function StrToFloat(const S: string): Extended;
 
Copy Copy returns a substring or sub array containing Count characters or elements starting at S[Index].

function Copy(S; Index, Count: Integer): string;
 
Pos Pos searches for a substring, Substr, in a string, S.

function Pos(Substr: string; S: string): Integer;
 
Length Length returns the number of characters actually used in the string or the number of elements in the array.

function Length(S): Integer;
 
Insert Insert merges Source into S at the position S[index].

procedure Insert(Source: string; var S: string; Index: Integer);
 
Delete Delete removes a substring of Count characters from string S starting with S[Index].

procedure Delete(var S: string; Index, Count:Integer);
 
Trim Trim removes leading and trailing spaces and control characters from the given string S.

function Trim(const S: string): string;
 
TrimLeft TrimLeft returns a copy of the string S with leading spaces and control characters removed.

function TrimLeft(const S: string): string;
 
TrimRight TrimRight returns a copy of the string S with trailing spaces and control characters removed.

function TrimRight(const S: string): string;
 
UpperCase UpperCase returns a copy of the string S, with the same text but with all 7-bit ASCII characters between 'a' and 'z' converted to uppercase.

function UpperCase(const S: string): string;
 
LowerCase LowerCase returns a string with the same text as the string passed in S, but with all letters converted to lowercase. The conversion affects only 7-bit ASCII characters between 'A' and 'Z'.

function LowerCase(const S: string): string;
 
Format This function formats the series of arguments in the open array Args.

function Format(const Format: string; const Args: array of const): string;
 
StrReplace StrReplace replaces occurrences of the substring specified by OldPattern with the substring specified by NewPattern. StrReplace assumes that the source string, specified by S, may contain Multibyte characters.

function StrReplace(const S, OldPattern, NewPattern: string;[[0/1],[0/1]]): string;

Square brackets enclose optional parameters.

function StrReplace(const S, OldPattern, NewPattern: string; 0): string; -StrReplace only replaces the first occurrence of OldPattern in S.

function StrReplace(const S, OldPattern, NewPattern: string; 1): string;  - all instances of OldPattern are replaced by NewPattern.

function StrReplace(const S, OldPattern, NewPattern: string; 0/1,1): string; - the comparison operation is case insensitive.

Examples:

A := StrReplace(b,'old','new');
A := StrReplace(b,'old','new',1);
A := StrReplace(b,'old','new',0,1);
 

Chr Chr returns the character with the ordinal value (ASCII value) of the byte-type expression, X.

function Chr(X: Byte): Char;
 

DateTime functions:
 

Now Returns the current date and time, corresponding to Date + Time.

function Now: TDateTime;
 
Date Use Date to obtain the current local date as a TDateTime value.

function Date: TDateTime;
 
Time Time returns the current time as a TDateTime value.

function Time: TDateTime;
 
DateToStr Use DateToStr to obtain a string representation of a date value that can be used for display purposes.

function DateToStr(Date: TDateTime): string;
 
StrToDate Call StrToDate to parse a string that specifies a date.

function StrToDate(const S: string): TDateTime;
 
TimeToStr TimeToStr converts the Time parameter, a TDateTime value, to a string.

function TimeToStr(Time: TDateTime): string;
 
StrToTime Call StrToTime to parse a string that specifies a time value.

function StrToTime(const S: string): TDateTime;
 
FormatDateTime FormatDateTime formats the TDateTime value given by DateTime using the format given by Format.

function FormatDateTime(const Format: string; DateTime: TDateTime): string;
 
DayOfWeek DayOfWeek returns the day of the week of the specified date as an integer between 1 and 7, where Sunday is the first day of the week and Saturday is the seventh.

function DayOfWeek(Date: TDateTime): Integer;
 
IncMonth IncMonth returns the value of the Date parameter, incremented by NumberOfMonths months.

function IncMonth(const Date: TDateTime; NumberOfMonths: Integer = 1): TDateTime;
 
DecodeDate The DecodeDate procedure breaks the value specified as the Date parameter into Year, Month, and Day values.

procedure DecodeDate(Date: TDateTime; var Year, Month, Day: Word);
 
DecodeTime DecodeTime breaks the object specified as the Time parameter into hours, minutes, seconds, and milliseconds.

procedure DecodeTime(Time: TDateTime; var Hour, Min, Sec, MSec: Word);
 
EncodeDate EncodeDate returns a TDateTime value from the values specified as the Year, Month, and Day parameters.

function EncodeDate(Year, Month, Day: Word): TDateTime;
 
EncodeTime EncodeTime encodes the given hour, minute, second, and millisecond into a TDateTime value.

function EncodeTime(Hour, Min, Sec, MSec: Word): TDateTime;
 

Math functions:
 

Abs Abs returns the absolute value of the argument, X.

function Abs(X);
 
Int Int returns the integer part of X; that is, X rounded toward zero.

function Int(X: Extended): Extended;
 
Frac The Frac function returns the fractional part of the argument X.

function Frac(X: Extended): Extended;
 
Round The Round function rounds a real-type value to an integer-type value.

function Round(X: Extended): Int64;
 
Ceil Call Ceil to obtain the lowest integer greater than or equal to X. The absolute value of X must be less than MaxInt.

function Ceil(const X: Extended):Integer;
 
Floor Call Floor to obtain the highest integer less than or equal to X.

function Floor(const X: Extended): Integer;
 
Trunc The Trunc function truncates a real-type value to an integer-type value.

function Trunc(X: Extended): Int64;
 
Sin The Sin function returns the sine of the argument.

function Sin(X: Extended): Extended;
 
Cos Cos returns the cosine of the angle X, in radians.

function Cos(X: Extended): Extended;
 
Tan Tan returns the tangent of X.

function Tan(const X: Extended): Extended;
 
ArcSin ArcSin returns the inverse sine of X.

function ArcSin(const X: Extended): Extended;
 
ArcCos ArcCos returns the inverse cosine of X.

function ArcCos(const X: Extended): Extended;
 
ArcTan ArcTan returns the arctangent of X.

function ArcTan(X: Extended): Extended;
 
Exp Exp returns the value of e raised to the power of X, where e is the base of the natural logarithms.

function Exp(X: Real): Real;
 
Ln Ln returns the natural logarithm (Ln(e) = 1) of the real-type expression X.

function Ln(X: Real): Real;
 
IntPower
 
IntPower raises Base to the Power specified by Exponent.

function IntPower(Base: Extended; Exponent: Integer): Extended;
 
Sqr The Sqr function returns the square of the argument.

function Sqr(X: Extended): Extended;
 
Sqrt Returns the square root of X.

function Sqrt(X: Extended): Extended;
 
Inc Inc adds one or N to the variable X.

procedure Inc(var X [ ; N: Longint ] );
 
Dec The Dec procedure subtracts one or N from a variable.

procedure Dec(var X[ ; N: Longint]);
 

Other functions:
 

Beep Beep calls the Windows API MessageBeep.

procedure Beep;
 
ShowMessage Call ShowMessage to display a simple message box with an OK button.

procedure ShowMessage(const Msg: string);
 
Min Call Min to compare multiple numeric or string values. Min returns the smaller value of all.

function Min(A,B,[C,]: Integer): Integer;

function Min('A','B',['C',]: String): String;
 
Max Call Max to compare multiple numeric or string values. Max returns the greater value of all.

function Max(A,B,[C,]: Integer): Integer;

function Max('A','B',['C',]: String): String;

Just select Fields Processor from the drop down list to display the appropriate settings.

Type your script (operation you want to be automatically performed with your data) in the Script window.

Notes:
 

Fields Processor works only with the fields extracted by Field Extractor. For your ease, you can select field names from the popup menu. Just click the right mouse button, click Insert Fields and select the necessary field name from the menu.

If a field value in the Field Extractor contains the line break symbols, they will be replaced with %%13%%%%10%% in the Fields Processor.

To test whether you correctly wrote your script, enter your source data into the Input Variables window and click Test. The Output Variables window shows you the result you would receive after the program finishes its work.

Example:

We have My Subscribers rule that processes messages with subscribe requests from our customers. Field Extractor extracts the following fields from a message: Name, Email, Action, ProgramName, Date. Let's admit that the customer did not indicate his name in the appropriate field. So, with Field Processor we can automatically assign the value for this field from the customer's email address. To do this, we type the following script in the Script window:

Name  := Trim(Name);
Email := Trim(Email);

if (Length(Name)=0) and (Email<>'')
then

Name:=UpperCaseFirstChar(GetEmailLocalPart(Email))
else
if
Name<>''
then

Name:=UpperCaseFirstChar(Name)
else
begin

ScriptResult := 'Email address is blank';
ScriptResult := ScriptResult+'; '+'User Name is blank';
end
;

CurrentDate := FormatDateTime('dddddd hh:mm AM/PM',Now);

function GetEmailLocalPart(Value);
begin

Result := Copy(Value,1,pos('@',value)-1);
end
;

function UpperCaseFirstChar(Value);
begin
case
Length(Value) of
0 : Result := '';
1 : Result := UpperCase(Value);
else

Result := UpperCase(Copy(Value,1,1))+Copy(Value,2,Length(Value)-1);
end
;

end;

This script means that if the value of NAME field equals 0, the program will assign to this field the value that equals the first part of the email address up to the @ symbol:

email - mark@glocksoft.com

name - "Mark"

 

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