The count command adds the value of the counter variable to the end of the workspace buffer.
For example, if the counter variable is 12 and the workspace contains the text 'line:', then after the count command the workspace will contain the text
read; [\n] { a+; count; add ": "; } print; clear;
pep -e "read; [\n] {a+; count; add ': '; } print;clear;" filename
pep -e "r;[\n]{+;n;a': ';}t;d;" filename
pep -f tr/ ??translate.java.pss \ ??
-e "read; [\n] {a+; count; add ': '; } print; clear;" > Machine.java
javac Machine.java
cat / ??usr/ ??share/ ??dict/ ??words | ?? java Machine
note: it would be simpler to use the lines
command in this example
read; [\n] { lines; add ": "; } print; clear;
read; "." { a+; } clear; <eof> { count; print; }
The count command only affects the 'workspace' buffer in the Pep virtual machine . The pep machine also maintains an automatic count of the
For counting lines and characters in the
input-stream, the commands lines
chars", “nolines” and “nochars” exist.
read;
"\n" {
while [ \t\r]; clear;
!(eof) { read; "\n" { a+; }}
}
clear;
(eof) {
add "Blank lines: "; count; add "\n";
print; quit;
}