------------------------------------------------------------------------------ PILOT/P QUICK REFERENCE GUIDE ------------------------------------------------------------------------------ THE PARTS OF AN INSTRUCTION --------------------------- These are all the possible elements of a PILOT/P instruction, in their correct order: Element Comment *label Must be on a separate line. instruction-name Required. conditioners Usually just one; one letter. : Required colon. object Depends on instruction. LABEL ----- Optional; identifies a place in the lesson. Up to 40 characters; preceded by an asterisk and followed by end of line. CONDITIONERS ------------ Optional; may be useful on one instruction. Conditioners may be used with any instruction. An instruction is skipped unless all of its conditions are met. Y (Yes) Executes if last Match was successful. N (No) Executes if last Match was unsuccessful. TEXT INSTRUCTIONS ----------------- Remark r: THIS IS A REMARK r: Last edited: Jan 1, 1984 Comments to author; not executed. Type t:What is your name? t:Your score is @#x@ points. Displays and formats object text on student's screen. If text includes variable names, their stored values are displayed instead. RESPONSE INSTRUCTIONS --------------------- Accept a: a:@#n@ a:@$A@ Accepts student's response. May assign response to variables. Match m:COMPUTER m:YES!yes!NO!no!ok!right m:Smith, Alfred Looks for object text in student's last response. Result of search used by Yes and No conditioners. ! (Or) m:cat!dog Separates object texts. Match successful if response contains either of given texts. CONTROL INSTRUCTIONS -------------------- Jump j:*start Branches to the specified label. Use u:ask Uses the called subroutine. End e: returns to instruction following the u: that called this subroutine. If not reached by a u:, ends lesson. Link l:lesson1 Starts new lesson, keeping all the variables from the old lesson. Wait w:5 w:#x Pauses the specified number of seconds or until any key is pressed, whichever comes first. Object may be a simple numeric variable. COMPUTATION INSTRUCTIONS ------------------------ Compute c:$n := 'Lincoln' c:#x := 15 c:#a := #b * #c Evaluates an arithmetic or string expression and stores it in the variable to left of assignment operator. FILE HANDLING INSTRUCTIONS -------------------------- Open an existing file u:reset('grades.dat',f1) Open a new file u:rewrite('b:test.dat',output) File Output u:writeln(f1,@$a@) Stores contents of specified variable(s) in the file now open. File Input u:readln(input,@$t@) Reads file now open and stores result in specified variable(s). Output to console as a file. u:rewrite('con:',output) Open the printer for output. u:rewrite('lst:',output) VARIABLES --------- User Variables Typical Names Example Simple numeric #a, #x c:#a := 15 String $a, $z c:$a := 'SUNDAY' System Variables ans Answer Buffer (response to last a:) ch Single character storage temp Temporary storage string FUNCTIONS --------- Transcendental Functions SIN(X) c:#r := sin(#a) Returns sine of angle x radians. COS(X) c:#r := cos(#n) Returns cosine of angle x radians. ARCTAN(X) c:#r := arctan(#x) Returns radian measure of angle whose tangent is x. Arithmetic Functions ABS(X) c: #a := abs(#x) t: Your score is @abs(#x:4)@ units. Returns the absolute value of x SQR(X) c: #a := sqr(#x) Returns the square of x TRUNC(X) c: #i := trunc(#x) Returns the integer whose absolute value is less than x SQRT(X) c: #r := sqrt(#x) Returns square root of x (x>0) LN(X) c: #r := ln(#x) Returns natural log of x (x>0) EXP(X) c: #r := exp(#x) Returns e (2.71828) to power x. LN(10)/LN(X) c: #r := ln(10)/ln(x) Returns base 10 log of x (x>0) String Functions CHR(X) t:@chr(7)@@chr(27)@ c: ch := chr(65) Returns character whose decimal ASCII code is x. ORD(CH) x:ord(ans[1])=0 c: #x := ord(ans[1]) Returns decimal ASCII code for the character. DELETE($T,#P,#C) u: delete($n,#p,#c) Deletes #c characters starting at position #p from string $t. COPY($S,$T,#H,#C) u: copy($t,ans,#i,#c) Returns sub-string $s from string $t starting at position #h for #c characters. INDEX($T,$P) c: #k := index(ans,'DAY') x: index($t,$p)<>0 Searches from the 1st character of $t for first occurrence of $p. Returns 0 if no occurrence found, or returns position in $t of matching sequence's first character. LENGTH($T) c: #k := length(ans) t: You entered @#k:1@ characters. Returns number of characters in $t. SETLENGTH($T,#L) u:setlength($n,0) Forces the length of string $t to length #l. UCASE($T) u:ucase($t) Returns entire string $t in upper case. LCASE($T) u:lcase($t) Returns entire string $t in lower case. VLENGTH($T) c: #k := vlength(ans) t: You entered @#k:1@ characters. Returns the length of string $t. [Highly recommend that you use this length function as it only uses 5 bytes of code and is much faster than the supplied function] INSERT($P,$T,#C) u: insert('turtle',$t,#c) Returns string $t with string $p inserted starting at position #c. REPLACE($P,$S,#C) u: replace('pattern',$s,#c) Returns destination string $s with the string $p in place starting at position #c. CONCAT($N,$A,$B) u: concat($n,ans,'DAY') Returns sum of strings $a and $b in string $n. The sum of the two passed strings will not be allowed to exceed the maximum allowable length of a string (255 characters). IVALUE($T,#N) c: k := ivalue(ans,1) Returns an integer value from the argument string passed in $t starting at position #n. STR(X,$T) u: str(#i,$t) Returns the number x expressed as a string of characters in $t. Input Functions KEYIN(CH) u:keyin(ch) Direct input of a single character from the keyboard without echo. Procedure waits for any input. KEYBOARD(CH) x:keyboard(ch) Real time input of a console character with NO echo. Returns true and the input character if a character is waiting. Similar to the UCSD function keyboard except that the character is returned directly. CONSTAT x:constat Real time console status check. Returns true if any key is pressed. CONCHAR c:#n := conchar c: ch := chr(#n) Real time input of a console character. Does not echo the input character. Returns zero if no char waiting. Do NOT use in conjunction with constat as this routine does its own status check. [CP/M 2.x only!] Miscelaneous Utility Functions MEMAVAIL t: We have @memavail:1@ bytes left. Returns the difference in value between the top of the heap and the stack as an integer value. This can be interpreted as the amount of memory available at that time. One must take into consideration the size of stacks and procedure calls. HALT($T) u: halt('FATAL ERROR') Fatal error termination with message to console. NO open files will be closed! ISALPHA(CH) x:isalpha(ch) Returns true if ch is an alphabetical character. ISUPPER(CH) x:isupper(ch) Returns true if ch is in uppercase. ISLOWER(CH) x:islower(ch) Returns true if ch is in lowercase. ISDIGIT(CH) x:isdigit(ch) Returns true if ch is a digit. ISSPACE(CH) x:isspace(ch) Returns true if ch is a space or a tab character. TOUPPER(CH) c:ch := toupper(ch) Returns the character ch in uppercase. TOLOWER(CH) c:ch := tolower(ch) Returns the character ch in lowercase. PEEK(#A) c:#n := peek(#a) Returns the contents of the memory location pointed to by #a. The value returned is a single byte integer. POKE(#A,#N) u:poke(#a,#n) Places the low-order eight bits of the byte #n at the memory location pointed to by #a. DWRITE(CH) u:dwrite(ch) Output a character directly to the console via CP/M BDOS call. [CP/M 2.x only!] GOTOXY(#C,#R) u:gotoxy(#c,#r) Position the cursor to the specified column and row. OUTPORT(#P,#X) u:outport(01,#v) The low-order 8 bits of #x are sent to the 8080/Z80 I/O port #p. INPORT(#P,#X) u:inport(02,#x) Returns the byte value from the 8080/Z80 I/O port #p. VAL(CH) c: #n := val(ans[1]) Returns the integer value of a single character. PWROFTEN(X) c: #r := pwroften(#r) Returns 10 raised to the exponent power. Exponent must be an integer in the range 0..37. POWER(X,Y) c:#r := power(#a,#r) Returns x^y. NO error checking. RANDOM(SEED) c: #r := random(seed) Returns real number between 0 and 1.0 requires global var seed: real; RANDOMIZE u: randomize Allows a random starting point for the pseduo random sequence. requires FUNCTION random RND(#L,#H) u: rnd(1,22) Returns an integer number from #l thru and including #h. Uses the procedure RANDOM(). ------------------------------------------------------------------------------