Text Executive Programming Language

Last updated

In 1979, Honeywell Information Systems announced a new programming language for their time-sharing service named TEX, an acronym for the Text Executive text processing system. TEX was a first-generation scripting language developed around the time of AWK and used by Honeywell initially as an in-house system test automation tool.

Contents

TEX extended the Honeywell Time-Sharing service (TSS) line editor with programmable capabilities, which allowed the user greater latitude in developing ease-of-use editing extensions as well as writing scripts to automate many other time-sharing tasks formerly done by more complex TSS FORTRAN programs.

Overview

TEX was a subsystem of Honeywell Timesharing (TSS). Users would enter the TSS command tex to change to a TEX session mode of operation. TEX expressions could be entered directly on the command line or run from a script file via the TEX command call filename.

TEX programs are a collection of TSS line editing commands, TSS session commands, and TEX statements. TEX variables could be inserted into TSS commands, and TSS line editor commands via the TEX variable substitution feature. TEX programs were primarily designed to extend the line editor system. Consequently, TEX had no concept of file input/output relying instead on applying line edit commands to the working file and saving as needed.

The key developers of TEX at Honeywell were Eric Clamons and Richard Keys with Robert Bemer, famous as the father of ASCII and grandfather of COBOL, acting in an advisory capacity. [1]

TEX should not be confused with TeX a typesetting markup language invented by Donald Knuth.

The American Mathematical Society has also claimed a trademark for TeX, which was rejected because at the time this was tried (the early 1980s), "TEX" (all caps) was registered by Honeywell for the "Text EXecutive" text processing system. [2]

TEX Variables

All variables [3] were stored as strings and converted to integer numeric values when required. Floating point variables, arrays, or other datatypes common in current scripting languages did not exist in a TEX environment.

All variables were stored in a single global variable pool which users had to manage in order to avoid variable naming conflicts. There were no variable scoping capabilities in TEX. Variable names were limited to 40 characters.

TEX provided several internal read-only registers called star functions [4] which changed state when certain TEX string parsing operations were executed. Star functions provided a means to get the current date and time, resultant strings from a split or scan string parsing operation or from TEX internal call level and TSS session information.

The maximum length of a string value was 240 ASCII characters. This includes intermediate results when evaluating a TEX expression. Numeric string values are limited to 62 digits in the string, including the (-) for negative numbers. Numeric values are also normalized where leading zeros are stripped from the string representation.

Some examples of variable usage:

   _ we can use quotes or other characters as delimiters as long as the string doesn't contain them    _ and can use the comma operator to concat them together    _    a="hello"    b=/world/    c=a,/ /,b
   _ the out statement prints "hello world" to the terminal without quotes    _    out:c
   _ Using TEX variables in a line editing command to find a line containing "hello"    _ replacing the "hello" string with the "hello world" string    _    rs:a:c

TEX Operators

TEX has three types of operators: [5]

When constructing a TEX expression, all spaces must be compressed out except for string literals. In general, spaces delimit TEX statements.

    _ NOTE: In the "d=" statement, there are no spaces between the commas      _ or the variables     a="hello"   b=" "   c="world"   d=a,b,c   out:d
    _ In contrast, a space  is needed to separate the 'if' from its expression and      _ the expression from the next TEX command to conditionally execute     _     if a:eqs:"hello" out:a


TEX Arithmetic Operators

supports only basic integer arithmetic operations:

with up to 16 levels of parentheses.

Some examples are:

   a=1    b=-2    c=3*(a-b)/(2*2+(4+1))

TEX Boolean Operators

come in two flavors for:

They were most often used within the context of an IF control statement.

A list of available numeric comparison operators are:

A list of available string comparison operators are:

String boolean operators are affected by the TEX CASE mode. Under CASE mode, strings such as 'ABC' and 'abc' were considered equal (TEX converted 'ABC' to 'abc' prior to the comparison). Under NOCASE mode, the 'abc' string would be considered greater than the 'ABC' string based on the ASCII code point value for 'a' being a larger value than the 'A' ASCII code point value.

