1  MYDRAFT.STY The DO-language REFERENCE MANUAL LUTZ MULLER, SAN SALVADOR, JUNE/16/1983 The Do-language Reference Manual  INDEX ELEMENTS OF THE DO-LANGUAGE Characters ....................... 1 ASCII-constants .................. 1 Hex-constants .................... 1 Numerical constants .............. 2 Identifiers ...................... 2 Numerical expressions ............ 2 Logical expressions............... 3 List expressions ................. 3 Indexing ......................... 4 THE DO SYNTAX :-terminator ..................... 5 Prefix-, infix-, postfix-notation 5 Syntax diagrams .................. 5 GENERAL DIRECTIVES .= ............................... 7 =. ............................... 8 ? ................................ 9 ?? .............................. 10 @ ............................... 11 def ............................. 12 del ............................. 13 do .............................. 14 edit ............................ 15 fix ............................. 16 input ........................... 17 inline .......................... 18 merge ............................xx output .......................... 19 pass ............................ 20 sort ............................ 21 PROGRAM FLOW break ........................... 23 clear ........................... 24 exit ............................ 25 next ............................ 26 if .............................. 27 repeat .......................... 28 MATH. FUNCTIONS bin ............................. 29 dec ............................. 30 rnd ............................. 31 STRING- AND LIST-FUNCTIONS adr ............................. 32 case ............................ 33 contents ........................ 34 head ............................ 35 ind ............................. 36 len ............................. 37 pos ............................. 38 tail ............................ 39 type ............................ 40 FILE I/O open ............................ 41 close ........................... 42 PREDEFINED VARIABLES error ........................... 41 err.............................. 41 top ............................. 41 cr .............................. 41 filler .......................... 42 mem ..............................43 ram ............................. 44 hex ............................. 44 The Do-language Reference Manual  ELEMENTS OF THE DO-LANGUAGE CHARACTERS The following minimum subset of the ascii character set is necessary for writing programs in the DO language. numbers: 0123456789 letters: abcdefghijklmnopqrstuvwxyz special characters: ? @ _ * + - / < = > ' , : ; ( ) [ ] { } The second line of special characters may not be used in identifiers for variables o command they act as delimiters. ASCII-CONSTANTS In DO an ascii-constant is a strings of characters delimited by "{" and "}". Curled braces may occur inside of ascii- constants but in a balanced manner. For each opening brace "{" a closing one "{" is needed. examples: {VARIABLE-1} {123xyz kkkKKKK} {-12.34546 $} {computer{keyboard,monitor,CPU},user} {A b {CD {efg}}} HEX-CONSTANTS Hex-constants are used to enter binary information or to use characters not in the visible ascii-character-set. We call these strings hex-constants because hexadecimal coding is used to describe each binary contents of a byte. Hex-con stants are enclosed in "''". Characters different from "0123456789ABCDEF" are ignored, but may not occur inbetween the two nibbles of a byte. Hex constants may not be longer than 255 bytes. examples: 'FF' '01EFCC4D' '01CE FF 13 D5C4' NUMERICAL CONSTANTS Numerical constants consist of digits from "0" to "9" and may contain a decimal point. "+" and "-" may precede numbers directly before the first digit as a sign. examples: 123 -555 10.56 0.56789 IDENTIFIERS Identifiers are used to specify variable or procedure names. Identifiers start with a letter and may be followed by any other letter, number or special characters but not delimiters. Delimiters would terminate an identifier. Maximum is 10 characters. examples: NAME var125 TEL_no. X qty_day NUMERICAL EXPRESSIONS Numerical expressions are constructed of constants, identifiers and some special characters and delimiters. Rules for forming numerical expressions are like in most other high- level languages. examples: X / -2.35 5 + 7 * (var - 1.3) (A+B)*(C-D) 125 / 9 *(3 + z) (dec mem) * 3 Parenthesis "()" may be used to change common precedence of arithmetic operators. Operators +-/* are delimiting characters. Spaces between identifiers and operatos are not necessary but may be included for better readability. Note that functions are wholy enclosed with their argument in parenthes as shown in the last example. This differs from writing functions in other languages. Precedence of operators is: precedence: functions * / + - Hex constants are not allowed in numerical expressions. LOGICAL EXPRESSIONS Logical expressions result in "1" or "0", standing for "true" and "false". Logical expressions use comparitive and logic operators : operator significance < less <= less or equal = equal >= greater or equal > greater <> not equal not negation and logical and or logical or with these operators expressions may be formed. logical expressions should be enclosed in paranthesis. Comparitive and logical operators have lower precedence than arithmetik operators. Comparitive operators are evaluated before logical. examples: (X = 1) (x = 1 and Y = "abc") (not x or NAME >= "A") Logical expressions are mostly used in "if"-statements to control programflow. LIST EXPRESSIONS List expressions are formed of ascii-constants, numerical constants,identifiers and some special list-functions. A list in DO is a collection of constants and/or identifiers and/or lists delimited by spaces or commas and enclosed in string braces "{}". Identifiers in lists may identify other lists. Lists may be part of lists. examples: 1 {a b c d e 12.30 f g} 2 {a b {c d} e f g} 3 {John Smith {Denver Colorado}} 4 (head {a b c d}) 5 (head (tail {1,4,6,7,3.8,9}) ) 6 (case 4 {THIS IS A LIST}) The list in examples 1. contains 8 elements one of them a numerical constant. In example 2. we have a list with 6 elements the third element itself beeing a list of two further elements. Examples 4.,5. and 6. show how list-functions are employed to isolate elements or sublists of lists. In example 5. the commas could be omitted. Commas and spaces are treated equal in DO. INDEXING Brackets "[]" are used for indexing in the DO-language. In the following examples there are always extracted substrings from some larger string. examples: contents 1 NAME .= {JOHN SMITH} "JOHN SMITH" 2 NAME[1,4] "JOHN" 3 NAME[6,5] "SMITH" 4 {abcdefg}[3,2] "cd" X .= 3 "3" 5 name[X,1] "H" 6 name[1,(X * 2)] "JOHN S" 7 9876.23[1,4] "9876" 8 name[6,5][1,2] "SM" 9 (1000 / 3)[1,4] " 333" 10 (head {this one})[3,2] "is" 11 name[6,5] .= {DOWE } "DOWE " 12 ram['EE 01',10] Examples 4. and 7. show that even constants may be indexed. Examples 5. and 6. show the use of identifiers and numerical expressions in indexing. Indexed expressions may be indexed as shown in example 8. Numerical expressions may be indexed as demonstrated in example 9. In DO anything may be indexed. Index expressions may occur on the left side of an assign-statement as demonstrated in example 11. changing only a part of the original string. Example 12. shows the use of hexconstants in indexing. The hex index must be given in low-high form. Hex indexes are processed much more rapidly than decimal based indexes. A second use of indexing is for disk-pointers. In this case only one index is used pointing to a specific byte. examples: floppy[100000] record[X * 20 + 1] mem['00000B'] THE DO-SYNTAX DO-statements consist of a primitive (function, operator) and one ore more operands. Operands may be: operand: ascii constant numerical constant hexadecimal constant identifier numerical expression logical expression list expression These operands are defined in the previous chapter ("elements of the DO-language"). : - TERMINATOR Each statement in DO is terminated by a doublepoint ":". This terminator may be omitted if a statement is executed with carriage-return (hitting the return-key) in an interactive mode. If statements are in a batch (program o multiple statements on the command line) they must be terminated by ":". PREFIX-, INFIX-, POSTFIX-NOTATION For each DO-primitive syntax is presented in prefix or infix-notation as these are the notations mostly used in other high-level languages. DO is capable of evaluationg statements and expressions in postfix notation (reversed polish notation). Even mixed notations are possible. The ability to treat with all kind of notations is a unique feature of this language, but may lead to confusing situations, if operation of some primitives is not fully understood. COMMENTS Comments may be inserted any where starting with a ";" semicolon. Comments are finished automatically at end of line or by a colon ":". SYNTAX-DIAGRAMS Each primitive is presented with its syntax diagram. One of the operators in brackets of type 1 must be selected. / \ / \ | | | | | | | | type 1 < > type 2 | | ... | | | | | | | | \ / \ / Selections in brackets of type 2 may be omitted. Three points "..." indicate that operands may be repeated. Different operands are seperated by space o comma. Space and comma are treated equally in DO. Selection of operands as shown for each DO-primitive are not the only possible ones. DO is very consistent in its operand-modes. That means almost all DO-primitives may have all kind of operands. In practice only a few selections make sense. For example a constant could occur as the receiving field in an assign-statement. DO would exept this statement but it would not be a useful statement (see example). { } .= X + Y: In the following section only logically useful operandmodes are described. DO-primitives are presented in four mayor groups: general directives : .=, =., ?, ??, @, def, del, do, edit, fix, inline, input, output, pass, sort, merge program flow : break, clear, exit,next, if, repeat math. functions : bin, dec, rnd string and list-functions : adr, contents, case, head, ind, len, pos, tail, type Each DO-primitive is explained with some examples. Most of them are complete with necessary definitions of variables procedures or constants. The Do-language Reference Manual  - .= - DESCRIPTION ".=" transfers contents from fields specified by operands on the right side of the statement to the receiving field specified in the left operand . Transfer is done left aligned. Digits not used in the trailing right part of the receiving field are filled with a special fill-character. This fill- character is contents of a predefined variable called "filler". "filler" may be changed by the user. Normally it contains space (asccii 32). SYNTAX / \ | asci cons. | | num. cons. | | hex cons. | identifier .= < identifier >, ... : | num. expr. | | log. expr. | | list expr. | \ / EXAMPLES result def {result} { } {fruits} {oranges}: ; 1 result .= 111:? result: "111 " 2 result .= 111 { $}:? result: "111 $ " 3 fix 2:result .= (10 - 2) * 5: " 40.00 " 4 fix 0:result .= (10/5) { } fruits: " 2 oranges " 5 filler .= {+}: 6 result .= 12.34: ? result: "12.34+++++++" 7 result .= {}: "++++++++++++" In statement 5. we see how "filler" may be modified. Example 6. shows trailing digits of "result" filled with the new fill-character. In example 7. a null-string is assigned resu lting in "result" completely filled with "+". - =. - DESCRIPTION "=." transfers contents of field specified in th operand on the right side to the field specified in operand on the left side. Transfer is done right- aligned. Leading digits not used in the receiving field are filled with a special fillcharacter (normally space). This character is contents of a predefined variable named "fil- ler". The contents of this variable may be changed by the user. SYNTAX / \ | asci cons. | | num. cons. | | hex cons. | identifier =. < identifier > : | num. expr. | | log. expr. | | list expr. | \ / EXAMPLES result def {result} { } {some} {any}: ; result =. 123: " 123" result .= 123: "123 " ; result =. some: " any" ; FIX 3: result =. -10 / 3: " 3.333" ; filler .= {*}: result =. -10 / 3: "****-3.333" The last two statements show use of the variable "filler". - ? - DESCRIPTION "?" displays contents of operands on the screen. Up to 20 operands may be specified in one statement. SYNTAX / \ | asc. cons. | | num. cons. | | hex cons. | ? < identifier >, ... : | num. expr. | | log. expr. | | list expr. | \ / EXAMPLES output on screen def {A} 5 {B} 3 {X} {asd} {Y} {jkl} {VAR1} { }: ; ? {abcdef}: "abcdef" ? 123.45: "123.45" ? '07': produces audible beep ; var1 .= {abcd}: ? var1: "abcd " ; fix 2:? (10/(A - B)): " 5.00" ? (X >= Y): "1" ? A B X Y VAR1: "53asdjklabcd " - ?? - DESCRIPTION "??" displays contens of operands in hexadecimal form. Up to 20 operands may be used in one statement. SYNTAX / \ | asci cons. | | num. cons. | | hex cons. | ?? < identifier >, ... : | num. expr. | | log. expr. | | list expr. | \ / EXAMPLES output on screen ?? {AB}: "41 42 " ?? 123: "31 32 33 " ?? 'DE1F00': "DE 1F 00 " def {saldo-X} 100: ?? saldo-X: "31 30 30 " ?? (2 + 1): "20 33 " ?? (1 = 10) "30 " ?? (case 3 {A,B,C}): "43 " ?? 1 {Z}: "31 5A " - @ - DESCRIPTION "@" positions cursor of the CRT in line specified by the first operand and column specified by the second operand. A third operand may specified opionally to set a specific area del display-screen to a certain attribute. The attribute set depends on the characters found in the string following as third operand. Consult the IBM-PC tecnical manual for significance of certain characters on the display. SYNTAX / \ / \ | num. cons. | | num. cons | | hex cons. | | hex cons. | @ < identifier > , < identifier > : | num. expr. | | num. expr. | | list expr. | | list expr. | \ / \ / EXAMPLES position row/col. def {a} 00 {b} 00 {x1} 00: ; @ 10,20: 10 20 ; x1 =. 10: @ '0E',X1: 14 10 ; A =. 20: B =. 18: @ ((A - B) *3),65: 6 65 ; @ A,B,{pppppp}:? {string}: 20 18 In the last example the cursor will be positioned in the 20 th line 18 th column . Starting at this location the word "string" will be displayed in reversed video. - def - DESCRIPTION "def" defines a new word in the dictionary. This word may serve as a variable pointer for memory or disk. the first Operand contains the word to be defined. The second defines type, length and adress of memory-field pointed to. In case of a disk pointer the second operand defines only an adress but no length diskadress. The new word defined may be used as a variable, constant o name of a procedure. Up to 10 definitions may be made in one statement. SYNTAX / \ / \ | asci cons. | | asci cons | | num cons. | | hex cons | | hex cons. | define < identifier > < identifier > , ... : | list expr. | | num. expr. | \ / | log. expr. | | list expr. | \ / EXAMPLES initial type length contents 1 def {height} 00000: N 5 "00000" 2 def {name} {John Smith}: A 10 "John Smith" 3 def {last} name[6,5]: A 5 "Smith" 4 def {pi_half} (3.14 / 2): N 5 " 1.57" 5 def {first} (head name): I 4 "John" 6 def last {30/11/47}: A 8 "30/11/47" 7 def {beep} {? '07':}: A 7 "? '07':" In example 6. the word defined is "Smith" which is contents of the word "last".Example 7. shows definition of a short procedure. executing "beep" produces an audible beeep on the CRT. See function "type" for explanation of the term "type", used in the example above. - del - DESCRIPTION "del" deletes any previos defined word from the dictionary. If more than one definition of a word exist, its last definition will be deleted. SYNTAX / \ | asci cons | | hex cons. | del < identifier >, ... : | list expr. | \ / EXAMPLES word deleted def {LAST} {any}: def {any} 000000: ; del {VAR},{LAST}: "VAR","LAST" del LAST: "any" - do - DESCRIPTION "do" loads a procedure from disk and executes it. The name of the procedure is containded in operand. The procedure is looked up in the disk-directory and loaded on bottom of available memory. A top-of-memory-pointer is incremented by the amount of memory used by the new procedure. The old top of memory pointer is pushed on a stack kept by the system. Optionally parameters may be passed to the procedure from the calling DO-statement. SYNTAX / \ / \ | asci cons. | | asci cons. | | hex cons. | | num cons. | DO < identifier > , | hex cons. | , ... : | list expr. | | identifier | \ / \ / EXAMPLES 1 do {create},{newname},10: 2 do {ledger}: 3 def {x} { }: inline x: do (case x {proga progb utility_Y Menu}): name .= {update}: 4 do name: In 1. a procedure named "create" is loaded and executed. Two parameters are passed. In example 3. depending on value of x one of 4 programs of the folowing list are executed. (see case- statement). In the last example the identifier "name" contains the name of the programm to be executed , which would be "UPDATE". - edit - DESCRIPTION "edit" edits a field sprecified in its operand. The current contents of the field is displayed and the cursor positioned at the end of the field. The field may now be editet with the usual editing keys. If "edit" is contested hitting return only, the field will be left unchanged with its initial contents. SYNTAX / \ | identifier | edit < > : | list expr. | \ / EXAMPLES 1 def {name} { }: edit name: ; 2 edit name[10,5]: In example 2 only a substring of variable "name" is edited. The rest of the field will be left unchanged. - fix - DESCRIPCION "fix" fixes position of the decimal point in evaluation of arithmetik expressions. The operand contains the number of digits to appear on the right side of the decimal point. Internally one more digit will be calculated to facilitate rounding. (see examples). SYNTAX / \ | num. cons. | | hex cons. | fix < identifier > : | num. expr. | | list expr. | \ / EXAMPLES output on screen def {X} { } {N} 00: ; 1 fix 1: X =. 1.5 / 2 + 0.05: ? X: " 0.8" ; 2 N =. 2: fix N: X =. 2 / 3: ? X: " 0.66" ; 3 fix 0: X =. 0.8 * 3: ? X: " 2" Example 1 shows rounding to one digit behind the decimal point. Without rounding "0.7" would be displayed. - input - DESCRIPTION "input" accepts characters from the keyboard. Unlike the "inline"-statement no input terminator (carriage return) is necessary. The program will proceed imedeately after filling the field specified in the operand of the input statement.If one operand is filled "input" will continue with the next, if specified. Editing as in "inline" is not possible. SYNTAX / \ | identifier | input < > ... : | list expr. | \ / EXAMPLES def {X} { } {ever} 999999: ; repeat ever { input X: ? X: if(X = {*}) exit: }: In this example a character input from the keyboard is immedeatly showed on the screen. Hitting "*" will exit the routine. - inline - DESCRIPTION "inline" gets characters from the keyboard and permits editing. The field to be input is specified in operand. All line editing keyfunctions are available during execution of this statement. DO will prompt the input field on the screen with a special prompt-character. This character may be defined by the user (see predefined). Hitting return only will left the field unchanged. If input is shorter than specified thru inputfield, leaving space in is filled with a special fill-character named "filler" (usually space). "filler" may be changed by the user. SYNTAX / \ | identifier | inline < > : | list expr. | \ / EXAMPLES def {value} 00000 {direction} { } {Z} { } {list} {value,direction}: ; 1 inline value: 2 inline direction[10,5] : 3 inline Z: inline (ind(case Z list)): In example 2. only 5. characters starting with the 10 th character may be entered from the keyboard. 5 characters beginning with the 10 th character. All contents in front and behind these 5 characters will be left unchanged. In example 3. one of the two variables will be entered depending on value of "Z". - output - DESCRIPTION outputprints the contents of fields specified in operands on the printer. This statement acts just like the "?"-state ment. Up to 20 operands may be specified in one statement. SYNTAX / \ | asc. cons. | | num. cons. | | hex cons. | OUTPUT < identifier >, ... : | num. expr. | | log. expr. | | list expr. | \ / EXAMPLES output on printer 1 output {Demonstration} : "Demonstration" 2 output 123.50 { $} : "123.50 $" 3 output '0C' : produces formfeed on most printers. 4 def {VAR} { }: fix 2: VAR .= 10 / 2: output VAR: " 5.00" - pass - DESCRIPTION This statement passes parameters from a calling procedure. "pass" does act similiar as a "def"-statement. Operands of "pass" contain only teh new words to be defined. The other part suplying information about adress type and length of the object defined are suplied as parameters by a calling procedure. SYNTAX (calling procedure) / \ / \ | asc. cons. | | identifier | | num. cons. | < > , < hex cons. >, ... : | list expr. | | identifier | \ / \ / SYNTAX / \ | asc. cons. | | hex cons. | pass < identifier > , ... : | list expr. | \ / EXAMPLES output on screen def {average} { pass {a} {b}: ? ((a+b)/2): del {a} {b}: }: average 10,20: " 15" The first part defines a subroutine named "AVERAGE". This module takes the input of to numbers and displays the average of them on the CRT-screen. At the end variables "A" and "B" are deleted from the dictionary. This is done to avoid acumulating more and more definitions of "A" and "B" in the dictionary each time "average" is called. - sort - DESCRIPTION "sort" classifies contents of a field specified in its first operand and with a record or keylength as specified in its second operand. The sort is done in scending order and based on the "Shell-sort" algorithm. SYNTAX / \ | num cons. | / \ | hex cons. | | identifier | sort < identifier > , < > : | num. expr. | | list expr. | | list expr. | \ / \ / EXAMPLES output on CRT 1 def {area} {ABEITKVMANDHFJ}: sort area 2: ? area: "ABANDHEIFJTKVM" 2 sort field 1: ? area: "AABDEFHIJKMNTV" In example 1. the string in "area" is broken up in 7 keys with a length of 2 each and these keys are sorted. - merge - DESCRIPTION "merge" permits construction of sorts of areas occupying more the the primary memory space of 64K. The first,second and third operand of merge specifie pointers to the computers memory space. The fourth parameter specifies number of bytes in each of the two areas pointed to by the fist two operands. The fifth parameter specifies record or keylength. - break - DESCRIPTION BREAK terminates execution of current procedure and proceeds execution on the next higher level. SYNTAX BREAK: EXAMPLES 1 DEFINE {A} 000: DEFINE {PROC} { IF (A = 9) BREAK: ? A:}: INLINE A: PROC: ? {END OF PROGRAM}: 2 DEFINE {I} 00: REPEAT 10 {I =. I + 1: IF (I = 5) BREAK: ? I: }: The program in example 1 will ask for an input from the keyboard thru the inline statement. Everything entered will be displayed thru procedure "PROC" with the exeption of "A" beeing equal to 9. In this case "PROC" will be left without showing contents of A. The program in example 2 shows a frequent use of the BREAK- statement to break the body of a REPEAT-loop and go on with the next iteration. The algorithm shown will display all numbers betwenn 1 and 10 with exeption of the number 5. In this case the procedure left by the BREAK-statement is the body of the REPEAT-loop enclosed in braces "{}". ----------- | CLEAR : | ----------- DESCRIPTION This command clears the last DO-overlay from memory and deletes all definitions made in this overlay from the dic tionary. If more than one DO-calls are present only the last one will be affected. While clearing overlay and definitions the top-of-memory-pointer is set to its previos value. It is recommended to terminate every program with a clear statement. As most programs will be called from disk by a DO-statement a CLEAR at the end of the program avoids memory and dicitonaruy overflow thru succesive DO-calls. See the DO-statement for further explanation. SYNTAX CLEAR: EXAMPLE ---------------- << low memory, beginning of |;MAIN PROGRAM | userspace | . | | . | | DO {PROG-1}: | | . | | . | | . | ---------------- << top of memory | PROG-1 | before DO-call of PROG-1 | . | and after CLEAR in PROG-1 | . | | . | | CLEAR: | ---------------- << top of memory | | after DO-call in MAIN PROGRAMM | | | | | free | | memory | | | | | | | ---------------- << high memory ---------- | EXIT : | ---------- DESCRIPTION EXIT is used to exit from REPEAT-loops. On execution programflow proceeds as if the REPEAT-loop would be terminated. If no REPEAT is in execution EXIT will stop programm flow completely. SYNTAX EXIT: EXAMPLES DEFINE {TASK} { } {EVER} 999999 {X} { }: ; REPEAT EVER { ? {please enter task to be executed}: IF (X = {END}) EXIT: INLINE TASK: DO TASK: }: ? {*** end of job ***}: The program shown asks to enter the name of a program . The name will be input to the variable "TASK" and the program is loaded from disk and executed. After execution the program will ask for another task until "END" is entered andthe string "*** end of job ***" is printed on the screen. ----------------------------------------------------- | IF operand-1,operand-2,... operand-n,operand-n1 : | ----------------------------------------------------- DESCRIPTION IF permits conditional execution of a procedure specified in operand-2 depending on condition specified in operand-1. On a true condition programflow will proceed processing the procedure in operand-2, else the next statement after the IF-statement will be executed. Up to 10 pairs of conditions and procedures may be specified. The first procedure belon ging to a true condition will be executed. After this the statement after the IF-statement will be processed. SYNTAX / \ / \ | num. cons. | | asc. cons. | IF < identifier > , < identifier > , ... : | log. expr. | | list expr. | \ / \ / EXAMPLES 1 DEFINE {A} 000: IF (A > 10) {? {A is greater 10}:}: 2 DEFINE {X} 00 {Y} 00 {Z} 0000: IF ((X = Y) OR (Z = 123)) {DO {UPDATE}:} 3 DEFINE {A} { }: DEFINE {ELSE} 1: INLINE A: ; IF (A = {update}) CHANGE (A = {new}) ENTER (A = {delete}) DELETE ELSE {? {unknown procedure}:}: ? {job terminated...}: In example 2 a procedure called "UPDATE" will be loaded from disk and executed if at least one of the conditions is true. Example 2 shows multiple conditions and procedures. Depen ding on input made in variable A one of three procedures will be executed. After that "job terminated..." will be displayed. If none of the three conditions is true program flow will display the message "unknown procedure". As the variable "ELSE" contains a "1" it is recognized as a "true" condition. -------------------------------- | REPEAT operand-1,operand-2 : | -------------------------------- DESCRIPTION Operand-1 contains the number of times procedure in operand-2 shell be repeated. The highest number of repitions is 2^32 or 4,294,967,296. REPEAT-loops may by exited by the EXIT- command. Inbetween a REPEAT-loop the BREAK-comand can force execution of next iteration before termination of the current. (See commands EXIT and BREAK). SYNTAX / \ | num. cons. | / \ | hex. cons. | | asc. cons. | REPEAT < identifier > , < identifier > : | num. expr. | | list expr. | | list expr. | \ / \ / EXAMPLES output on screen 1 DEFINE {STARS} {? {*}:}: REPEAT 10 STARS: "**********" 2 DEFINE {IN} { } {I} 00000 {EVER} 99999: ; REPEAT EVER { ? {next itrtn/1 exit loop/2}: I =. I + 1: INLINE IN: IF (IN = 1) BREAK (IN = 2) EXIT: ? I {TH. ITERATION}: }: ? {...end of program}: Programm in example 1 will output a line of 10 "*" on the screen. Program in example 2 shows use of EXIT and BREAK in REPEAT- loops. ----------------- | (BIN operand) | ----------------- DESCRIPTION This function returns the binary equivalent of an ascii-decimal coded input specified in operand. As BIN represents a function it should be enclosed in parenthesis with its operand. BIN can convert integer numbers betweeen 1 and 4,294,967,295 (2^32). Results are stored in 1 to 4 bytes depending on value. If more than one bytes are used orde is in low-high byte (see examples). SYNTAX / \ | num. cons. | (BIN < identifier > ) | num. expr. | | list expr. | \ / EXAMPLES output on CRT 1 ? (BIN 7): produces audible beep 2 ?? (BIN 1000): "E8 03 " 3 DEFINE {VAL} { }: VAL =. 16777200: ?? (BIN VAL): "0F FF FF " Note the low-high byte order in examples 2 and 3. This order facilitates manipulation of varios systemparameters requi ring this order of bytes. ----------------- | (DEC operand) | ----------------- DESCRIPTION The DEC-function converts from binary to ascii-decimal coding. DEC is the reverse function of BIN. The contents of operand may not be longer than 4 bytes number from hex00 to hexFFFFFFFF may be converted. As a function DEC and its operand should be enclosed in patenthesis. SYNTAX / \ | asc. cons. | | hex. cons. | (DEC << identifier >> ) | list expr. | \ / EXAMPLES output on screen 1 ? (DEC 'FF'): " 255" 2 ? (DEC(BIN(DEC '63'))): " 99" 3 DEFINE {X} 'E803': ? (DEC X): " 1000" 4 ? (DEC {A}): " 65" 5 TOP .= (BIN((DEC TOP) + 200)): Example 2 shows the complementary work of the DEC and BIN functions. Hex63 is converted to decimal from there back to binary and finaly to decimal another time. Example 5 shows updating of one of the systemparameters. In this case the top-of-memory pointer is incemented by 200. --------- | (RND) | --------- DESCRIPTION RND return a pseudo random integer betweeen 1 and 65535. A special memory location may be used to put a start seed for the pseudo random process. (see table of system variables). EXAMPLES 1 DEFINE {X} 00000 {Z} 00000: X =. (RND): ; 2 FIX 0: Z =. 10 * (RND) / 65535 + 1: Example 1 shows assignment of a random number between 1 and 65535 to variable "X": In example 2 random numbers between 1 and 10 are generated and assigned to variable "Z". ------------------ | (ADR operand ) | ------------------ DESCRIPTION The ADR-function returns adress of a field specified in operand. By menas of this function ubication of variables o procedures in memory may be calculated. SYNTAX / \ | identifier | (ADR < > ) | list expr. | \ / EXAMPLES output on screen 1 DEFINE {BUFFER} RAM[50000,10000] : ? (ADR BUFFER): " 50000" Since "BUFFER" was previos defined to begin at memory-adress 50000 the ADR-function will produce the same value. ------------------------------ | (CASE operand-1 operand-2) | ------------------------------ DESCRIPTION Operand-1 of this list-function selects an element of a list defined in operand-2. CASE is useful whenever a selection can be made by number. This refers to data-structures as well as to programstruc ters. SYNTAX / \ | num. cons. | / \ | hex cons. | | hex cons. | (CASE < identifier > < identifier > ) | num expr. | | list expr. | | list expr. | \ / \ / EXAMPLES 1 DEFINE {PROGRAMS} {MASTER UPDATE REPORT} {SELECT} { }: ; ? {which ? master/1 update/2 report/3}: INLINE SELECT: DO (CASE SELECT PROGRAMS): output on screen 2 DEFINE {LIST} {A {B C} D} {X} { }: X .= (CASE 2 LIST): ? X: "B C" Depending on a number between 1 and 3 one of three programs will be loaded from disk and executed. The variable "PROG RAMS" contains a list of names. As they are delemited by a delimiter (space) they will be recognized as differnt ele ments. In example 2 the ascii-constant "{A B}" will be recognized as one element. (For further understanding of building lists see statements HEAD and TAIL.) ---------------------- | (CONTENTS operand) | ---------------------- DESCRIPTION This function returns the contents of a field specified in operand without trailing spaces. This function is useful for verifications of inputs or for finding out the first free space in in a field to append more text or information (see examples). SYNTAX / \ | identifier | (CONTENTS < > ) | list expr. | \ / EXAMPLES output on screen 1 DEFINE {ANY} {46.78 $ P/DAY }: ; ? ANY: "46.78 $ P/DAY " ? (CONTENTS ANY) "46.78 $ P/DAY" ; ANY .= (CONTENTS ANY) { 1982}: ? ANY: "46.78 $ P/DAY 1982" Note the difference in the first two outputs. The CONTENTS- function does not include trailing spaces. The last two statments show how this function may be used to append information to existing strings. ------------------- | (HEAD operand ) | ------------------- DESCRIPTION This list-processing function returns the first element of a list. Lists are made of identifiers,numbers and ascii- constants. String-brackets may be used to define sublists of lists. SYNTAX / \ | asci cons. | (HEAD < identifier > ) | list expr. | \ / EXAMPLES 1 DEFINE {list} {{THE STUDENT} {HARDLY STUDIES} COMPUTERS}: output on screen ? (HEAD list): "THE STUDENT" ? (HEAD(HEAD list)): "THE" ? (TAIL(HEAD list)): "STUDENT" "list" consists of three elements of which the first two are lists themself. The last stement shows how complex list- functions may be formed. See TAIL-statement for further examples with HEAD. ----------------- | (IND operand) | ----------------- DESCRIPTION IND returns de indirect contents of a field specified in operand. This is not the contents itself but the contents of the contents. IND interpretes the contents of operand as an identifier and looks it up in the dictionary. This concept of "indirect adressing" is well known in assembler program ming. For further understanding look at examples. SYNTAX / \ | identifier | (IND < > ) | list expr. | \ / EXAMPLES output on screen 1 DEFINE {X} 1234: DEFINE {Y} {X}: ; ? X: "1234" ? (IND Y): "1234" ? (IND {X}): "1234" 2 ? (IND(CASE 1 {X Y})): "1234" ? (CASE 1 {X Y}): "X" All three "?"-statements in example 1 cause the same output. The last two use indirect adressing. Although the symntax- explanation does not include the use of ascii-constants in IND-functions, it is not prohubited do do so.We use it her for for better understanding of this type of function. The use of ascii-constants is not included in the syntax because of redundancy in real aplication. Example 2 shows how IND can help to interprete the elements of a list as variables. Without use of IND not the contents of "X" but only "X" itself would be returned for display. ------------------ | (LEN operand ) | ------------------ DESCRIPTION The LEN-function returns the length of a field specified in operand. LEN is mainly used in input verification. SYNTAX / \ | identifier | (LEN < > ) | list expr. | \ / EXAMPLES output on screen 1 DEFINE {VAR-X} RAM[TOP,50]: ? (LEN VAR-X): " 50" 2 DEFINE {GET} { } {X} 00: {MESSAGE} {? {too small}:}: ; INLINE GET: X =. (LEN(CONTENTS GET)): IF (X < 5) MESSAGE: "too small" Example 2 shows a typical aplication for the LEN-function in inputverification. By use of the CONTENTS-function input in the variable "GET" is isolated and may be chequed by means of LEN of its length. If length is less then 5 the message "too small" would be displayed on the screen. ----------------------------- | (POS operand-1 operand-2) | ----------------------------- DESCRIPTION This functions searches for a field specified in operand-1 in a field specified in operand-2 and returns the starting position of the string found. If no match was posible the POS-function will return a "0". SYNTAX / \ | asci cons | | num. cons. | / \ | hex cons. | | identifier | ( POS < identifier > < > ) | list expr. | | list expr. | \ / \ / EXAMPLES DEFINE {alphabet} {ABCDEFGHIJKLMNOPQRSTUVWXYZ} {KEY} {UVW} : output on screen ; 1 ? (POS {F} alphabet): " 6" 2 ? (POS '31' alphabet): " 0" 3 ? (POS KEY alphabet " 21" 4 ? (POS {DE} alphabet[2,9]): " 3" In example 2 alphabet is searched for the character "1". In example 4 only a substring of "alphabet" is searched, the position found is releative to this substring. ------------------ | (TAIL operand) | ------------------ DESCRIPTION This list-processing function returns all but the first element from a list specified in operand. Lists are made of identifiers, numbers and ascii-constants. String-brackets may be used to define sublists of lists. SYNTAX / \ | asci cons. | (TAIL < identifier > ) | list expr. | \ / EXAMPLES DEFINE {phrase} {{the student} {hardly studies} computers}: output on screen ? (TAIL phrase): "{hardly studies} computers" ? (HEAD(TAIL phrase)): "hardly studies" ? (HEAD(HEAD(TAIL phrase))): "hardly" ? (TAIL(HEAD(TAIL phrase))): "studies" ? (TAIL(TAIL phrase)): "computers" "phrase" consists of threee elements of which the first two are lists themself. See HEAD-statements for further examples. ------------------ | (TYPE operand) | ------------------ DESCRIPTION The TYPE-function returns the type of a string tested. TYPE is used mainly for input verification as shown in the following examples. SYNTAX / \ | asci cons. | (TYPE < identifier > ) | list expr. | \ / EXAMPLES 1 DEFINE {entry} { }: ; INLINE entry: ? (TYPE(HEAD entry)): inputinentry / output screen / type "ABCD" "I" identifier "var125" "I" identifier "1.23" "N" number "{kkkk}" "A" ascii-constant "'0C EE'" "H" hex-constant "(" "(" arithmetik parenth. "]" "]" string parenthesis ":" ":" terminator "" "E" empty or end Any string starting with "+,-,1,2,3,4,5,6,7,8,9,0" would be typed as a number. Any string starting with "{" as ascii- constant and any string starting with "'" as a hex-constant. The special characters "(,),[,],:" are isolated by all list- functions as unique elements although not separated with a space o comma from surrounding elements.These characters are themselves delimeters. The TYPE-function as in the example returns these characters themselves. The last example shows typing of an empty string. "E" would be returned in this case. ----------------------------- | OPEN operand-1,operand-2: | ----------------------------- File handling in DO is easy through defining "diskpointers". These pointers point to the beginning of a file on the specified diskdevice and may be indexed for acces of any byteadress in the file. Open searches the directory for a file specified in operand-2 and defines a diskpointer speci fied in operand-1.This pointer may be indexed by a simple index. SYNTAX / \ / \ | asci cons. | | asci cons. | OPEN < identifier > , < identifier > | list expr. | | list expr. | \ / \ / EXAMPLES 1 OPEN {master} {ACCOUNT}: 2 DEFINE {record} { }: record .= {this is an example}: master[500] .= record: In statement a file named "ACCOUNT" is opened and a pointer named "master" is defined in DO's directory. The following atatements show how information is written to this file starting in the 500th byte. ------------------ | CLOSE operand: | ------------------ CLOSE releases files from access an writes updated buffers back to disk. Depending on the operational system environ ment of DO these buffers may besmall o rather big. CLOSE is the only way to assure information physically written to disk when buffered file i/o is employed by the oparational system. SYNTAX / \ | asci cons. | CLOSE < identifier > : | list expr. | \ / EXAMPLE CLOSE {master} : The file pointed to by "master" is closed updated buffers are written back to disk. PREDEFINED VARIABLES Some predefined variables give access to often used memory locations containing system variables or procedures. --------- | ERROR | --------- ERROR is a predefined procedure called whenever the DO- processor encounters an error condition. ERROR may be changed by the user to provide customized action on error. ------- | ERR | ------- ERR contains in binary form the last error-number occured. The simplest form of an error message would be to display this error number on screen. A so defined procedure ERROR would contain: ERROR .= {? {error no.}: ?? ERR:} ------- | TOP | ------- TOP is a 2-byte variable containing the adress of the first unused byte in user space. TOP contains this adress in binary form in low-byte/high-byte order. TOP automatically will be updated (incremented) by DO-calls to diskresident subroutines and decremented by the CLEAR- statement. A stack is used to hold previous TOP's when DO- calls occur. Executing a CLEAR-statement the old TOP can be established pulling it out of the stack. See descriptions of DO and CLEAR for further explanation. ------ | CR | ------ CR is a one-byte variable containing hex-0D. displaying or printing "CR" will cause a carriage return line-feed on the printer or screen. As any OUTPUT- or ?-statement will not automatically cause an carriage return/line feed,"CR" is mostly used in this statements as the last variable. ---------- | FILLER | ---------- FILLER is a one byte variable containing the fill character used in the "INLINE",".=" and "=." statement to fill unused space in receiving fields. If not modified by the user, FILLER contains hex-20 which is ascci-code for space. ------- | RAM | ------- RAM is an A-type variable pointing to user-RAM. RAM is 64 Kbyte long. And may be used to access a specific memory area to make definitions for specific memory areas. ------- | HEX | ------- HEX points to the same area as MEM but is of H-type. Execu ting a hex-type variable will take its contents as machine code and proces it like that. ------- | MEM | ------- MEM is a four-byte pointer pointing to ram outside the area specified by RAM. MEM may be used in machines offering more than 64Kbyte adressspace to access memory outside of DO's main working area. "THE STUDENT" ? (HEAD(HEAD list)): "THE" Z[v qOPomnmkigec@@mnywuso./mRSk{|iywus=?q//l22j22h1323f@23l3m3y33w33u33sJJq=J>JorJsJmJJkJJJyJJw0K1KuQQsQQqQQoNRORmUUkUUiUXXyY Yw|Y}Yuddseeq@eAeoeemmmk.n.n/nyY Yw|Y}Yuddseeq@eAeoeemmmk.nxxxxxxxxxxxurrrollxxxxxxxxxxxxxxxxxxxxxxxxxxxx$u&'Zc]Q<< ]dyfvtqnkkkCkikkkhec`S<<Sx:x`xbuvsxpmmmm6m\mmmmmm@mS@fxxxxuspm6m\mmmmjjhm@S<Sx x1xWxYu[uyuspmm m/mUm{mmmmSxv sE sG p] n_ k h h h h hC hi h h mSS i W U R R P Me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