String macros
Advanced macros for working with strings.
%Chr
Параметры
%Chr(char number)
Описание
Character with specified decimal ASCII code. Allowed interval is 1..256.
Пример
%Chr("64")
%CountLines
Параметры
%CountLines(text)
Описание
Count number of lines in text. All lines, even empty, are counted.
Пример
%CountLines("to be or not to be
here is a question")
%CutHere
Параметры
%CutHere
Описание
Stands for "-- " string that should be inserted in every message right before the signature. It should be there to cut off the signature in quotation in other users' replies. Space character will be there 100%.
Пример
%CutHere
%GetLine
Параметры
%GetLine(line number, text)
%GetLine(line number, text, lines
count)
Описание
Extracts specified line from text. Number of first line is 1. If there's no line with this number, macro returns nothing. The third parameter may specify how many lines to return starting from Line number.
Пример
%GetLine("2","look, if you had
one shot, or one
opportunity")
%InputBox
Параметры
%InputBox
%InputBox(caption)
%InputBox(caption, default
value)
Описание
Displays input box so user can enter a string. Caption is text displayed in
the prompt. Default value is value that will be entered in the box right when it
opens. If user pushes Cancel the default value will be returned.
Warning!!! Use this macro only in quick templates that are
not called automatically! Otherwise The Bat! might halt.
Пример
%InputBox("Enter title:","Untitled")
%Numerical
Параметры
%Numerical(number, template 1, template 2, template
3)
%Numerical(number, template 1, template 2 and 3)
Описание
Analyses number and inserts it in one of templates instead of "^n". First
template is for number ending on 1 but not 11. Second - for numbers ending on 2,
3, 4 but not 12, 13, 14. Third - for all others. If 2-nd
and 3-rd templates are equal, you can specify it only once.
Пример
%Numerical("18","^n day","^n days")
%Prefix
Параметры
%Prefix(prefix, text)
Описание
Adds prefix to the beginning of each line of text.
Пример
%Prefix("| ","Any text can be here,
clipboard for
example.")
%ProgressBar
Параметры
%ProgressBar(black, white, width, min, max,
value)
%ProgressBar(black, white, width, percent)
Описание
Inserts text string representing progress bar of specified Width. Some part
of it is colored Black, other — White. Percentage of black
string width can be set as Minimum, Maximum and current Value, or just an
integer percentage as number between 0 and 100.
Пример
[%ProgressBar(":"," ","60","0","50","35")]
%RegExp
Параметры
%RegExp(regular expression, text)
%RegExp(regular expression, text,
mask)
Описание
Performs Regular Expression search in Text and returns the match. If Regular expression contains subpatterns, use Mask to access them. $1 in Mask will be replaced with first subpattern match, and so on.
Пример
%RegExp("\A(.+)@(.+)\Z","%FromAddr","User $1 at $2.")
%RegExpReplace
Параметры
%RegExpReplace(regular expression, text, replacement)
Описание
Replaces all Regular expression matches in Text with Replacement.
Пример
%RegExp("\d+","100 green bottles","A number of")
%SmartQuotes
Параметры
%SmartQuotes
%SmartQuotes(level)
%SmartQuotes(level,
crop)
Описание
Replacement for %Quotes macro for quoting original message. Unlike it
reformats quotes so that there's one single empty line between different levels
of quotes, automatically removes greetings and goodbyes, removes old quotes.
Parameter Level specifies the maximum depth of quotes to
leave (0 or no parameter — leave all). Second parameter Crop specifies wether
greetings and goodbyes should be removed (crops by default, 'no' for no
cropping).
To edit hello and goodbye words list go to
Options » Preferences… » Plug-Ins, select MyMacros and click Configure. Here is
a sample list:
Hello words:
hello
you wrote
wrote:
Hello regexps:
\d:\d\d:\d\d
hi[^a-z0-9]
Goodbye words:
-----Original Message-----
-----
Original Message -----
best regards
best
wishes
------------------------ Yahoo! Groups Sponsor
--------------------~--
Пример
%RegExp("\A(.+)@(.+)\Z","%FromAddr")%SubPatt="2"@%SubPatt="1"
%StrLen
Параметры
%StrLen(text)
Описание
Returns length of Text. This macro is useful with single-line Text, because new line is counted as 2 bytes (when you press Enter you actually enter 2 characters that all Windows text editors interpret as a command to move cursor to next line).
Пример
%StrLen("test line")
%StrReplace
Параметры
%StrReplace(text, find, replace)
Описание
Replaces all occurances of Find string in Text to Find string. Search is not case-sensitive. Should work fast on large texts.
Пример
%StrReplace("one two five two three","two","2")
%StrTr
Параметры
%StrTr(text, find alphabet, replace alphabet)
Описание
It's younger brother of %StrReplace. Use it when you have to replace single
characters to another single characters only! It repl aces
all characters from Find Alphabet in text to corresponding characters from
Replace Alphabet. Alphabets should be of equal size. Replace is case-sensitive.
Пример
%StrTr("Lift","FIfi","SAsa")
%TextBar
Параметры
%TextBar(prefix, sting, suffix, width)
Описание
Makes string of specified width in such way: prefix and suffix are added as
many times as it is needed to get required width. If string
length is larger that required one, it is not truncated.
Пример
%TextBar("=-","[ text ]","-=","70")
%Trim
Параметры
%Trim(text)
Описание
Deletes spaces, line returns and so on from beginning and ending of the Text.
Пример
|%Trim(" What a hell?
")|
Calculations
Macros dealing with number. Useful with The Bat! built in %Calc macro.
%CounterToDate
Параметры
%CounterToDate(format, counter)
Описание
Revese %DateToCounter. Converts number of days since 1 January 1900 to date
string. Format may contain yyyy, yy, mmm, mm, m, dd, d, hh, h, nn, n, ss, s.
Macro is experimental and is not guaranted to work
correctly.
Пример
%CounterToDate("nn.mm.yyyy, hh:nn:ss","123456.78")
%DateToCounter
Параметры
%DateToCounter
%DateToCounter(format, date)
Описание
N umber of days from 1 January 1900 to specified Date. Format may contain
yyyy, yy, mmm, mm, m, dd, d, hh, h, nn, n, ss, s. Time is interpreted as a
decimal part of counter, i.e. 1 Jan 1900, 12:00 will be 0.5.
Macro is experimental and is not guaranted to work
correctly.
Пример
%DateToCounter("yyyy-mm-nn hh:nn:ss","2004-08-01 18:56:32")
%DaysTo
Параметры
%DaysTo(date)
Описание
Number of days between today and specified Date. Input
date format can differ depending on your system locale. See your own format in
"Short Date" field in Regional Options found in Control Panel.
Пример
%DaysTo("23.02.04")
%DaysTo("23/02/04")
%Random
Параметры
%Random(min, max)
Описание
Random integer value between Min and Max inclusively.
Пример
%Random("5","10")
Loops
Iteration macros to execute templates multiply times.
%Eval
Параметры
%Eval(expression)
Описание
Processes expression with The Bat! template processor once again. It's easier to explain it in examples:
Пример
%Eval("%Subject")
In this case first of all
%Subject is processed by The Bat!. It is replaced with current message subject.
After that %Eval is called. It gets a simple string and does nothing about it.
Eval("%%Subject")
In this
case first of all %% macro is processed. It is replaced with %% string. Then
%Eval is called. It receives %Subject and processes it with The Bat!'s
interpreter. As a result it returns current message subject.
So the difference between these two examples is in order of
processing of macros. %Eval macro itself does not provide any useful
functionality, but all loop macros (%While, %For, etc.) are based on it, so it's
important to understand this idea of "%%".
%For
Параметры
%For(min, max, variable name, expression)
Описание
Executes given Expression (see %Eval) several times. Each time specified Variable is set to the following integer value between Min and Max.
Пример
%For("1","5","Iter","%%_Iter ")
%ForDown
Параметры
%ForDown(max, min, variable name, expression)
Описание
The same as %For. But it counts backwards.
Пример
%For("5","1","Cnt","%%_Cnt ")
%While
Параметры
%While(variable name, terminal value, expression)
Описание
Executes Expression (see %Eval) a number of times while specified Variable is
not equal to Terminal Value. Be careful!!! Do not make
endless loops!
Пример
%While("Abc","wwww","%%_Abc='w%%_Abc'%%_Abc ")
%Until
Параметры
%Until(variable name, terminal value, expression)
Описание
The same as %While, but check for loop termination is made after expression
is processed. Be careful!!! Do not make endless loops!
Пример
%Until("Xyz","wwww","%%_Xyz='w%%_Xyz'%%_Xyz ")
Lists of values
Macros for working with list of enumerated values.
%GetValueN
Параметры
%GetValueN(n, list)
%GetValueN(n, list, separator)
Описание
This macro returns N's value from list. List is a text string where you list
a set of values separating them with separator. Default separator is "," (coma),
but you can set any other, even multicharacter. You may
quote separated values from List with " or ' characters if they contain
separator.
You may use escape-sequences to prevent
characters from being interpreted as separators. "\n" and "\t" sequences are
recognized correctly as new line and tab respectively.
Note
that you can't write anything like macro in the following line, because
character " is used as delimiters of argument of %To macro and you can't use
them inside. It's The Bat! limitation.
%To="%GetValueN('2','"test, a","test2, b","test3,
c"')"
To prevent this you may use quick templates
like this (or external text files):
Macro:
%To="%GetValueN('2','%QInclude=`sample`')"
Quick template "sample":
"test, a","test2, b","test3, c"
Пример
%GetValueN("3","one, 'two\ntwo', 'third \' third \' third'")
%GetValueKey
Параметры
%GetValueKey(key, list)
%GetValueKey(key, list, key/value
separator)
%GetValueKey(key, list, key/value separator, row
separator)
Описание
Macro searches List keys for the Key and returns value for that key. If Key
wasn't found, it returns empty string. Default key and
value separator is "," (coma), you can change it. You can change row separator
as well, but default value of "\n", new line, might fit you mostly in all cases.
Пример
%GetValueKey("apple","
tomato => red
apple => green
lemon => yellow
","=>")
%GetValueRegExpKey
Параметры
%GetValueRegExpKey(key, list)
%GetValueRegExpKey(key, list,
key/value separator)
%GetValueRegExpKey(key, list, key/value separator, row
separator)
Описание
It's much like %GetValueKey macro, but keys in List are regular expressions.
Пример
%GetValueRegExpKey("andrew@microsoft.com","
'@microsoft\.' = you work for MS
'@.+\.microsoft\.' = you work for a department of MS
'@barin\.com\.ua\Z' = you work for me :)
","=")
Windows
Macros to cooperate with operating system.
%KeybLayout
Параметры
%KeybLayout(keyboard layout)
Описание
Switches current keyboard layout. It can be defined as 8-digit language code (like, 0000409 is English) or one of the following identifiers: BE, BG, CS, DA, DE, EL, EN, ET, IT, LT, LV, NL, NO, PL, PT, RO, RU, SL, UK.
Пример
%KeybLayout("EN")
%RegRead
Параметры
%RegRead(path to value)
%RegRead(path to value, default
result)
Описание
Returns string (STRING) or integer (DWORD) value from registry at Path.
If value doesn't exist, returns Defa ult Value.
Пример
%RegRead("HKEY_CURRENT_USER\Software\%-
\Microsoft\Internet Explorer\Main\Start Page")
%RegWrite
Параметры
%RegWrite(path to value, value)
%RegWrite(path to value, value, type
of value)
Описание
Sets specified value of registry at Path. Third
parameter is optional and specifies value type: "STR" for STRING, "INT" for
DWORD. Default is STR.
Пример
%RegWrite("HKEY_CURRENT_USER\A\B\C","123","STR")
%Run
Параметры
%Run(command line)
%Run(command line, window state)
%Run(command
line, window state, timeout)
Описание
Executes Command Line. Second optional parameter is for
Window State: HIDE, ACTIVE, ACTIVEMAX, ACTIVEMIN, NOTACTIVE, NOTACTIVEMIN.
Default is ACTIVE.
If third parameter is present, template
processing is suspended until application terminates or timeout occurs (in
milliseconds).
Пример
%Run("notepad.exe c:\boot.ini","ACTIVEMAX")
Winamp
Macros to watch Winamp activity.
%WinampStatus
Параметры
%WinampStatus
Описание
Returns state of WinAmp - one of those strings: OFF, STOPPED, PAUSED, PLAY.
Пример
%WinAmpStatus
%WinampTitle
Параметры
%WinampTitle
Описание
Returns title of media, loaded in WinAmp 2.xx/5.xx. Scrolling of media title in windows taskbar should be off!
Пример
%WinAmpTitle
Other
Macros that don't fit in a separate section :)
%CountAttachments
Параметры
%CountAttachments
Описание
Number of attached files.
Пример
%CountAttachments
%MyMacrosVersion
Параметры
%MyMacrosVersion
Описание
Returns version of MyMacros like "MyMacros N.xx".
Пример
%MyMacrosVersion
%OCountAttachments
Параметры
%OCountAttachments
Описание
Number of attached files in original message.
Пример
%OCountAttachments
%SubjIfNone
Параметры
%SubjIfNone(new subject)
Описание
Sets subject to New Subject if this field is empty yet.
Пример
%SubjIfNone="About MyMacros"
%ToIfNone
Параметры
%ToIfNone(recipient address)
Описание
Sets To field to Recipient Address if list of recipients is empty yet.
Пример
%ToIfNone="list@host.com"
* — свежак