The code at callout B starts a While loop that waits for a hex dump to be copied to the clipboard. This code uses the WaitForChange() method so that the script pauses until a change is made to the clipboard. In this instance, however, no timeout value is specified, so the script will wait indefinitely for a change.
After a change is detected, the While loop code runs. This code first checks to see whether the clipboard contains text. When the clipboard doesn't contain text (e.g., you copy a graphic image), the While loop continues to wait for a change. When the clipboard does contain text, a Foreach loop begins, as callout C shows. The Foreach loop enumerates each line of text in the clipboard. It does so by calling the Get() method to retrieve the clipboard's text, which it separates into rows using a carriage return (\n) as the delimiter.
As the Foreach loop processes each line of text, the code at callout D splits each row of text into three components—an offset value, a list of hex bytes, and ASCII data—using a regular expression (regex). When the loop fails to find these components, it moves on to the next row. When the loop finds these components, it assigns them to the scalar variables of $Offset, $Hex, and $Display, respectively. For the remainder of the script, only $Hex is used. The remaining $Offset and $Display variables are ignored; their real function was to help parse out the $Hex component. . . .
Nukeice March 23, 2007 (Article Rating: