|
|||||
|
|||||
Related Concepts | |||||
built-in variable |
#current-input |
Purpose
#current-input is a built-in source which represents the unconsumed part of the input currently being processed by a submit or scan.
#current-input can be used like any other built-in source such as #main-output
, so long as it is used in the context where scanning or find rule processing is in progress.
Using #current-input has the effect of consuming the remaining data from a source, unless you submit or scan #current-input, in which case the original data is consumed normally by the new scan or find rules process. If that process terminates before consuming the entire source, the original process resumes and continues until the source is completely consumed.
The following code shows what happens when #current-input is output or assigned to a variable:
process submit "Mary had a little lamb." find "Mary" white-space+ output #current-input find "lamb" output "Baa baa black sheep."
The program will output "had a little lamb." It will not output "Baa baa black sheep.", because after "Mary" whitespace+ is matched, the rest of the input is consumed by the line "output #current-input", so the "lamb" rule never fires.
The following code shows what happens when #current-input is scanned:
process submit "Mary had a little lamb." find "Mary" white-space+ output "David " repeat scan #current-input match "had" white-space+ output "stole " match "a" white-space+ output "my " again find "lamb" output "sheep"
This program will output "David stole my little sheep." The characters "Mary " and "little lamb." were processed by the find rules invoked by the original submit. The characters "had a " were processed by the repeat scan of #current-input. That repeat scan exited when it failed to match "little lamb.", leaving those characters unconsumed, and available for processing by the original find process.
Note that while OmniMark's other built-in sources, #main-input
and #process-input
are always attached at the beginning of a program (unless you declare no-default-io
), #current-input is only attached in a scope created by a submit
or scan
.
Related Concepts Pattern matching, nested |
Copyright © Stilo International plc, 1988-2008.