The boolean NOT operator was represented by the circumflex character (^). [8]

Some examples of boolean operators in action:

   if name:eqs:"luke"   out:"May the force be with you!"     if ^age:gtn:500  out:"Heh, you can't be Yoda!" 

TEX did not provide and or or connectors to make more complex boolean expressions. Instead, programmers had to use nested if statements for and connections and a block of if...do something statements to handle or connections:

   _ an example of an and construct    if a:eqs:'a'   if b:eqs:'b'  goto !its_true    goto !its_false     _ an example of an or construct    if a:eqs:'a'   goto !its_true    if b:eqs:'b'   goto !its_true    if c:eqs:'c'   goto !its_true    goto !its_false     !its_true out:"It's true!" goto !next_block    !its_false out:"It's false!" goto !next_block     !next_block    ...do something...

TEX String Operators

String concatenation in TEX was provided by the comma operator:

   a="hello"," "," world"

TEX provided several string-splitting operators: [9]

Some string-splitting examples:

   a="hello world"    b=a']5    c=a]'5     out:"It's a strange new ",c," but ",b," anyways!"


TEX provided several string scanning/parsing operators: [10]

Some string scanning/parsing examples:

   a="hello world"    b=a'>" "
   out:b

TEX Labels

All TEX statement labels were prefixed with a (!). [11] Statement labels were ignored unless referenced by a goto [12] or call [13] statement. One notable feature of TEX was the ability to call or goto labels in other files. Coupled with the TEX SUBS mode meant that TEX could create new scripts via line editing, save, and then call or goto labels in these scripts dynamically.

The mypgm.tex file:


   !hello    out:"hello world"    return     !hello2    out:"hello world again"    exit     (end-of-file marker)


Calling by label example:

   call /mycat/mypgm.tex!hello


In the above example, TEX would process the /mycat/mypgm.tex file searching for the !hello label(*). TEX would continue processing the file until a return statement or exit statement was executed, or an end-of-file was reached.

Goto by label example:

   goto /mycat/mypgm.tex!hello2


In the next example, TEX would process the /mycat/mypgm.tex file searching for the !hello2 label(*). TEX would continue processing until an exit statement or end of file was reached. An error would be thrown if a return statement was executed and there were no CALLs active.

(*) TEX did not check for duplicate labels in the same file, consequently execution was unpredictable if present.

TEX Substitutions

TEX provides the SUBS and NOSUBS commands to activate or deactivate variable substitution for TEX statements or TSS commands.


   xx=/out:"Hello World"/     subs ?     ?xx?           nosubs     ?xx?


In the above example, the xx variable contains a TEX output statement as its value. The subs command specifies that (?) is the substitution character for all future statements of the program. Upon processing the first ?xx? line, TEX will substitute the out:"Hello World" command for ?xx? and then execute the resultant statement. The nosubs command turns off substitutions for subsequent statements and so TEX issues an error when it tries to execute the second ?xx? line.

TEX Indirections

In addition to variable substitution, TEX supported variable indirection. Variables prefixed with the underscore character (_) were considered to contain a variable name as their contents and so TEX would use indirection to get the value. TEX limited indirection to 64 levels to avoid possible looping.

As an example:

   a="b"    b="c"    c="hello world"     _ here the out:__a would print "hello world" to the terminal,     _ since two underscore prefix of a means a >> b >> c    out:__a

TEX Input/Output

Honeywell Timesharing sessions had a concept of the working file. To edit an existing file, you would first make it the working file via the old command. To create a new file, you would first create it via the new command. Once changes were complete, you would either save (for new files) or resave the working file. Basically only one file could be open for editing at a time.

TEX programs were primarily designed to extend the line editor system. Consequently, TEX had no concept of file input/output relying instead on making changes to the working file via line edit commands and saving as needed.

However, TEX did provide terminal-oriented input/output commands:

A simple example using in and out:

   in:"What is your name?"     out:"Hi ",*in


TEX Star Functions

as a means to access results/side-effects of TEX subsystem functions or to represent ASCII terminal codes. [14]

A list of star variables follows:

TEX ASCII/Terminal Codes

Terminal codes were mapped into star variables for easy reference in TEX programs. [15]

Commands

TEX was built on top of the TSS line editor, as such line editor commands could be used within a TEX program. TEX programs may have:

TSS Line Editing Commands

The general command format was:

   verb:<search_expr>;<repeat_cnt>;<occurrence_cnt>:<replacement_string>

The search_expr could contain a range as in F:/hello/,/world/ to find all lines that start with the string "hello" and contain the string "world" too.

TEX provided standard line-based file editing commands:

Each command could be modified with a numeric repeat value or with an asterisk (*):

Commands can be further modified with a line matching string or expression:

For string mode, an S was added. Whenever /xxx/ was found within the line then the edit was applied:

Lastly, the commands can be further modified with V to turn on verify mode and with O to specify nth occurrence string mode:

There are a few other lesser used editing commands:

In all edit command formats, the /xxx/ or /yyy/ or 999 could be replaced with a TEX variable. In addition, the 999 value could be replaced with an asterisk (*) to denote all occurrences.

TEX Commands

TEX did not provide commands for numeric or conditional looping or switch cases as is common in modern scripting languages. These had to be constructed using if, labels and goto commands. As an example, to eliminate duplicate lines from a file, one would use:

   !ELIM_DUPS a=*cl f;1    _    !NEXT_LINE if *eof out:"task complete" return     b=*cl if a:eqs:b d;1 goto !NEXT_LINE     a=b f;1 goto !NEXT_LINE

TEX commands:

TEX Mode Changing Statements

TEX modes defined how other TEX commands would operate. [16] The *svmd variable contained the current state of all TEX modes in the form of TEX commands to restore the modes. Each mode had an inverse command to turn the mode off which could be done at any time.

TSS Commands

While beyond the scope of this article, the most commonly used TSS commands were:

TEX Examples

This code was excerpted from a TEX based Adventure game written by a team of Explorer Scouts from GE Post 635, Schenectady New York circa 1980. The Adventure game was the first of several popular online text-based adventure games available on the GE Timesharing service. The scouts decided to create their own adventure game using TEX. The original Adventure game used two word commands to navigate Colossal Cave. The parser shown below handled simple two word commands like go west or move right and converted them into x,y deltas for positioning and directional orientation in the game.

Parsing the Adventure two word commands:

   ...
   _ force a clear screen on the televideo terminal    !init     out:*esc,":"        _ clear program variables    rmdr=*null    del=0    dir="n"    xlocn=1    ylocn=1    return
   _ _______________________________________________________________    _    _ The PARSER subroutine interprets your input commands and tries to     _ pre-process them prior to returning to your program.    _    !parser    qry=*cr,*lf,"-->" sntc=*null call !ask1    ergo !unkn_cmd verb=ans vdel=0 goto !$ans$_cmd    _    !walk_cmd   del=2     call !move_to  return    !run_cmd    del=4     call !move_to  return    !fly_cmd    del=6     call !move_to  return    !swim_cmd   del=2     call !move_to  return    ...    !unkn_cmd   return
   !move_to call !ask3 if ans:eqs:*null goto !to_$dir$    ercall !to_same call !to_$ans$    _    !to_locn xlocn=xlocn+xdel ylocn=ylocn+ydel return    _    !to_f    !to_forward    !to_ahead    !to_same goto !to_$dir$    _    !to_b    !to_backward goto !inv_$dir$    _    !to_r    !to_right goto !rt_$dir$    _    !to_l    !to_left goto !lt_$dir$    _    !inv_south    !rt_northwest    !lt_northeast    !to_n    !to_north dir="north" xdel=0 ydel=del return    _    !inv_west    !rt_northeast    !lt_southeast    !to_e    !to_east dir="east" xdel=del ydel=0 return    _    !inv_north    !rt_southeast    !lt_southwest    !to_s    !to_south dir="south" xdel=0 ydel=-del return    _    !inv_east    !rt_southwest    !lt_northwest    !to_w    !to_west dir="west" xdel=-del ydel=0 return
   _ adjust delta speed if these words are spotted as in "go very fast"    !to_very vdel=vdel+1 goto !to_same    !to_fast del=del+vdel vdel=0 goto !to_same    !to_slow del=del-vdel vdel=0 goto !to_same
   _ ______________________________________________________________    _    _ The ASK subroutines get your terminal input and break it up depending    _ on the spaces. ask1 falls into ask2 and ask2 falls into ask3 then returns    _    _ rmdr holds remainder of input line, sntc holds remainder of current command sentence    _ sentences are terminated with a period. ans holds the current word being processed    _    !ask1 if rmdr:eqs:*null in:qry rmdr=*in sntc=*null    !ask2 if sntc:eqs:*null scan:rmdr:"." sntc=*l rmdr=*r]'1    !ask3 scan:sntc:" " ans=*l sntc=*r return

Rolling dice:

   _ _______________________________________________________________    _    _ The DICE subroutine rolls the dice for you and returns the answer    _ in the variable called DICE.    _    _ Input to the DICE subroutine is via the DICE variable as shown below :    _    _     1d6 - roll the 6-sided die once    _     3d8 - roll the 8-sided die 3 times    _     d%  - roll the 100-sided die once (percentage roll)    _    !dice if dice:eqs:"d%" dice="1d100"    scan:dice:"d" i=*l j=*r dice=0        !dice_1     k=*random if j:gt:9 k=k,*random    k=k/j dice=dice+*rmdr+1    i=i-1 if i:gt:0 goto !dice_1        clear i clear j clear k     return

Televideo screen codes:

   _ _______________________________________________________________    _    _ The following routines allow you to easily draw pictures on the    _ the Televideo 950 terminal.    _    _      xyplot: positions the cursor    _     _      gr:     turns graphics mode on    _    _      nogr:   turns graphics mode off    _    _      clear:  clears the screen    _    _      load:   used by xyplot to load the xytbl    _    !xyplot    ercall !load xytbl=xytbl    cx=(xytbl]'(x-1))']1    cy=(xytbl]'(y-1))']1    out:*ESC,"=",cy,cx,z    return    _    _    !load    xytbl=" !",/"/,"#$%&'()*+,-./"    xytbl=xytbl,"0123456789:;<=>?",*AT,"ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_"    xytbl=xytbl,"`abcdefghijklmnopqrstuvwxyz{|}~",*DEL    return    _    _    !gr nosubs    out:*ESC,"$" subs $    $*SVMD$ return    _    _    !nogr out:*ESC,"%" return    _    _    !clear out:*ESC,":" return


Notable TEX Features

The most notable feature in TEX was its SUBS mode allowing variable values to crossover and become executable code. It allowed a programmer to create new variables on the fly to be used in later TEX expressions in a LISP-like fashion. TEX also allowed programmers to create scripts on the fly via line editing, saving the content to file later to be executed as part of the current program using interfile call and goto statements. However, in most cases, these features were used to provide simple dynamic goto statements in code as seen in the Adventure game parser example. What other kinds of Artificial Intelligence constructs could be developed were never fully explored.

An example of creating variables on the fly and then using them to do an interfile goto.

   _ incorporate x,y,z into the global variable pool    cmd="x=1 y=2 z=3"    subs ?    ?cmd?
   _ next we modify mycat/mypgm_1_2.tex to say "hello world" we are writing some code to     _execute later in our script    _    old mycat/mypgm_1_2.tex    r:*cl:/!label_3 out:'Hello World'/    resave mycat/mypgm_1_2.tex
   _ lastly we subs in x,y,z and then evaluate the goto mypgm_1_2!label_3 which does an interfile goto    _    goto mycat/mypgm_?x?_?y?.tex!label_?z?


