The scan and copy process is controlled by simple commands contained in the string list Commands. The commands are interpreted and executed in a linear way starting with the first command through to the last command (except for loops). A cursor which points to the input stream can be moved freely by various commands (including a "find" command). At any position parts of the input stream may be copied (after an optional procession step) to the output stream. ExtractFromStream starts the extraction at the current position of the input stream InStream (previous versions automatically set the input stream position to zero). This allows to apply the same extraction script for several times.
# |
any comment. A # character as the first character
in a command line marks the line as a comment line. |
$xx |
The command $xx identifies an ASCII character in
hexadecimal notation (xx is the hex value of the character). Please note
that the $ command always has to be followed by exactly 2 hex digits. In
order to use a dollar character in a command line you have to use $24 (24
is the hexadecimal ASCII code for the $ character). |
ConvertByte M N |
sets the conversion table for the byte M such that it is translated to N. M and N are decimal values. |
CopyAbs M N |
copy bytes between marks M and N (including the marked positions) to the output stream. The stream position points to mark N after the copy operation |
CopyAll |
copy the entire input stream to the output stream. The stream position points to the end of the input stream after the copy operation. Please note that the results of CopyAll are affected by the character conversion table. |
CopyRel NUM |
copy NUM bytes to output stream from current
position |
DelLast NUM |
delete last NUM characters from the output stream |
EndPos |
set cursor to last byte of the stream |
Find
TXT |
find next occurrence of TXT, starting from the current cursor position. The search is not case-sensitive. The cursor points to the next byte after the found string. If no TXT string is found the pointer is left unchanged. Note that the commands IfFound and IfNotFound can be used to execute conditional statements after a Find
command. |
FindWithin NUM TXT |
find next occurrence of TXT within NUM characters from current cursor position. The search is not case-sensitive. The cursor points to the next byte after the found string. If no TXT string is found the pointer is left unchanged. Note that the commands IfFound and IfNotFound can be used to execute conditional statements after a Find command. |
IfFound...EndIf |
statements between IfFound and EndIf are executed only if the previous Find command was
successful. |
IfNotFound...EndIf |
statements between IfNotFound and EndIf are executed only if the previous Find command was not
successful. |
IncPos
NUM |
increment cursor by NUM characters (NUM may also be negative) |
Insert TXT |
insert TXT into output stream. TXT is not affected by the conversion table. |
InsertByte BYTE |
inserts a byte into the output stream. BYTE is the decimal representation of the byte to be inserted. |
InsertDate FORMAT |
inserts the current date and time into the output stream. FORMAT specifies the format of the date/time string to be inserted. The syntax of the FORMAT specification complies with the syntax of the Delphi FormatDateTime procedure (see DtFormat for a detailed description). |
Label LBL |
Defines a loop label (LBL = 0..9) |
LoadConvTab FName |
load conversion table from file FName. Format: 16 lines of 16 hexadecimal entries, each
representing the resulting value of the conversion for the addressed byte
(the byte of the input stream forms the address into the conversion
array). |
Loop
LBL NUM |
loop NUM times to lable LBL. The Loop command can only jump to labels which are defined before it (jump back) since the extraction script is interpreted in a linear way from top to bottom. If the end of the input stream is encountered before the loop is finished, the loop is stopped. If NUM is zero, the loop is repeated until the entire input stream is read. Note that the loop can be stopped by the command EndPos (which sets the cursor to the end of the input stream). |
MakeLower |
sets conversion table to produce lower case
characters |
MakeUpper |
sets conversion table to produce upper case
characters |
MoveTo
M |
move cursor to mark M (M = 0..9) |
NoConversion |
resets conversion table in order to switch off
conversion |
ResetPos |
reset cursor to the beginning of the stream |
SetMark M |
store current cursor position in one of 10 possible marks (M = 0..9). Please note that the marks are persistent between calls to ExtractFromStream ; thus they may be used as
position markers across repeated calls of
ExtractFromStream. |
A powerful feature of ExtractFromStream is the application of a character conversion table. Whenever data is copied to the output stream, each byte is converted by means of a conversion table. Thus it is easy to replace certain characters. By default, the conversion table is set in a way that no conversion takes place.