|
Macro
|
Description
|
%XMP_ArgCount(Text, [Delimiter],
[Quotes])
|
Determines the number of entries in a "Text" that are separated by one of the specified "Delimiter" characters. Delimiters inside any of the "Quotes" are ignored.
If "Delimiter" is not specified, a space is assumed. If no "Quotes" are specified, a standard quote (") is used.
Example:
%XMP_ArgCount(|"ABC 123 XYZ"789 test1 test2|)
%XMP_ArgCount(|"ABC,123,XYZ" 789,test1,test2|,|,|)
%XMP_ArgCount(|'ABC#123#XYZ" 789#test1:test2|,|#:|,|'"|)
Output:
3
3
3
|
%XMP_ArgItem(Text, Entry [Delimiter],
[Quotes])
|
Returns a specific "Entry" from a "Text" that is separated from other entries by one of the specified "Delimiter" characters. Delimiters inside any of the "Quotes" are ignored.
If "Delimiter" is not specified, a space is assumed. If no "Quotes" are specified, a standard quote (") is used.
Example:
%XMP_ArgItem(|"ABC 123 XYZ"789 test1 test2|,|2|)
%XMP_ArgItem(|"ABC,123,XYZ" 789,test1,test2|,|3|,|,|)
%XMP_ArgItem(|'ABC:123#XYZ" 789#test1:test2|,|1|,|#:|,|'"|)
Output:
test1
test2
'ABC:123#XYZ" 789
|
|
%XMP_Decode(Text, Method)
|
Decodes a "Text" in MIME format (Base64) or Quoted-Printable format.
The "Method" argument specifies whether the text is in Base64 format (argument "B") or Quoted-Printable format (argument "Q").
Example:
%XMP_Decode("RGV1dHNjaGxhbmQgaXN0IHNjaPZu","B")
%XMP_Decode("est une soci=E9t=E9 Suisse","Q")
Output:
Germany is beautiful
est une société Suisse
|
|
%XMP_Encode(Text, Method)
|
Encodes a "Text" as MIME (Base64) or Quoted-Printable.
The "Method" argument specifies whether the text should be encoded as Base64 (argument "B") or Quoted-Printable (argument "Q").
Example:
%XMP_Encode("Germany is beautiful","B")
%XMP_Encode("est une société Suisse","Q")
Output:
RGV1dHNjaGxhbmQgaXN0IHNjaPZu
est une soci=E9t=E9 Suisse
|
|
%XMP_Grep(Text, RegExp, [Output])
|
Searches a "Text" line by line using the regular expression "RegExp". "Output" specifies which lines should be returned:
M -> Returns all lines matching the regular expression. (Default if not specified)
N -> Returns all lines not matching the regular expression.
B -> Returns all lines before the first matched regular expression.
A - > Returns all lines after the first matched regular expression.
I -> Can be used additionally with "A" or "B" to include the line matching the regular expression as well.
Note: Since problems may occur if the "Text" contains quotes, these are replaced with the hexadecimal code 0x02.
Therefore, in regular expressions, the hexadecimal code 0x02 ("\x02") must be used for a quote instead of "\x22".
Example:
All lines containing "http://www.":
%XMP_Grep("%TEXT","http:\/\/www\.")
Example Output:
All lines containing "http://www.":
> Our URL is https://www.ritlabs.com
On https://www.ritlabs.com you can also find the Extended Macro Plugin
https://www.ritlabs.com
|
|
%XMP_HtmlDec(Text, [Options])
|
This macro decodes HTML entities in a "Text" into the corresponding special characters.
The optional "Options" argument specifies the type of decoding:
E -> Decodes HTML entities (except encoded HTML control characters) into national special characters.
This method is used if the "Options" parameter is not specified.
H -> Decodes HTML control characters (greater-than, less-than, double quotes, and ampersand).
Example:
%XMP_HtmlDec('<b>"àéî€ & äöüß "</b>')
%XMP_HtmlDec('<b>"àéî€ & äöüß "</b>','H')
%XMP_HtmlDec('<b>"àéî€ & äöüß "</b>','EH') Output: <b>"àéî€ & äöüß"</b>
<b>"àéî€ & äöüß"</b>
<b>"àéî€ & äöüß"</b>
|
|
%XMP_HtmlEnc(Text, [Options])
|
This macro encodes special characters in a "Text" into HTML entities.
The optional "Options" argument specifies the type of encoding:
E -> Encodes national special characters, e.g., German umlauts, into named entities. This method is used if the "Options" parameter is not specified.
U -> Encodes national special characters, e.g., German umlauts, using their character codes.
H -> Encodes HTML control characters (greater-than, less-than, double quotes, and ampersand).
Example:
%XMP_HtmlEnc('<b>"àéî€ & äöüß"</b>')
%XMP_HtmlEnc('<b>"àéî€ & äöüß"</b>','U')
%XMP_HtmlEnc('<b>"àéî€ & äöüß"</b>','H')
%XMP_HtmlEnc('<b>"àéî€ & äöüß"</b>','EH')
%XMP_HtmlEnc('<b>"àéî€ & äöüß"</b>','UH') Output: <b>"àéî€ & äöü ß"</b>
<b>"àéî€ & äöüß "</b>
<b>"àéî€ & äöüß"</b>
<b>"àéî€ & äö üß"</b>
<b>"àéî€ & äö
üß"</b>
|
%XMP_LineBtw(Text, Start, End, [StartPos,
EndPos])
|
Returns the part of a line in "Text" between "Start" and "End". The search is case-insensitive.
"StartPos" and "EndPos" indicate whether the search terms are at the start or end of the line. 1 stands for the start or end of the line. If "StartPos" or "EndPos" is 0 or omitted, the entire line is searched for "Start" and "End".
Example Text:
Name: Huber, Karl
Location: 1234 City S/N: 173993783892.TEST
Example:
%XMP_LineBtw("%TEXT","Name:",", ",0,1)
%XMP_LineBtw("%TEXT","Location:","",0,0)
%XMP_LineBtw("%TEXT","S/N:",".test",0,0)
Example Output:
Huber
1234 City
173993783892
|
%XMP_REIsMatch(Text, Search, [StartPos],
[Case])
|
Searches "Text" for "Search" using a regular expression (PCRE). Returns "1" if found, otherwise "0".
The optional "StartPos" parameter specifies the start position for the search. "0" corresponds to the beginning of the text.
If "Case" is set to "1", the search is case-insensitive.
Example:
%XMP_REIsMatch("abc","b")
%XMP_REIsMatch("abc","b",2)
%XMP_REIsMatch("abc","B",0,1)
Output:
1
0
1
|
|
%XMP_RERepl(Text, Search, New, [Case])
|
Searches in the "Text" for "Search" using a regular expression (PCRE) and replaces it with "New". Returns "1" if found, otherwise "0".
The optional parameter "StartPos" can specify the starting position for the search. "0" corresponds to the beginning of the text.
If "Case" is set to "1", the search is case-insensitive.
Example:
%XMP_RERepl("AbC AbC AbC","(b)","[$1]")
Output:
A[b]C A[b]C A[b]C
|
|
%XMP_ReX(Text, Expression,[SubPatt])
|
This macro is a simplified version of The Bat!'s RegExp macros. The argument "Text" specifies the text to search. "Expression" is the regular expression to search for. If "SubPatt" is specified, the corresponding sub-pattern is returned; otherwise, the first sub-pattern is returned.
If "SubPatt" is specified, it works like "%REGEXPBLINDMATCH". If not specified, it works like "%REGEXPMATCH".
Note: Quotes in the "Text" are replaced by the hex code 0x02 to avoid issues. Therefore, in the regular expressions, use the hex code 2, i.e., "\x02" instead of "\x22" for quotes.
Example:
%XMP_ReX("abc test TEXT abc",".*(test)(\s)(.*)\s.*")
%XMP_ReX("abc test TEXT abc",".*(test)(\s)(.*)\s.*","0")
%XMP_ReX("abc test TEXT abc",".*(test)(\s)(.*)\s.*",3)
Output:
test
abc test TEXT abc
TEXT
|
|
%XMP_StrAttach(Text, Filename)
|
Saves the "Text" into a temporary file with the specified "Filename" and attaches this file to the current message.
Returns "0" if an error occurs, otherwise "1".
The temporary file is NOT deleted afterward, as The Bat! would not be able to find it or attach it. All files created by this macro are deleted when the plugin is unloaded (The Bat! is closed).
Example:
%XMP_StrAttach("%TEXT","Originaltext.txt")
|
|
%XMP_StrC(Text)
|
Outputs the specified "Text", replacing escaped special characters.
The following special characters can be used:
\\ -> Backslash
\n -> Line feed
\r -> Carriage return
\t -> Tab
\w -> Carriage return + Line feed (equivalent to "\r\n")
\cCHR -> CHR is the character code from 000 to 255 and MUST be three digits!
\xHH -> HH is the hexadecimal code from 00 to FF and MUST be two digits! (Case-insensitive.)
Example:
%XMP_StrC("\c034Line1\c034\nLine2\tTab\n\nLine4")
--
%XMP_StrC("\x55\x56\x57\x0A\c034XYZ\c034")
Output:
"Line1"
Line2 Tab
Line4
--
UVW
"XYZ"
|
%XMP_StrChar(CharCode,
[CharCode], ...)
|
Converts the specified character codes (from 0 to 255) into text and returns it.
Example:
%XMP_StrChar(65,66,67,13,10,49,50,51)
Output:
ABC
123
|
%XMP_StrCheck(Text, Check,
[AlternativeChars])
|
Checks if the specified "Text" consists of certain characters.
The "Check" parameter can have the following values:
U -> (Upper) Checks if only uppercase letters are in the "Text".
L -> (Lower) Checks if only lowercase letters are in the "Text".
N -> (Numeric) Checks if only numbers are in the "Text".
In "AlternativeChars", additional characters allowed in the "Text" can be specified.
Returns "1" if the text matches the pattern, otherwise "0".
Example:
%XMP_StrCheck('Hello','L')
%XMP_StrCheck('Hello','UL')
%XMP_StrCheck('Hello, this is a test','UL',' ,')
%XMP_StrCheck('123-456.789','N','-.')
Output:
0
1
1
1
|
|
%XMP_StrCount(Text, SearchText, [Case])
|
Returns the number of occurrences of "SearchText" in "Text".
If "Case" = 1, the search is case-insensitive.
Example:
%XMP_StrCount("Abc ABC abC abc","abc")
%XMP_StrCount("Abc ABC abC abc","abc",1)
Output:
1
5
|
|
%XMP_StrDup(Text, Count)
|
Repeats the "Text" multiple times. "Count" specifies how many times.
Example:
%XMP_StrDup("=-",20)
Output:
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
|
%XMP_StrIns(OriginalText, Text,
Start/Alignment, [Length])
|
Inserts "Text" into "OriginalText".
"Start" specifies the start position, "Length" specifies the number of characters to overwrite.
Default: Start = 1, Length = 0.
Instead of a start position, you can use an alignment:
L -> Left-aligned
R -> Right-aligned
M -> Centered (odd length → more to the left)
N -> Centered (odd length → more to the right)
Example:
%XMP_StrIns("123456789","ABC")
%XMP_StrIns("123456789","ABC","R")
%XMP_StrIns("123456789","ABC","L")
%XMP_StrIns("123456789","ABC",4)
%XMP_StrIns("123456789","ABC",4,1)
%XMP_StrIns("123456789","ABC",4,999)
Output:
ABC123456789
123456ABC
ABC456789
123ABC456789
123ABC56789
123ABC
|
|
%XMP_StrItem(Text, Delimiter, Entry)
|
Reads a specific "Entry" from a "Text" separated by a "Delimiter".
Example:
%XMP_StrItem("123#ABC#XYZ","#",2)
Output:
ABC
|
|
%XMP_StrItemCnt(Text, Delimiter)
|
Returns the number of entries in "Text" separated by "Delimiter".
Example:
%XMP_StrItemCnt("123#ABC#XYZ","#")
Output:
3
|
|
%XMP_StrLeft(Text, Count)
|
Returns the first "Count" characters from "Text".
Example:
%XMP_StrLeft("123456789",3)
Output:
123
|
|
%XMP_StrLen(Text)
|
Returns the length of the specified text.
Example:
%XMP_StrLen("ABCEDEF")
Output:
7
|
|
%XMP_StrLines(Text, [Start], [Count])
|
Reads "Count" lines from "Text" starting at line "Start".
Omitting "Start" or "Count" defaults to 1 line.
Example:
%XMP_StrLines("%TEXT",2,2)
Output:
Line2
Line3
|
|
%XMP_StrLnCnt([Text])
|
Determines the number of lines in the specified "Text".
If "Text" is not specified, the message body of the original message is used.
Example:
%XMP_StrLnCnt
%XMP_StrLnCnt("")
%XMP_StrLnCnt("%_VAR")
Output:
25
0
3
|
|
%XMP_StrMid(Text, Start, [Count])
|
Returns a specific "Count" of characters from "Text", starting at character "Start".
If "Count" is not specified, all characters from "Start" onward are returned.
Example:
%XMP_StrMid("123456789",3,4)
%XMP_StrMid("123456789",3)
Output:
3456
3456789
|
|
%XMP_StrPos(Text, SearchText, [Case])
|
Determines the position of the first occurrence of "SearchText" in "Text".
If "Case" is set to "1", the search is case-insensitive.
Example:
%XMP_StrPos("AbcABCabc","ABC")
%XMP_StrPos("AbcABCabc","ABC",1)
Output:
4
1
|
%XMP_StrRepl(Text, Search, New,
[Case], [All])
|
Replaces all occurrences of "Search" in "Text" with "New".
If "Case" is set to "1", the replacement is case-insensitive.
If "All" is set to "1", after replacing it checks again whether new occurrences were created by the previous replacement. The "Case" setting is respected here as well.
Warning: When using "All", ensure no "infinite loops" occur, e.g.:
"%XMP_StrRepl("XxXxXxXxXxXxXx","X","x",1,1)"!
Example:
%XMP_StrRepl("AbcABCabc","ABC","Xyz")
%XMP_StrRepl("AbcABCabc","ABC","Xyz",1)
%XMP_StrRepl("XxXxXxXxXxXxXx","XX","x",1,1)
Output:
AbcXyzabc
XyzXyzXyz
x
|
|
%XMP_StrRev(Text)
|
Returns the "Text" in reverse order.
Example:
%XMP_StrRev("Hallo")
Output:
ollaH
|
|
%XMP_StrRight(Text, Count)
|
Returns a specific "Count" of characters from "Text", starting from the last character.
Example:
%XMP_StrRight("123456789",4)
Output:
6789
|
%XMP_StrTr(Text, Search, [Replace],
[Options])
|
Replaces all characters in "Text" that appear in "Search" with the corresponding characters in "Replace". This means the first character in "Search" is replaced by the first in "Replace", the second by the second, and so on.
If "Replace" is not specified or is empty, all characters in "Search" are removed from "Text". (Equivalent to option "D".)
The characters in "Search" and "Replace" must follow the %XMP_StrC notation, so special characters can also be used.
The "Options" parameter can use the following values:
D -> Removes all characters in "Search" from "Text". The "Replace" string is ignored.
L -> Makes the search case-insensitive.
Example:
%XMP_StrTr("HALLO","loh","104")
%XMP_StrTr("HALLO","loh","104","L")
%XMP_StrTr("Hallo","HL")
%XMP_StrTr("HALLO","Hl","XXX","DL")
Output:
HALLO
4A110
allo
AO
|
%XMP_StrTrim(Text, [LeftRight],
[CharTypes])
|
Removes all spaces and control characters at the beginning and/or end of "Text". Also removes character 160 (0xA0), sometimes used in HTML mails instead of a space.
To remove spaces only from the left or right, set "LeftRight" to "L" or "R".
The "CharTypes" parameter specifies which character types to remove. Options:
(Space) -> Removes all spaces, control characters, and character 160 (0xA0). This is the default.
A -> Removes all uppercase letters
a -> Removes all lowercase letters
1 -> Removes all numbers
! -> Removes all punctuation and printable special characters
8 -> Removes all 8-bit characters
S -> Removes all national special characters (from 0xBF)
Combinations are allowed, e.g., "Aa 1" for letters, spaces, and numbers.
Example:
|%XMP_StrTrim(" ABC ")|
|%XMP_StrTrim(" ABC ","L")|
|%XMP_StrTrim(" ABC ","R")|
%XMP_StrTrim("Betrag: 129,- Euro",""," Aa!")
%XMP_StrTrim("Betrag: 9,90 Euro",""," Aa!")
Output:
|ABC|
|ABC |
| ABC|
129
9,90
|
|
%XMP_StrWordCnt(Text)
|
Returns the number of words in the specified "Text".
Various punctuation and control characters are used as separators, including period, comma, semicolon, exclamation mark, question mark, and various brackets.
Example:
%XMP_StrWordCnt("Wort1, Wort-2!Wort3.Wort4 Wort_5")
Example Output:
5
|
|
%XMP_StrWrap(Text, [Width], [Alignment])
|
Wraps the specified "Text" at 70 characters. If "Width" is specified, wraps at that width.
Spaces, tabs, and hyphens are recognized as break points. Text inside double or single quotes is not broken!
The internal macro %WRAPPED only wraps the first paragraph. %XMP_StrWrap reformats the entire text.
The optional third parameter specifies text alignment. Options:
L -> Align left (default)
R -> Align right
C -> Center
J -> Justify
Example:
%XMP_StrWrap("%CLIPBOARD",35)
Example Output:
At the beginning of each macro description
the macro syntax is shown. Arguments in
square brackets can be omitted. In that case,
default values are used. Only the last arguments
can be omitted.
|
|
%XMP_UrlDec(URL)
|
Decodes special characters in the "URL" that were previously encoded with %XMP_UrlEnc.
Example:
%_TMP=#%XMP_UrlEnc("mailto:test@tester.com?subject=Test Subjekt")#%-
%_TMP
%XMP_UrlDec("%_TMP")%-
Output:
mailto%3Atest%40tester%2Ecom%3Fsubject%3DTest%20Subjekt
mailto:test@tester.com?subject=Test Subjekt
|
|
%XMP_UrlEnc(URL, [Type])
|
Encodes certain characters in the "URL" that cannot appear in a URL. Can also be used for "mailto:" links.
For example, the link "mailto:test@tester.com?subject=Das ist ein Test" would normally only set the subject to "Das", but encoding it as "mailto:test@tester.com?subject=Das%20ist%20ein%20Test" sets the full subject correctly.
The optional argument "Type" specifies the encoding type:
& -> Replaces all & with "&", otherwise uses hex encoding.
< or > -> Replaces "<" and ">" with "<" or ">", otherwise uses hex encoding.
+ -> Replaces spaces with "+", otherwise spaces are "%20".
Example:
%XMP_UrlEnc("Test & Test")
%XMP_UrlEnc("Test & Test","&")
%XMP_UrlEnc("Test & Test","&<")
%XMP_UrlEnc("Test & Test",">&")
%XMP_UrlEnc("Test & Test","+&<")
Output:
Test%20%3Caaa%40bbb%2Ecom%3E%20%26%20Test
Test%20%3Caaa%40bbb%2Ecom%3E%20&%20Test
Test%20<aaa%40bbb%2Ecom>%20&%20Test
Test%20<aaa%40bbb%2Ecom>%20&%20Test
Test+<aaa%40bbb%2Ecom>+&+Test
|
|
%XMP_XtrEMLs([Text], [Delimiter])
|
Extracts all email addresses from "Text" and returns them separated by "Delimiter".
If "Text" is empty or not specified, the message body is used. If "Delimiter" is not specified, Windows line breaks (0x0D + 0x0A) are used.
|
%XMP_XtrURLs([Text], [Delimiter],
[SearchText])
|
Extracts all URLs from "Text" and returns them separated by "Delimiter".
If "Text" is empty or not specified, the message body is used. If "Delimiter" is not specified, Windows line breaks (0x0D + 0x0A) are used.
The "SearchText" argument specifies a text inside the URL from which the length of the URL is determined. If found, the macro searches left and right for the first character not allowed in a URL. Default "SearchText" is "https://". Other values like "www." or "ritlabs.com" are also possible.
|
|