The TEX program above illustrates dynamic script creation and then execution via substitution, file editing and interfile goto. In effect, programs writing programs were possible although never done. In the above example, the mycat/mypgm_1_2.tex file would be executed at label_3 printing out "hello world".

Related Research Articles

<span class="mw-page-title-main">AWK</span> Programming language

AWK (awk) is a domain-specific language designed for text processing and typically used as a data extraction and reporting tool. Like sed and grep, it is a filter, and is a standard feature of most Unix-like operating systems.

sed Standard UNIX utility for editing streams of data

sed is a Unix utility that parses and transforms text, using a simple, compact programming language. It was developed from 1973 to 1974 by Lee E. McMahon of Bell Labs, and is available today for most operating systems. sed was based on the scripting features of the interactive editor ed and the earlier qed. It was one of the earliest tools to support regular expressions, and remains in use for text processing, most notably with the substitution command. Popular alternative tools for plaintext string manipulation and "stream editing" include AWK and Perl.

In computer science, control flow is the order in which individual statements, instructions or function calls of an imperative program are executed or evaluated. The emphasis on explicit control flow distinguishes an imperative programming language from a declarative programming language.

<span class="mw-page-title-main">C shell</span> Unix shell

The C shell is a Unix shell created by Bill Joy while he was a graduate student at University of California, Berkeley in the late 1970s. It has been widely distributed, beginning with the 2BSD release of the Berkeley Software Distribution (BSD) which Joy first distributed in 1978. Other early contributors to the ideas or the code were Michael Ubell, Eric Allman, Mike O'Brien and Jim Kulp.

<span class="mw-page-title-main">Atari BASIC</span> Dialect of the BASIC programming language

Atari BASIC is an interpreter for the BASIC programming language that shipped with the Atari 8-bit family of 6502-based home computers. Unlike most American BASICs of the home computer era, Atari BASIC is not a derivative of Microsoft BASIC and differs in significant ways. It includes keywords for Atari-specific features and lacks support for string arrays, for example.

Integer BASIC is a BASIC interpreter written by Steve Wozniak for the Apple I and Apple II computers. Originally available on cassette for the Apple I in 1976, then included in ROM on the Apple II from its release in 1977, it was the first version of BASIC used by many early home computer owners.

The syntax of the C programming language is the set of rules governing writing of software in the C language. It is designed to allow for programs that are extremely terse, have a close relationship with the resulting object code, and yet provide relatively high-level data abstraction. C was the first widely successful high-level language for portable operating-system development.

In some programming languages, eval, short for the English evaluate, is a function which evaluates a string as though it were an expression in the language, and returns a result; in others, it executes multiple lines of code as though they had been included instead of the line including the eval. The input to eval is not necessarily a string; it may be structured representation of code, such as an abstract syntax tree, or of special type such as code. The analog for a statement is exec, which executes a string as if it were a statement; in some languages, such as Python, both are present, while in other languages only one of either eval or exec is.

FOCAL is an interactive interpreted programming language based on JOSS and mostly used on Digital Equipment Corporation (DEC) Programmed Data Processor (PDP) series machines.

cmd.exe Command prompt program

Command Prompt, also known as cmd.exe or cmd, is the default command-line interpreter for the OS/2, eComStation, ArcaOS, Microsoft Windows, and ReactOS operating systems. On Windows CE .NET 4.2, Windows CE 5.0 and Windows Embedded CE 6.0 it is referred to as the Command Processor Shell. Its implementations differ between operating systems, but the behavior and basic set of commands are consistent. cmd.exe is the counterpart of COMMAND.COM in DOS and Windows 9x systems, and analogous to the Unix shells used on Unix-like systems. The initial version of cmd.exe for Windows NT was developed by Therese Stowell. Windows CE 2.11 was the first embedded Windows release to support a console and a Windows CE version of cmd.exe. The ReactOS implementation of cmd.exe is derived from FreeCOM, the FreeDOS command line interpreter.

