Pep and Nom

home | documentation | examples | translators | download | blog | all blog posts

the ℕ𝕠𝕞 "nochars" command

Set the automatic character counter register to zero (i.e. to nochars*)

Everytime that a character (Unicode we hope) is read from the input stream, (by the nom commands read or while or whilenot or until ) the character counter register in the pep virtual machine is incremented by one.

The “nochars” command sets the automatic character counter to zero. This is useful for making the character number relative to the line number. This is often more helpful than having a character count that starts from the beginning of the input stream. For example at the beginning of a script, we can put

break lines that are longer than 40 characters


    read; [\n] { nochars; } print; clear; 
    chars; "60" { clear; add "\n"; print; }
    clear;
  

show the line and (line-relative) character number of 'z's in input


    read; 
    "\n" { nochars; }
    "z" { 
      add "\n[Found a 'z' at line: "; lines; add ", char: "; chars;
      add "]\n";
    }
    print; clear;