Text Variations

version 4 by Jon Ingold

  • Home page
  • Beginning
  • Previous
  • Next



  • Part 5 - Doing the printing

    To finalise print line, cycling, stopping, once only, sticky random or at random:
        complete line;
        let k be the hash of the buffer;
        if k is zero, stop; [ ie. There was no text stored up. ]
        let k be the row with hash k;
        if k is not zero begin;
            choose row k in the Table of Hash Numbers;
        otherwise;
            if the number of blank rows in the Table of Hash Numbers is 0 begin;
                say "(TV Error - increase size of Table of Hash Numbers)";
                sort Table of Hash Numbers in index order;
                choose row 5 in the Table of Hash Numbers;
                blank out the whole row;
            end if;
            choose a blank row in the Table of Hash Numbers;
            change hash entry to the hash of the buffer;
            change index entry to 0;
        end if;
        if once only begin;
            if the index entry is not 0, stop;
            change the index entry to 1;
            print line using index entry;
            stop;
        end if;
        if upper buffer limit is 0, say "error - empty buffer";
        if upper buffer limit is at most 1 begin;
            print line using 1;
            stop;
        end if;
        if sticky random begin;
            if the index entry is 0, change the index entry to a random number from 1 to the upper buffer limit;
            print line using index entry;
            stop;
        end if;
        if at random begin;
            let choice be a random number from 1 to the upper buffer limit;
            while choice is the index entry repeatedly let choice be a random number from 1 to the upper buffer limit;
            change index entry to choice;
            print line using index entry;
            stop;
        end if;
        if stopping begin;
            change index entry to index entry + 1;
            if index entry > upper buffer limit then change index entry to upper buffer limit;
            print line using index entry;
            stop;
        end if;
        if cycling begin;
            change index entry to index entry + 1;
            if index entry > upper buffer limit then change index entry to 1;
            print line using index entry;
            stop;
        end if;

    Table of Hash Numbers
    hash  index  
    a number  a number  
    with 99 blank rows.