HP Time-Shared BASIC is a BASIC programming language interpreter for Hewlett-Packard's HP 2000 line of minicomputer-based time-sharing computer systems. TSB is historically notable as the platform that released the first public versions of the game Star Trek.

Color BASIC is the implementation of Microsoft BASIC that is included in the ROM of the Tandy/Radio Shack TRS-80 Color Computers manufactured between 1980 and 1991. BASIC is a high level language with simple syntax that makes it easy to write simple programs. Color BASIC is interpreted, that is, decoded as it is run.

<span class="mw-page-title-main">Sharp EL-5120</span>

The Sharp EL-5120 is a scientific programmable calculator. It has about 1 KB of total RAM available to the user, and has 4 basic operational modes:

The syntax of JavaScript is the set of rules that define a correctly structured JavaScript program.

CMS EXEC, or EXEC, is an interpreted, command procedure control, computer scripting language used by the CMS EXEC Processor supplied with the IBM Virtual Machine/Conversational Monitor System (VM/CMS) operating system.

A batch file is a script file in DOS, OS/2 and Microsoft Windows. It consists of a series of commands to be executed by the command-line interpreter, stored in a plain text file. A batch file may contain any command the interpreter accepts interactively and use constructs that enable conditional branching and looping within the batch file, such as IF, FOR, and GOTO labels. The term "batch" is from batch processing, meaning "non-interactive execution", though a batch file might not process a batch of multiple data.

<span class="mw-page-title-main">Cosmos (operating system)</span> Toolkit for building GUI and command-line based operating systems

C# Open Source Managed Operating System (Cosmos) is a toolkit for building GUI and command-line based operating systems, written mostly in the programming language C# and small amounts of a high level assembly language named X#. Cosmos is a backronym, in that the acronym was chosen before the meaning. It is open-source software released under a BSD license.

SUPER BASIC, sometimes SBASIC for short, is an advanced dialect of the BASIC programming language offered on Tymshare's SDS 940 systems starting in 1968 and available well into the 1970s.

SDS BASIC, also known as CP-V BASIC, Batch BASIC or Sigma BASIC depending on the version, is a BASIC programming language compiler for Scientific Data Systems's (SDS) Sigma series mainframe computers, originally released in 1967. Xerox purchased SDS in 1969 and began rebranding it as Xerox Data Systems, and finally just Xerox, at which time the language became known as Xerox BASIC.

Wang BASIC is a series of BASIC programming languages for computers from Wang Laboratories. The term can be used to refer to the BASIC on any Wang machine, but is mostly associated with the versions on the Wang 2200 minicomputer series of the early 1970s. When these machines were updated to the VP series in 1976, BASIC-2 was introduced and remained the pattern for future machines in the 2200 series. A planned BASIC-3 was never released.

References

  1. Introduction to TEX, p.144 Interface Age - Aug 1978
    • Donald E. Knuth. The TeXbook (Computers and Typesetting, Volume A). Reading, Massachusetts: Addison-Wesley, 1984. ISBN   0-201-13448-9.
  2. Honeywell DF72 Chapter 3.1
  3. Honeywell DF72 Chapter 3.4
  4. Honeywell DF72 pg 3-16
  5. Honeywell DF72 pg 3-18
  6. Honeywell DF72 pg 3-19
  7. Honeywell DF72 pg 3-16
  8. Honeywell DF72 pg 3-21
  9. Honeywell DF72 pg 3-22 thru 3-30
  10. Honeywell DF72 pg 4-2
  11. Honeywell DF72 pg 4-6
  12. Honeywell DF72 pg 4-3
  13. Honeywell DF72 pg 3-7
  14. Honeywell DF72 pg 3-10
  15. Honeywell DF72 Chapter 6