=== Using AID on TWENEX.ORG ===
== Introduction ==
"AID (for Algebraic Interpretive Dialog) is a PDP-10 adaptation of language elements of JOSS". Like JOSS (JOHNNIAC Open Shop System), AID was designed to be an easy-to-learn language to help scientists and engineers with solving complex numerical problems. "Commands are typed in imperative English sentences and mathematical expressions are typed, for the most part, in standard notation" (DEC 1970, p. 4-7).
Like JOSS, AID is restricted to numeric calculations and has little provision for symbolic manipulation. In this regard, AID may be considered akin to the //bc// calculator language. Charles L. Baker (one of the creators of JOSS) wrote that "JOSS is __not__ a programming language..." (Baker 1966. p. 2), but rather a special-purpose system, drawing comparison to a desk calculator. At the time he wrote that, JOSS was somewhat a system, as it was tied to specific, expensive hardware (Baker 1966).
Whether AID is a 'language' or not is beyond the scope of this document. The purpose of this tutorial is to introduce AID to the reader and point out some of the particularities of using it on TWENEX.ORG. For the most part, AID is very similar to JOSS, and interested readers are invited to consult the works listed in the bibliography below. Appendices to this document provide details specific to AID; such as its character set, built-in functions, and commands. Much of the following borrows from the "PDP-10 timesharing handbook" (DEC 1970).
== Running AID ==
AID is started on TWENEX.ORG by typing "AID" at the EXEC prompt. AID will respond with a welcome message and an asterisk prompt.
@AID
AID (14-MAR-69) AT YOUR SERVICE ...
*
According to the DEC Timsharing Manual (TOPS-10), AID is terminated and control is returned to Monitor [EXEC] level by sending a CTRL-C. This, however, throws an error on TWENEX.ORG---which appears harmless.
*↑C
?PA1050: Illegal instruction 6,,0 at user 0
@
== Interacting with AID ==
A user interacts with AID by typing single-line commands called "steps" which are entered at the asterisk (*) prompt. Each step occupies a single line, begins with a capitalized command (verb), and terminates with a period. (The last two attributes are a matter of style and are optional in AID.) There are two types of steps in AID: //direct// steps and //indirect// steps.
A direct step is interpreted and executed by AID immediately following a carriage return.
*Type 2+2.
2+2 = 4
*
An indirect step is entered by preceding the step with a numeric label containing both an integer and decimal portion (e.g., 1.1, 2.53). Preceding a step with a numeric label signals AID that the step is to be stored for later execution.
Steps can be grouped into "parts." All steps that share the same integer portion are members of the same part; for example:
*1.1 Type "X VALUES".
*1.2 Type x.
*1.3 Type x*2, x/2, x^2.
*
Individual steps or parts are executed with the DO command. Only the step or part specified by DO is executed; AID does not continue to other steps or parts unless specifically instructed to. Here we will use the SET command directly to assign the value of 3 to x, and the DO command to execute the indirect steps of part 1.
*1.1 Type "X VALUES".
*1.2 Type x.
*1.3 Type x*2, x/2, x^2.
*Set x = 3.
*Do part 1.
X VALUES
x = 3
x*2 = 6
x/2 = 1.5
x^2 = 9
*
== Variables ==
The SET command in the previous example assigned a value of 3 to X which is evaluated only once. In contrast, had the LET command been used, X would have been re-evaluated each time it is referenced (see Appendix 3). In AID, "identifiers" (variables) are represented by single alphabetic characters to which arithmetic or logical values have been assigned. There are 52 unique identifiers available (A though Z, and a through z), which may also be used to identify user-defined functions. Identifiers (variables) may be indexed by one to ten subscripts to create vectors and multidimensional arrays, with each subscript being an integer in the range of -250 to +250. For example,
*Set b = 2.0.
*Set c(1,2) = 6.
*Set d(-4,0,8) = 3.14
*Type b + c(1,2) + d(-4,0,8).
b + c(1,2) + d(-4,0,8) = 11.14
*
== Propositions ==
Propositions in AID are Boolean expressions composed of arithmetic or logical statements using:
* Relational operators
* = (equal)
* # (not equal)
* > (greater than)
* < (less than)
* >= (greater than or equal to)
*
*Set x = true.
*Set y = false.
*Let z = (x) and (y) or (x) and (100 > sqrt(959)).
*Type z.
z = true
*
Commands can be made conditional by appending IF clauses and propositions; e,g.,
*1.1 Set b = 50 if a > 100.
*1.2 To part 2 if c <= 0.
*
== User-defined Functions ==
User-defined functions take the form f(a,b,c,...)=expression, where
* f is the function identifier,
* (a,b,c,...) are dummy arguments (up to ten),
* expression is the arithmetic expression representing the user function.
While the number of dummy arguments is limited to ten, you can also pass subscripted identifiers to user-defined functions.
User-defined functions can also contain conditional expressions. A conditional expression allows a function to return different values depending upon which of a number of conditions is true. It is composed of a series of clauses separated by semicolons, with each clause made up of a proposition followed by a colon followed by an expression. The last proposition may be omitted if the last expression is to be the default for all cases that do not satisfy any of the previous propositions. The entire expression must be enclosed by parentheses or brackets. For instance:
*Let f(x) = (x<0: 0; 0<=x<1: x^2; 1).
*Type f(-3), f(0.25), f(0.5), f(0.75), f(3).
f(-3) = 0
f(0.25) = .0625
f(0.5) = .25
f(0.75) = .5625
f(3) = 1
*
== Formatting Output ==
AID provides for greater control over output format with "forms." Forms allow you to specify (1) the notation (fixed or scientific) of results, (2) multiple results per line, (3) any text to be interspersed with the results, and (4) report-type headings. (The FORM command is described in Appendix 3). Let's redo an earlier example, but incorporating forms. In this example, the forms are specified with direct steps following part 1, and referenced in indirect steps 1.2 and 1.3.
*Delete all.
*1.1 Type "X VALUES".
*1.2 Type form 1.
*1.3 Type x, x*2, x/2, x^2 in form 2.
Form 1:
* X X*2 X/2 X^2
*Form 2:
* ___.__ ___.__ __.___ ___.__
*Set x = 3.
*Do part 1.
X VALUES
X X*2 X/2 X^2
3.00 6.00 1.500 9.00
*
Combined with iterative clauses, using forms is a convenient way to make tables. Let's take the previous example a bit further by asking the user for a range of values for x (with the DEMAND command) and making a table with a row for each value of x. (See Appendix 2 for more information on iterative clauses.) While we are at it, let's make some user-defined functions. In this example, we will define the functions with direct steps; that way they will not be redefined each time the code is executed. In addition, by defining the functions with direct steps, they can be redefined without modifying the indirect steps or parts. This example also breaks the code into two parts: part 1 for input, and part 2 for output. Although clearly inefficient coding, this shows the use of parts as subroutines. Part 1 calls part 2, which upon completion, returns control back to part 1, where execution terminates.
*Delete all.
*
*1.1 Demand m as "Lower limit".
*1.2 Demand n as "Upper limit".
*1.3 Do part 2.
*
*2.1 Type "X VALUES".
*2.2 Type form 1.
*2.3 Do step 2.5 for I = m(1)n.
*2.4 Done.
*2.5 Type I, f(I), g(I), h(I) in form 2.
*
*Form 1:
* X X*2 X/2 X^2
*Form 2:
* ___.__ ___.__ __.___ ___.__
*
*Let f(x) = x*2.
*Let g(x) = x/2.
*Let h(x) = x^2.
*
*Do part 1.
Lower limit = *-5
Upper limit = *5
X VALUES
X X*2 X/2 X^2
-5.00 -10.00 -2.500 25.00
-4.00 -8.00 -2.000 16.00
-3.00 -6.00 -1.500 9.00
-2.00 -4.00 -1.000 4.00
-1.00 -2.00 -.500 1.00
.00 .00 .000 .00
1.00 2.00 .500 1.00
2.00 4.00 1.000 4.00
3.00 6.00 1.500 9.00
4.00 8.00 2.000 16.00
5.00 10.00 2.500 25.00
*
== File Operations ==
File I/O in AID appears to be limited to the storage and retrieval of AID items in specially formatted files akin to a workspace file.
The four commands most used for file I/O in AID are:
* USE: makes an external storage file available for use.
* FILE: stores an item in the external storage file currently in use.
* RECALL: reads an item previously stored by a FILE command.
* DISCARD: deletes an item from the external storage file currently in use.
These commands are described in Appendix 3.
In what seems to be an attempt to be faithful to its JOSS roots, AID file-names are restricted to positive integers (ranging from 0 to 2750). However, on TOPS-20, AID will prefix the file-name on the physical device with "QQ" and attach a ".J01" extension. For example, using a file named "100" in AID will create (or open) a file named "QQ0100.J01" in your default directory.
Let's create a file, and save the parts, formulas, and forms from the previous example.
*Use file 100.
Roger.
*File all parts as item 1.
Done.
*File all formulas as item 2.
Done.
*File all forms as item 3.
Done.
*
To retrieve items, you use the USE and RECALL commands. Here we will USE file 100, TYPE its ITEM-LIST, and RECALL the three previously saved items. To make sure we got everything, we will TYPE ALL that is in immediate storage.
*Delete all.
*Use file 100.
Roger.
*Type item-list.
ITEM-LIST
ITEM DATE
1 30-JUN-69
2 30-JUN-69
3 30-JUN-69
*Recall item 1.
Done.
*Recall item 2.
Done.
*Recall item 3.
Done.
*Type all.
1.1 Demand m as "Lower limit".
1.2 Demand n as "Upper limit".
1.3 Do part 2.
2.1 Type "X VALUES".
2.2 Type form 1.
2.3 Do step 2.5 for I = m(1)n.
2.4 Done.
2.5 Type I, f(I), g(I), h(I) in form 2.
Form 1:
X X*2 X/2 X^2
Form 2:
___._^ ___._^ __.__^ ___.__
f(x): x*2
g(x): x/2
h(x): x^2
*
(Hmmm, it looks like AID has a Y2K issue.)
It does not appear that AID reads from or writes to plain-text files---at least not directly. For smaller amounts of text, copy-and-paste is one option to transfer text to/from AID. Session logging is another option for saving output from AID. On TOPS-20, you can use batch processing to run AID and redirect I/O from and to other files (see"TOPS-10/TOPS-20 Batch Reference Manual"). Appendix 4 provides a simple example of running AID as a batch job under TOPS-20.
== Bibliography & Resources ==
Baker, C. L. 1966. JOSS: Introduction to a Helpful Assistant. RAND Corporation. Santa Monica, California.\\
http://archive.org/details/bitsavers_randjossRMAug67_4199822
Gimple, E. P. 1967. JOSS: Problem Solving For Engineers. RAND Corporation. Santa Monica, California.\\
http://archive.org/details/bitsavers_randjossRMlvingForEngineersMay67_3293549
Marks, S. L. and G. W. Armerding. 1967. The JOSS Primer. RAND Corporation. Santa Monica, California.\\
http://archive.org/details/bitsavers_randjossRMAug67_4199822
PDP-10 timesharing handbook. Book 4: Conversational Programming with AID. Digital Equipment Corporation. Maynard, Mass. [c1970] \\
http://www.worldcat.org/title/pdp-10-timesharing-handbook/oclc/486624
TOPS-10/TOPS-20 Batch Reference Manual. Digital Equipment Corporation. Maynard, Mass. 1988.\\
http://archive.org/details/bitsavers_decpdp10TOksvol02AAH374BBatchReferenceManualNov88_7913653
--------
== Appendix 1. AID Character Set ==
^ Standard Math Symbol ^ AID Symbol ^ JOSS Symbol ^
|A-Z |A-Z |A-Z |
|a-z |a-z |a-z |
|0,1-9 |0,1-9 |0,1-9 |
| Operators |||
|%%| |%% (absolute) |! ! |%%| |%% |
|[ ] (brackets) |[ ]|[ ]|
|( ) (parentheses) |( ) |( ) |
|xe (exponent) |↑ or
+Y | |-------------. X,Y | . : | . : | . : | . : | . : | . )arg(x,y) : |________________ +X 0,0The value of arg(0,0) is 0. The range of arg is 0 through 2pi or -pi through pi. --- **cos(x)** The COSINE function requires one argument, assumed to be in radians.
*Do step 2.3 for A = 1(2)12.
*Type sum(A = -50(B)C).
3. //Combinations://
A range can be expressed as a combination of value series and increments.
For example:
*Do part 3 for W = 20(Y)50(5)500, 1000(100)Z.
(Part 3 will be performed for all values of W, beginning with 20, continuing in increments of Y though 50, then continuing in increments of 50 through 500, and then from 1000 in increments of 100 through Z.)
*Type sum(W = A(3)B, C, 800(D)1500).
(The SUM function will be applied to all values of W, beginning with A and continuing in increments of 30 through B, then C, followed by 800 through 1500 in increments of D.)
---
--------
== Appendix 3. AID Command Summary ==
**CANCEL:** Cancels a currently stopped process when the user does not desire to resume execution.
Type: D,O.
**(CANCEL):** Cancels a currently stopped process which was initiated by a parenthetical DO.
Type: D,O.
---
**DELETE:** Erases the specified item from immediate storage and frees the space by it for some other use. Several DELETE commands can be combined into one.
Format: DELETE {
* L
* S
* S(m,n)
* form m
* step m.n
* part m
* formula f
* all steps
* all parts
* all formulas
* all forms
* all values
* all
}.
Type: O.
---
**DEMAND:** Causes AID to type out a message requesting the user to supply a value for the specified item. Only one variable can be specified in each DEMAND
command.
Format: DEMAND {
* L
* S(m,n)
* L as "any text"
* S(m,n) as "any text"
}.
Type: I,O.
---
**DISCARD ITEM m (code):** Delete item #m from the external storage file currently in use. (Code) is optional.
Type: F.
---
**DO:** Executes an indirect step or part. If the DO command is a direct step, control returns to the user at the completion of the DO; if an indirect step, control returns to the step following the DO.
Format: DO {
* step m.n
* step m.n, p times
* step m.n for L=range
* part m
* part m, p times
* part m for L=range
}.
Type: O.
**(DO ...):** Initiates a new execution without canceling the currently stopped process.
Format: (same as above).
Type: (same as above).
---
**DONE:** Skips execution of the remaining steps of a part during the current iteration.
Type: I,O.
---
**FILE:** Stores the specified item in the external storage file currently open. Immediate storage in not affected in any way. (code) is optional. (NB. use of the code option may cause a run-time error on the version of AID in the Panda Distribution.)
Format: FILE {
* L
* S
* S(m,n)
* from m
* step m.n
* part m
* formula f
* all steps
* all parts
* all formulas
* all forms
* all values
* all
} AS ITEM n (code)\\
where //n// is an item number in the range of 1 through 25.
Type: F.
---
**FORM:** Defines a format to be used in presenting typeouts for purposes of readability. The FORM command is followed by a form number, a colon, a new-line, and the format specification.
Fixed point notation (up to nine digit positions plus the decimal point) is specified by a series of 'null item' characters (← or underscore), a decimal point, and more 'null item' characters. e.g.,
; Run AID.
@R AID
; Load our previously saved program parts and forms.
*Use file 100.
*Recall item 1.
*Recall item 2.
; Run the program.
*Do part 1.
; Supply user input to the program.
*-10
*10
; Terminate AID with a CTRL-C.
*^c
Next, //submit// the job; e.g.,
@submit my_job.ctl
Wait for TOPS-20 to tell you that your job is ready.
[Batch job MY_JOB queued, request #32, limit 0:05:00]
@
[From SYSTEM: Job MY_JOB request #32 finished executing at 16:51:10]
Review the log file. Your output, if any, is there. (If you were expecting output, but didn't receive any, there was likely an error. Review the log file for clues.)