Content-Type: text/html

# TECO/Example

HomePage | TECO | RecentChanges | Preferences
You can edit this page right now! It's a free, community project

Example TECO Program

This is a simple interchange sort of the current text buffer, based on 1st character of each line, taken from the PDP-11 TECO User's Guide. A "goto" and "structured" version are shown. Note that TECO ignores case and whitespace (except tab, which is an insertion command).

Example 1

      !START! j 0aua               ! jump to beginning, load 1st char in register A !

      !CONT! l 0aub                ! load first char of next line in register B !

      qa-qb"g xa k -l ga 1uz '     ! if A>B, switch lines and set flag in register Z !

      qbua                         ! load B into A !
      l z-."g -l @o/CONT/ '        ! loop back if another line in buffer !

      qz"g 0uz @o/START/ '         ! repeat if a switch was made on last pass !

Example 2

      0uz                             ! clear repeat flag !
      <j 0aua l                       ! load 1st char into register A !

      <0aub                           ! load 1st char of next line into B !

      qa-qb"g xa k -l ga -1uz '       ! if A>B, switch lines and set flag !

      qbua                            ! load B into A !
      l .-z;>                         ! loop back if another line in buffer !

      qz;>                            ! repeat if a switch was made last pass !

HomePage | TECO | RecentChanges | Preferences
You can edit this page right now! It's a free, community project
Edit text of this page | View other revisions
Last edited August 8, 2001 5:16 am (diff)
Search: