DECsystem 10 ALGOL-60, Version 7(717) 02-JUN-78 05:16:08 Command string: G,G/C=G.ALG LINK! 1 000000 1 COMMENT ------------------------------------------------- 2 000000 2 3 000000 3 GNOSIS provides a simple CAI authoring language which makes 4 000000 4 it easy for any teacher with a basic understanding of 5 000000 5 "programmed" textbooks to develop computerized tutorials for 6 000000 6 his students. Although material already written in such a 7 000000 7 format can be transformed virtually as-is by GNOSIS into a 8 000000 8 form suitable for computer delivery, the teacher would 9 000000 9 normally be writing his own "script." This script, because 10 000000 10 it simulates the dialogue one might overhear if that teacher 11 000000 11 were tutoring a student in private, can be made to "come to 12 000000 12 life" on a computer terminal by the addition of a few simple 13 000000 13 GNOSIS command words. The computer driven tutorial is, in 14 000000 14 reality, a compiled version of the ALGOL program GNOSIS 15 000000 15 writes in response to the script prepared by the teacher. 16 000000 16 17 000000 17 As in the ordinary tutoring environment, the student's path 18 000000 18 through the material can be guided in various and subtle 19 000000 19 ways, e.g., by routing students having difficulty to 20 000000 20 supplementary material. The program qua tutor can also 21 000000 21 react in helpful ways to a variety of anticipated false 22 000000 22 answers to questions, e.g., by giving appropriate diagnostic 23 000000 23 commentary or hints, followed by a repetition of the wrongly 24 000000 24 answered question. Although unanticipated responses can be 25 000000 25 saved for inclusion in the teacher reports (along with 26 000000 26 statistics on individual student performance), the data 27 000000 27 which are generated exist for the sake of improving the 28 000000 28 lesson pedagogically. This is in keeping with the general 29 000000 29 design philosophy that GNOSIS should be a TEACHING system 30 000000 30 rather than a TESTING system. 31 000000 31 32 000000 32 If anyone makes any additions or modifications to the GNOSIS 33 000000 33 translator, then please send a copy either to (1)Jacob 34 000000 34 Palme, Research Institute of National Defense, S-10450 35 000000 35 Stockholm 80, Sweden, or (2)Dr. Walter Maner, Department of 36 000000 36 Philosophy, Old Dominion University, Norfolk, Virginia 37 000000 37 23508, USA. With your cooperation, we can prepare more 38 000000 38 powerful versions of GNOSIS for distribution to GNOSIS users 39 000000 39 like yourself. THANK YOU. 40 000000 40 41 000000 41 42 000000 42 ALPHABETICAL LIST OF GLOBAL VARIABLES 43 000000 43 ===================================== 44 000000 44 45 000000 45 NAME TYPE CONTENT 46 000000 46 ------------------------------------------------------------------- 47 000000 47 48 000000 48 A INTEGER A 49 000000 49 ALLNEUTRAL BOOLEAN TRUE IF ALL ANSWER PATTERNS SO FAR TO THIS 50 000000 50 . QUESTION HAVE BEEN NEUTRAL. THIS INFLUENCES 51 000000 51 . THE WORDING OF MESSAGES FOR UNEXPECTED STUDENT 52 000000 52 . ANSWERS. 53 000000 53 ANSWER STRING BUFFER FOR INPUT LINES OF THE LESSON. ONE LINE 54 000000 54 . AT A TIME IS STORED IN THIS BUFFER. 55 000000 55 ANSWERLENGTH INTEGER LENGTH OF LESSON LINE. 56 000000 56 BELL BOOLEAN TRUE IF LESSON CONTAINS A %BELL COMMAND 57 000000 57 . RINGS BELL ON STUDENT'S TERMINAL WHEN INPUT 58 000000 58 . FROM HIM IS REQUIRED. 59 000000 59 BLANK INTEGER 60 000000 60 CARRIAGERETURN INTEGER 13 61 000000 61 CHARVALUE INTEGER TEMPORARY STORAGE OF INTEGRAL VALUE OF ONE 62 000000 62 . CHARACTER IN A STRING WHICH IS 63 000000 63 . BEING OUTPUTTED. 64 000000 64 COLON INTEGER : 65 000000 65 CONTROLCHAR INTEGER BINARY VALUE OF THE FIRST CHARACTER IN THE 66 000000 66 . LESSON. THIS CHARACTER BEGINS ALL COMMAND 67 000000 67 . LINES. IT IS USUALLY = "%". 68 000000 68 CONTROLINLINE BOOLEAN CONTROLCHAR INSIDE INPUT LINE. 69 000000 69 CONTROLSTART STRING SUBSTRING OF CHARACTER 2-4 OF COMMAND. 70 000000 70 COPYRIGHT STRING LESSON AUTHOR'S COPYRIGHT NOTICE 71 000000 71 DISK BOOLEAN TRUE IF LESSON CONTAINS A %DISK COMMAND. 72 000000 72 . SENDS TEACHER REPORT TO A DISK FILE 73 000000 73 . WITH THE NAME "LESSONNAME.DTA". 74 000000 74 DOT INTEGER . 75 000000 75 DOUBLEQUOTE INTEGER " 76 000000 76 EMPTY BOOLEAN TRUE IF TEACHER ANSWER PATTERN IS EMPTY. 77 000000 77 EQUALSIGN INTEGER = 78 000000 78 ERRLINES INTEGER COUNTER OF LINES TO BE PRINTED AFTER ERROR. 79 000000 79 EXCLAMATION INTEGER ! 80 000000 80 EXTRA BOOLEAN ARE EXTRA WORDS PERMITTED IN STUDENT ANSWERS? 81 000000 81 FIRSTRIGHT STRING FIRST RIGHT ANSWER TO A QUESTION. 82 000000 82 FORMFEED INTEGER 12 83 000000 83 IFSET BOOLEAN ARRAY IF ON GNOSIS-TIME SWITCH IS ACTIVE. 84 000000 84 IFVAL BOOLEAN ARRAY VALUE OF IF ON GNOSIS-TIME SWITCH. 85 000000 85 INFILE STRING FILENAME WITH EXTENSION OF INPUT FILE. 86 000000 86 JUSTIFY BOOLEAN TRUE IF TEXT BLOCKS ARE TO BE RIGHT 87 000000 87 . JUSTIFIED ("RAGGED RIGHT") AT COLUMN 72 88 000000 88 KEEP BOOLEAN KEEP TEACHER REPORTS AT COMPUTING CENTER, 89 000000 89 . DO NOT ASK THE STUDENT TO SEND THEM IN. 90 000000 90 LAB STRING USED FOR GENERATION OF LABELS IN THE PRODUCED 91 000000 91 LABELCOUNT INTEGER COUNTER OF NUMBER OF MAINLABS. 92 000000 92 LACK BOOLEAN TRUE AFTER A %LACK COMMAND. 93 000000 93 LANGUAGE INTEGER LANGUAGE = 1 -> LESSON IS IN ENGLISH, 94 000000 94 . (ENGLISH IS THE DEFAULT) 95 000000 95 . LANGUAGE = 2 -> LESSON IS IN SWEDISH. 96 000000 96 LCAA INTEGER } = BINARY VALUE OF SWEDISH LETTER 97 000000 97 LCAE INTEGER { 98 000000 98 LCE INTEGER e 99 000000 99 LCOE INTEGER ` 100 000000 100 LEFTSQUARE INTEGER [ 101 000000 101 LESSONNAME STRING FILENAME OF THE LESSON WITH EXTENSION REMOVED. 102 000000 102 . THIS NAME WITH THE EXTENSION ".ALG" IS THE 103 000000 103 . NAME OF THE OUTPUT FILE. 104 000000 104 LINEFEED INTEGER 10 = BINARY VALUE OF ASCII CHARACTER 105 000000 105 LINENUMBER STRING LINENUMBER FOR LINENUMBERED FILES. 106 000000 106 LINENUMBERED BOOLEAN THE GNOSIS TEXT IS A LINE-NUMBERED FILE. 107 000000 107 LOCK BOOLEAN TRUE IF LESSON CONTAINS A %LOCK COMMAND. 108 000000 108 . DISABLES BACKSTEPPING AND SKIPPING 109 000000 109 . PROVISIONS OF GNOSIS. 110 000000 110 MAINLAB STRING USED FOR GENERATION OF LABELS IN THE PRODUCED 111 000000 111 . ALGOL PROGRAM, TO BE USED FOR BACKSTEPPING. 112 000000 112 NAME BOOLEAN TRUE IF LESSON CONTAINS A %NAME COMMAND. 113 000000 113 . STUDENT'S FIRST NAME USED FOR I/O AND 114 000000 114 . HIS FULL NAME GOES TO TEACHER REPORT (IF ANY). 115 000000 115 NEUTRAL BOOLEAN TRUE FOR A %NEUTRAL COMMAND. 116 000000 116 OPENED BOOLEAN TRUE WHEN THE OUTPUT FILE FROM GNOSIS 117 000000 117 . HAS BEEN OPENED AND THE PREAMBLE OF THE 118 000000 118 . ALGOL TRANSLATION OF THE LESSON HAS BEEN 119 000000 119 . OUTPUTTED. 120 000000 120 ORDER BOOLEAN MUST STUDENT ANSWER WORDS BE IN ORDER? 121 000000 121 POS INTEGER POSITION IN THE TEXT OF THE LESSON LINE. 122 000000 122 POS2 INTEGER POSITION IN THE TEXT OF THE LESSON LINE. 123 000000 123 PREVIOUSLAB STRING LABEL FOR PREVIOUS TEXT OR QUESTION. GNOSIS 124 000000 124 . WRITES INTO LESSON A GOTO STATEMENT WITH THIS 125 000000 125 . LABEL AS ARGUMENT SO STUDENT MAY BACK UP IN 126 000000 126 . THE LESSON ONE ITEM AT A TIME. 127 000000 127 PUT BOOLEAN TRUE IF THE LESSON CONTAINED A %TEACHER COMMAND, 128 000000 128 . SO THAT TEACHER REPORTS ARE TO BE GENERATED. 129 000000 129 QCOUNT INTEGER COUNTER OF THE NUMBER OF QUESTIONS 130 000000 130 . (%QUESTION COMMANDS) IN THE LESSON. 131 000000 131 QUESTION STRING QUESTION IDENTIFICATION WHICH IS OUTPUT 132 000000 132 . ON THE TEACHER REPORTS TO SHOW HIM WHICH 133 000000 133 . QUESTION GAVE UNEXPECTED ANSWERS. 134 000000 134 . ALGOL PROGRAM, TO BE USED INSIDE QUESTIONS. 135 000000 135 RIGHT BOOLEAN TRUE FOR A %RIGHT COMMAND, FALSE FOR 136 000000 136 . A %WRONG COMMAND. 137 000000 137 RIGHTFOUND BOOLEAN TRUE IF ANY RIGHT ANSWER HAS BEEN FOUND 138 000000 138 . TO THE CURRENT OR PREVIOUS QUESTION. 139 000000 139 RIGHTSQUARE INTEGER ] 140 000000 140 SAME STRING LABEL TO JUMP TO IF A %SAME COMMAND IS 141 000000 141 . ENCOUNTERD. 142 000000 142 SAVEANLEN INTEGER SAVED VALUE OF ANSWERLENGTH. 143 000000 143 SEMICOLON INTEGER ; COMMENT 144 000000 144 SGNOSIS BOOLEAN DO NOT PRINT INITIAL MESSAGE TELLING THE 145 000000 145 . STUDENT THAT HE IS RUNNING GNOSIS. 146 000000 146 SKIP BOOLEAN SKIP INPUT LINES BECAUSE OF GNOSIS-TIME 147 000000 147 . SWITCH SETTINGS. 148 000000 148 SWITCHCOUNT INTEGER NUMBER OF GNOSIS-TIME SWITCHES. 149 000000 149 SWITCHNAME STRING ARRAY NAME OF ALL GNOSIS-TIME SWITCHES. 150 000000 150 SWITCHNUMBER INTEGER INDEX OF ONE GNOSIS-TIME SWITCH. 151 000000 151 SWITCHVAL BOOLEAN ARRAY SETTING OF GNOSIS-TIME SWITCH VALUES. 152 000000 152 SWITCHWORD STRING NAME OF ONE GNOSIS-TIME SWITCH. 153 000000 153 TEACHER STRING NAME AND ADDRESS OF THE TEACHER. 154 000000 154 TEMP TEMPORARY STRING. 155 000000 155 TEXCOUNT INTEGER COUNTER OF THE NUMBER OF TEXT SEGMENTS 156 000000 156 . (%TEXT COMMANDS) IN THE LESSON 157 000000 157 UCAA INTEGER $ 158 000000 158 UCAE INTEGER # 159 000000 159 UCE INTEGER E 160 000000 160 UCOE INTEGER @ 161 000000 161 UPARROW INTEGER ^ 162 000000 162 WORD STRING ONE WORD FROM A TEACHER ANSWER PATTERN. 163 000000 163 WPOS INTEGER POSITION IN THE TEXT OF THE LESSON LINE. 164 000000 164 Z INTEGER Z 165 000000 165 ZEROPRINTED BOOLEAN A TEST FOR EMPTY STUDENT ANSWERS 166 000000 166 . HAS BEEN PRINTED FOR THIS QUESTION. 167 000000 167 ------------------------------------------------------------------- 168 000000 168 ; 169 000000 169 170 000000 170 171 000000 171 172 000000 172 173 000000 173 174 000000 174 175 000000 175 176 000000 176 177 000004 B1 177 BEGIN 178 000004 178 179 000005 179 INTEGER 180 000005 180 controlchar, language, carriagereturn, linefeed, tabchar, blank, exclamation, 181 000005 181 answerlength, saveanlen, pos, pos2, wpos, charvalue, doublequote, 182 000005 182 a, z, formfeed, dot, qcount, texcount, semicolon, colon, equalsign, errlines, labelcount, 183 000005 183 linecount, leftsquare, rightsquare, switchcount, switchnumber, rightmargin, 184 000005 184 lcaa, lcae, lcoe, ucaa, ucae, ucoe, lce, uce; 185 000005 185 186 000005 186 STRING 187 000005 187 controlstart, word, lessonname, copyright, teacher, answer, firstright, previouslab, 188 000005 188 nextlesson, temp, question, lab, mainlab, same, infile, switchword, linenumber; 189 000005 189 190 000005 190 STRING ARRAY 191 000007 191 switchname[1:9]; 192 000007 192 193 000014 193 BOOLEAN 194 000014 194 extra, empty, order, right, neutral, allneutral, opened, put, sgnosis, 195 000014 195 nocontrolc, transferlesson, justify, controlinline, bell, name, lock, disk, 196 000014 196 lack, zeroprinted, keep, rightfound, skip, linenumbered; 197 000014 197 198 000014 198 BOOLEAN ARRAY 199 000034 199 switchval[1:9], ifset[0:9], ifval[1:9]; 200 000034 200 201 000034 201 202 000041 202 FORWARD PROCEDURE makemainlab, getcontrolstart, upcase, pastoperation; 203 000041 203 204 000041 204 205 000041 205 206 000041 206 FORWARD STRING PROCEDURE getword; 207 000041 207 208 000041 208 209 000041 209 210 000045 210 PROCEDURE delet(s); 211 000051 211 STRING s; 212 000051 212 COMMENT ------------------------------------------------- 213 000051 213 Delet will delete non-empty STRINGs, but will not (like 214 000051 214 Delete) cause an error if an attempt is made to delete an 215 000051 215 empty string. 216 000051 216 -----------------------------------------------------------; 217 000057 217 IF Length(s) > 0 THEN Delete(s); 218 000057 218 219 000057 219 220 000057 220 221 000067 221 PROCEDURE errmess(toggle, message); 222 000073 222 BOOLEAN toggle; 223 000073 223 VALUE message; 224 000073 224 STRING message; 225 000073 225 COMMENT ------------------------------------------------- 226 000073 226 This procedure causes a GNOSIS error (or warning) message to 227 000073 227 be displayed. The troublesome line and the next three lines 228 000073 228 of the lesson are displayed on the terminal. If the souce 229 000073 229 file contains line numbers, these will be displayed as 230 000073 230 reference points. If it does not, then the APPROXIMATE line 231 000073 231 numbers which are generated by the 'getline' PROCEDURE will 232 000073 232 be displayed. The identification number of the GNOSIS error 233 000073 233 message corresponds to the line in THIS file (i.e., 234 000073 234 GNOSIS.ALG) from which this error procedure was called. 235 000073 235 This is useful for debugging purposes since same kind of 236 000073 236 error can occur at many different points (e.g., errors in 237 000073 237 precedence). 238 000073 238 -----------------------------------------------------------; 239 000075 B2 239 BEGIN 240 000075 240 Selectoutput(0); 241 000100 241 IF errlines = 0 THEN 242 000103 B3 242 BEGIN 243 000103 243 IF linenumbered THEN 244 000105 B4 244 BEGIN 245 000105 245 temp:= Copy(linenumber); 246 000116 246 Write(temp); 247 000121 247 delet(temp) 248 000121 E4 248 END 249 000124 249 ELSE 250 000125 B5 250 BEGIN 251 000125 251 Write("LINE "); 252 000135 252 Print(linecount - 1, 5); 253 000141 253 Write(": ") 254 000144 E5 254 END; 255 000144 255 temp:= Copy(answer,1,answerlength); 256 000157 256 Write(temp); 257 000162 257 Newline; 258 000167 258 IF answerlength > 0 THEN delet(temp) 259 000172 E3 259 END; 260 000172 260 errlines:= 3; 261 000202 261 IF toggle THEN Write("****** ERROR Message No. ") ELSE Write("****** WARNING Message No. "); 262 000205 262 Write(message); 263 000210 263 Newline; 264 000212 264 Selectoutput(2) 265 000215 E2 265 END of PR*CEDURE errmess; 266 000215 266 267 000215 267 268 000215 268 269 000216 269 PROCEDURE getline; 270 000216 270 COMMENT ------------------------------------------------- 271 000216 271 'Getline' reads in a line of the lesson script. Any 272 000216 272 sequence of characters (including the null sequence) which 273 000216 273 is terminated by a or constitutes a line. A 274 000216 274 immediately after a will not cause any blank line. 275 000216 275 276 000216 276 This procedure ignores any line beginning with a '!' in 277 000216 277 column one, thus conforming to DEC comment conventions. 278 000216 278 -----------------------------------------------------------; 279 000226 B6 279 BEGIN 280 000227 280 INTEGER s, t, i; 281 000227 281 BOOLEAN taberror; 282 000227 282 283 000227 283 getnextline: 284 000241 284 linecount:= linecount+1; 285 000244 285 taberror:= FALSE; 286 000245 286 IF linenumbered THEN 287 000247 B7 287 BEGIN 288 000251 288 FOR i:= 1 STEP 1 UNTIL 5 DO 289 000255 B8 289 BEGIN 290 000255 290 Insymbol(t); 291 000260 291 linenumber.[i]:= t 292 000265 E8 292 END; 293 000266 293 Insymbol(t); 294 000271 294 taberror:= t > 32 295 000276 E7 295 END; 296 000276 296 controlinline:= FALSE; 297 000301 297 FOR i:= 1 STEP 1 UNTIL 133 DO 298 000305 B9 298 BEGIN 299 000305 299 300 000305 300 loop: 301 000315 301 Insymbol(t); 302 000320 302 answer.[i]:= t; 303 000325 303 IF t = controlchar THEN 304 000330 B10 304 BEGIN 305 000333 305 IF i # 1 THEN controlinline:= TRUE 306 000334 E10 306 END; 307 000337 307 IF t = linefeed THEN GOTO out; 308 000340 308 IF t = formfeed THEN 309 000343 B11 309 BEGIN 310 000343 310 Outsymbol(t); 311 000351 311 IF i = 1 THEN GOTO loop; 312 000352 312 i:= i+1; 313 000355 313 GOTO out 314 000355 E11 314 END 315 000356 E9 315 END; 316 000357 316 errmess(FALSE, "0316: Long input line will be truncated to 132 characters."); 317 000357 317 318 000357 318 out: 319 000373 319 answerlength:= i-2; 320 000404 320 IF answer.[1] = exclamation THEN GOTO getnextline; 321 000405 321 IF taberror THEN 322 000407 322 errmess(FALSE, "0322: Character after line-number is not TAB.") ELSE 323 000414 323 IF controlinline THEN 324 000416 324 errmess(FALSE, "0324: Command character not first in line."); 325 000422 325 IF errlines > 0 THEN 326 000425 B12 326 BEGIN 327 000425 327 errlines:= errlines-1; 328 000430 328 Selectoutput(0); 329 000433 329 IF linenumbered THEN 330 000435 B13 330 BEGIN 331 000435 331 temp:= Copy(linenumber); 332 000446 332 Write(temp); 333 000451 333 delet(temp) 334 000451 E13 334 END 335 000454 335 ELSE 336 000455 B14 336 BEGIN 337 000455 337 Write("LINE "); 338 000465 338 Print(linecount - 1, 5); 339 000471 339 Write(": ") 340 000474 E14 340 END; 341 000474 341 temp:= Copy(answer,1,answerlength); 342 000507 342 Write(temp); 343 000512 343 Newline; 344 000517 344 IF answerlength > 0 THEN delet(temp); 345 000522 345 IF errlines = 0 THEN 346 000525 346 Write("----------------------------------------------------------------------[N]"); 347 000530 347 Selectoutput(2) 348 000533 E12 348 END; 349 000533 349 COMMENT ------------------------------------------------- 350 000533 350 Now we check to see whether the current line is an %IF, 351 000533 351 %IFNOT or %IFEND command line and, if so, "skip" will be 352 000533 352 reset accordingly. "Skip" is the BOOLEAN which GNOSIS 353 000533 353 checks to determine whether or not to skip certain lines. 354 000533 354 -----------------------------------------------------------; 355 000541 355 IF answer.[1] # controlchar THEN GOTO noif; 356 000542 356 getcontrolstart(3); 357 000545 357 IF controlstart = "IF" THEN 358 000545 358 COMMENT -------------------------------------------------- 359 000545 359 Since the parameter passed to 'getcontrolstart' was 3 rather 360 000545 360 than the usual 4, %IF, %IFNOT and %IFEND will look the same 361 000545 361 at this point. (They do not differ in their first three 362 000545 362 characters.) 363 000545 363 -----------------------------------------------------------; 364 000552 B15 364 BEGIN 365 000552 365 pastoperation; 366 000554 366 switchword:= getword; 367 000564 367 upcase(switchword); 368 000574 368 IF Length(switchword) <= 0 THEN errmess(TRUE, "0368: No switchname in %IF-class command.[N]****** Line will be ignored."); 369 000602 369 FOR switchnumber:= 1 STEP 1 UNTIL switchcount DO 370 000616 370 IF switchname[switchnumber] = switchword THEN GOTO found; 371 000620 371 errmess(TRUE, "0371: Unknown switchname in %IF-class command.[N]****** Line will be ignored."); 372 000624 372 GOTO getnextline; 373 000624 373 374 000624 374 found: 375 000636 375 IF answer.[4] = lce OR answer.[4] = uce THEN 376 000636 376 COMMENT -------------------------------------------------- 377 000636 377 Since this command line began with "%IF" and had an "E" in 378 000636 378 the fourth position, it must be an %IFEND command. 379 000636 379 380 000636 380 This command turns off the %IF/%IFNOT facility. In other 381 000636 381 words, the SCOPE of each %IF or %IFNOT extends to the next 382 000636 382 occurrence of a %IFEND command. Thus, all text following 383 000636 383 %IFEND will be included in the translated lesson as usual, 384 000636 384 regardless of previous %IF's or %IFNOT's. Subsequent %IF's 385 000636 385 or %IFNOT's will, of course, create another need for an 386 000636 386 %IFEND to define THEIR scope -- unless that scope extends 387 000636 387 all the way to the end of the lesson. %IFEND must therefore 388 000636 388 follow some %IF or %IFNOT command. 389 000636 389 -----------------------------------------------------------; 390 000657 B16 390 BEGIN 391 000657 391 IF NOT ifset[switchnumber] THEN 392 000663 392 errmess(FALSE, "0392: %IFEND on non-active switch -- will have no effect."); 393 000667 393 ifset[switchnumber]:= FALSE 394 000672 E16 394 END ELSE 395 000673 B17 395 BEGIN 396 000673 396 ifset[switchnumber]:= TRUE; 397 000676 397 ifval[switchnumber]:= answer.[4] = blank 398 000676 398 COMMENT -------------------------------------------------- 399 000676 399 The line above handles both %IFNOT and %IF command lines. 400 000676 400 If no blank follows the "IF", then the appropriate item in 401 000676 401 the BOOLEAN ARRAY 'ifval' is switched FALSE since the 402 000676 402 trailing character (in position 4) can only be an "N" (i.e., 403 000676 403 a %IFNOT command line). On the othr hand, if a blank does 404 000676 404 follow the "IF", then the item is switched TRUE (i.e., since 405 000676 405 the command was a %IF). 406 000676 406 407 000676 407 Assuming has been declared and initialized by a 408 000676 408 %SWITCH command, the occurrence of %IF will cause the text 409 000676 409 between the %IF and the next %IFEND to be deposited in the 410 000676 410 translated lesson ONLY if was initialized TRUE. 411 000676 411 Otherwise these lines of text will be skipped. 412 000676 412 Correspondingly, the text between %IFNOT and the next %IFEND 413 000676 413 command will be included in the ALGOL translation of the 414 000676 414 lesson ONLY if is FALSE. 415 000676 415 -----------------------------------------------------------; 416 000710 E17 416 END; 417 000710 417 skip:= FALSE; 418 000713 418 FOR switchnumber:= 1 STEP 1 UNTIL switchcount DO 419 000717 419 skip:= skip OR ( ifset[switchnumber] AND NOT 420 000717 420 ( ifval[switchnumber] EQV switchval[switchnumber] )); 421 000735 421 GOTO getnextline 422 000736 E15 422 END ELSE 423 000736 423 424 000736 424 noif: 425 000751 425 IF skip THEN GOTO getnextline; 426 000752 426 pos:= 1 427 000754 E6 427 END of PR*CEDURE getline; 428 000754 428 429 000754 429 430 000754 430 431 000764 431 PROCEDURE upcase(s); 432 000770 432 STRING s; 433 000770 433 COMMENT -------------------------------------------------- 434 000770 434 'Upcase' will transform all letters in the parameter STRING 435 000770 435 from lower case to upper case. If the language of the 436 000770 436 lesson is swedish, then the swedish letters }, { and ` will 437 000770 437 also be transformed to upper case 438 000770 438 -----------------------------------------------------------; 439 000771 B18 439 BEGIN 440 000772 440 INTEGER t, i; 441 000774 441 FOR i:= 1 STEP 1 UNTIL Length(s) DO 442 001007 B19 442 BEGIN 443 001007 443 IF s.[i] >= 97 AND s.[i] <= 122 THEN 444 001031 444 s.[i]:= s.[i]-32 445 001046 445 ELSE IF language = 2 THEN 446 001051 B20 446 BEGIN 447 001057 447 IF s.[i] = lcaa THEN s.[i]:= ucaa ELSE 448 001075 448 IF s.[i] = lcae THEN s.[i]:= ucae ELSE 449 001113 449 IF s.[i] = lcoe THEN s.[i]:= ucoe 450 001113 E20 450 END 451 001122 E19 451 END 452 001123 E18 452 END of PR*CEDURE upcase; 453 001123 453 454 001123 454 455 001123 455 456 001134 456 PROCEDURE getcontrolstart(i); 457 001140 457 VALUE i; 458 001140 458 INTEGER i; 459 001140 459 COMMENT -------------------------------------------------- 460 001140 460 'Getcontrolstart' extracts that part of a command line which 461 001140 461 contains the beginning of the command text. This beginning 462 001140 462 determines what GNOSIS will do until it encounters another 463 001140 463 command line. The PROCEDURE also passes over unrecognized 464 001140 464 commands and any non-command line(s) which may follow them. 465 001140 465 This ensures that the error scan will be able to generate 466 001140 466 meaningful messages for the user and, with a little luck, 467 001140 467 may enable GNOSIS to produce a program the ALGOL compiler 468 001140 468 will accept despite user error. 469 001140 469 -----------------------------------------------------------; 470 001141 B21 470 BEGIN 471 001141 471 472 001141 472 repeat: 473 001152 473 delet(controlstart); 474 001155 474 controlstart:= Copy(answer,2,i); 475 001170 475 upcase(controlstart); 476 001173 476 IF i = 4 THEN 477 001176 B22 477 BEGIN 478 001176 478 COMMENT -------------------------------------------------- 479 001176 479 We scan down this list, eliminating the most frequently used 480 001176 480 GNOSIS commands first. The semicolon after 'THEN' is a 481 001176 481 dummy statement used to outwit the compiler (it still 482 001176 482 complains some). This is as close as we can come to a case 483 001176 483 statement in ALGOL. 484 001176 484 -----------------------------------------------------------; 485 001203 485 IF controlstart = "RIG" THEN ; ******* ^ 485 SEMICOLON PROBABLY SUPERFLUOUS 486 001211 486 ELSE IF controlstart = "WRO" THEN ; ******* ^ 486 SEMICOLON PROBABLY SUPERFLUOUS 487 001217 487 ELSE IF controlstart = "SAM" THEN ; ******* ^ 487 SEMICOLON PROBABLY SUPERFLUOUS 488 001225 488 ELSE IF controlstart = "ORD" THEN ; ******* ^ 488 SEMICOLON PROBABLY SUPERFLUOUS 489 001233 489 ELSE IF controlstart = "NOO" THEN ; ******* ^ 489 SEMICOLON PROBABLY SUPERFLUOUS 490 001241 490 ELSE IF controlstart = "EXT" THEN ; ******* ^ 490 SEMICOLON PROBABLY SUPERFLUOUS 491 001247 491 ELSE IF controlstart = "NOE" THEN ; ******* ^ 491 SEMICOLON PROBABLY SUPERFLUOUS 492 001255 492 ELSE IF controlstart = "QUE" THEN ; ******* ^ 492 SEMICOLON PROBABLY SUPERFLUOUS 493 001263 493 ELSE IF controlstart = "NEU" THEN ; ******* ^ 493 SEMICOLON PROBABLY SUPERFLUOUS 494 001271 494 ELSE IF controlstart = "LAC" THEN ; ******* ^ 494 SEMICOLON PROBABLY SUPERFLUOUS 495 001277 495 ELSE IF controlstart = "GO " THEN ; ******* ^ 495 SEMICOLON PROBABLY SUPERFLUOUS 496 001305 496 ELSE IF controlstart = "GOT" THEN ; ******* ^ 496 SEMICOLON PROBABLY SUPERFLUOUS 497 001313 497 ELSE IF controlstart = "TEX" THEN ; ******* ^ 497 SEMICOLON PROBABLY SUPERFLUOUS 498 001321 498 ELSE IF controlstart = "JUS" THEN ; ******* ^ 498 SEMICOLON PROBABLY SUPERFLUOUS 499 001327 499 ELSE IF controlstart = "NOJ" THEN ; ******* ^ 499 SEMICOLON PROBABLY SUPERFLUOUS 500 001335 500 ELSE IF controlstart = "HEL" THEN ; ******* ^ 500 SEMICOLON PROBABLY SUPERFLUOUS 501 001343 501 ELSE IF controlstart = "VAR" THEN ; ******* ^ 501 SEMICOLON PROBABLY SUPERFLUOUS 502 001351 502 ELSE IF controlstart = "PRO" THEN ; ******* ^ 502 SEMICOLON PROBABLY SUPERFLUOUS 503 001357 503 ELSE IF controlstart = "INI" THEN ; ******* ^ 503 SEMICOLON PROBABLY SUPERFLUOUS 504 001365 504 ELSE IF controlstart = "ALG" THEN ; ******* ^ 504 SEMICOLON PROBABLY SUPERFLUOUS 505 001373 505 ELSE IF controlstart = "QEN" THEN ; ******* ^ 505 SEMICOLON PROBABLY SUPERFLUOUS 506 001401 506 ELSE IF controlstart = "END" THEN ; ******* ^ 506 SEMICOLON PROBABLY SUPERFLUOUS 507 001407 507 ELSE IF controlstart = "TEA" THEN ; ******* ^ 507 SEMICOLON PROBABLY SUPERFLUOUS 508 001415 508 ELSE IF controlstart = "NAM" THEN ; ******* ^ 508 SEMICOLON PROBABLY SUPERFLUOUS 509 001423 509 ELSE IF controlstart = "KEE" THEN ; ******* ^ 509 SEMICOLON PROBABLY SUPERFLUOUS 510 001431 510 ELSE IF controlstart = "BEL" THEN ; ******* ^ 510 SEMICOLON PROBABLY SUPERFLUOUS 511 001437 511 ELSE IF controlstart = "DSK" THEN ; ******* ^ 511 SEMICOLON PROBABLY SUPERFLUOUS 512 001445 512 ELSE IF controlstart = "DIS" THEN ; ******* ^ 512 SEMICOLON PROBABLY SUPERFLUOUS 513 001453 513 ELSE IF controlstart = "LOC" THEN ; ******* ^ 513 SEMICOLON PROBABLY SUPERFLUOUS 514 001461 514 ELSE IF controlstart = "COP" THEN ; ******* ^ 514 SEMICOLON PROBABLY SUPERFLUOUS 515 001467 515 ELSE IF controlstart = "LAN" THEN ; ******* ^ 515 SEMICOLON PROBABLY SUPERFLUOUS 516 001475 516 ELSE IF controlstart = "SGN" THEN ; ******* ^ 516 SEMICOLON PROBABLY SUPERFLUOUS 517 001503 517 ELSE IF controlstart = "SWI" THEN ; ******* ^ 517 SEMICOLON PROBABLY SUPERFLUOUS 518 001511 518 ELSE IF controlstart = "NOC" THEN ; ******* ^ 518 SEMICOLON PROBABLY SUPERFLUOUS 519 001517 519 ELSE IF controlstart = "NEX" THEN ; ******* ^ 519 SEMICOLON PROBABLY SUPERFLUOUS 520 001525 520 ELSE IF controlstart = "FIN" THEN ; ******* ^ 520 SEMICOLON PROBABLY SUPERFLUOUS 521 001533 521 ELSE IF controlstart = "IF " THEN ; ******* ^ 521 SEMICOLON PROBABLY SUPERFLUOUS 522 001541 522 ELSE IF controlstart = "IFE" THEN ; ******* ^ 522 SEMICOLON PROBABLY SUPERFLUOUS 523 001547 523 ELSE IF controlstart = "IFN" THEN ; ******* ^ 523 SEMICOLON PROBABLY SUPERFLUOUS 524 001547 524 ELSE 525 001550 B23 525 BEGIN 526 001550 526 errmess(TRUE, 527 001550 527 "0527: Unrecognized command line found. As a result,[N]****** this line up to next command line will be ignored."); 528 001554 528 getline; 529 001564 529 WHILE answer.[1] # controlchar DO getline; 530 001567 530 i:= 4; 531 001571 531 GOTO repeat 532 001571 E23 532 END 533 001572 E22 533 END 534 001572 E21 534 END of PR*CEDURE getcontrolstart; 535 001572 535 536 001572 536 537 001572 537 538 001573 538 STRING PROCEDURE getword; 539 001573 539 COMMENT -------------------------------------------------- 540 001573 540 'Getword' scans the input line, beginning at 'pos', and 541 001573 541 finds a word. For purposes of this PROCEDURE, any STRING of 542 001573 542 non-blank characters terminated by a blank or a 543 001573 543 will constitute a word. Leading and trailing blanks are not 544 001573 544 assumed to be part of the word. 'Getword' will move 'pos' 545 001573 545 to the end of the found word. 546 001573 546 -----------------------------------------------------------; 547 001603 B24 547 BEGIN 548 001604 548 INTEGER pos1, t; 549 001604 549 pos1:= pos; 550 001611 550 IF pos1 # 1 THEN GOTO blankloop; 551 001611 551 552 001611 552 textloop: 553 001623 553 t:= answer.[pos1]; 554 001633 554 IF t = carriagereturn THEN GOTO null; 555 001634 555 IF t # blank THEN 556 001637 B25 556 BEGIN 557 001637 557 pos1:= pos1+1; 558 001642 558 GOTO textloop 559 001643 E25 559 END; 560 001643 560 561 001643 561 blankloop: 562 001654 562 t:= answer.[pos1]; 563 001664 563 IF t = carriagereturn THEN GOTO null; 564 001665 564 IF t = blank THEN 565 001670 B26 565 BEGIN 566 001670 566 pos1:= pos1+1; 567 001673 567 GOTO blankloop 568 001674 E26 568 END; 569 001702 569 IF answer.[pos1] = carriagereturn THEN GOTO null; 570 001703 570 pos:= pos1+1; 571 001703 571 572 001703 572 wordloop: 573 001717 573 t:= answer.[pos]; 574 001724 574 IF t # blank AND t # carriagereturn THEN 575 001736 B27 575 BEGIN 576 001736 576 pos:= pos+1; 577 001741 577 GOTO wordloop 578 001742 E27 578 END; 579 001747 579 getword:= Copy(answer,pos1,pos-1); 580 001762 580 GOTO out; 581 001762 581 582 001762 582 null: 583 001773 583 getword:= ""; 584 001773 584 585 001773 585 out: 586 002012 E24 586 END of PR*CEDURE getword; 587 002012 587 588 002012 588 589 002012 589 590 002022 590 PROCEDURE alglin(s); 591 002026 591 VALUE s; 592 002026 592 STRING s; 593 002026 593 COMMENT -------------------------------------------------- 594 002026 594 'Alglin' will dump the STRING passed to it as a parameter 595 002026 595 into the translated lesson. Since this parameter could 596 002026 596 contain characters which are not supposed to have their 597 002026 597 usual ALGOL function (i.e., the semicolon, the left and 598 002026 598 right square bracket, and the doubequote), we could not take 599 002026 599 advantage of the built-in PROCEDURE 'Write'. A is 600 002026 600 output after the STRING. 601 002026 601 -----------------------------------------------------------; 602 002027 B28 602 BEGIN 603 002031 603 FOR wpos:= 1 STEP 1 UNTIL Length(s) DO 604 002051 604 Outsymbol(s.[wpos]); 605 002051 605 Newline 606 002057 E28 606 END of PR*CEDURE alglin; 607 002057 607 608 002057 608 609 002057 609 610 002064 610 PROCEDURE textline(s); 611 002070 611 VALUE s; 612 002070 612 STRING s; 613 002070 613 COMMENT -------------------------------------------------- 614 002070 614 'Textline' will output a line in an Algol 10 program. This 615 002070 615 line contains a call to the Algol 10 PROCEDURE "Write" such 616 002070 616 that the input STRING is written. Example: If the input 617 002070 617 STRING is "ABCD[I]" then this PROCEDURE will output the line 618 002070 618 "Write("ABCD[[I]]"). 619 002070 619 620 002070 620 We developed this PROCEDURE so that we would not go bonkers 621 002070 621 trying to nest square brackets and doublequotes -- not to 622 002070 622 mention a 'Write' inside another 'Write'. However, the 623 002070 623 program was mostly finished before we began to take 624 002070 624 advantage of it. 625 002070 625 -----------------------------------------------------------; 626 002071 B29 626 BEGIN 627 002072 627 INTEGER pos, t; 628 002072 628 Write("Write("""); 629 002077 629 FOR pos:= 1 STEP 1 UNTIL Length(s) DO 630 002112 B30 630 BEGIN 631 002112 631 t:= s.[pos]; 632 002117 632 IF t = doublequote OR t = semicolon OR 633 002117 633 t = leftsquare OR t = rightsquare 634 002143 634 THEN Outsymbol(t); 635 002146 635 Outsymbol(t) 636 002151 E30 636 END; 637 002152 637 Write("[[N]]"");;[N]") 638 002155 E29 638 END of PR*CEDURE textline; 639 002155 639 640 002155 640 641 002155 641 642 002161 642 PROCEDURE textlines; 643 002161 643 COMMENT -------------------------------------------------- 644 002161 644 'Textlines' will take text from the GNOSIS lesson and 645 002161 645 translate that text to an Algol 10 program sequence which, 646 002161 646 in turn, will write that text to the user. Succesive lines 647 002161 647 from the GNOSIS lesson are translated until a line is found 648 002161 648 which contains a GNOSIS command. 649 002161 649 650 002161 650 In %NOJUSTIFY mode, GNOSIS watches vertical spacing only, 651 002161 651 ensuring that scrolling will cease as soon as the screen is 652 002161 652 full. (A call to 'pause' is inserted for this purpose.) In 653 002161 653 %JUSTIFY mode, GNOSIS not only watches vertical spacing but 654 002161 654 also edits the text in such a way that a semi-justified 655 002161 655 right margin is produced (at or before column 72). In this 656 002161 656 mode, GNOSIS will be sensitive to the occurrence of the 657 002161 657 semicolon, right and left square bracket, and the 658 002161 658 doublequote. This sensitivity will probably be removed in 659 002161 659 later versions. 660 002161 660 -----------------------------------------------------------; 661 002171 B31 661 BEGIN 662 002172 662 INTEGER outpos, screenlines; 663 002172 663 STRING nextword; 664 002174 664 BOOLEAN writingaline, morewords; 665 002174 665 666 002174 666 667 002174 667 668 002175 668 STRING PROCEDURE getnextword; 669 002175 669 COMMENT -------------------------------------------------- 670 002175 670 Same as 'getword' except does not scan past first word in 671 002175 671 'answer'. 672 002175 672 -----------------------------------------------------------; 673 002205 B32 673 BEGIN 674 002206 674 INTEGER pos1, t; 675 002206 675 pos1:= pos; 676 002210 676 t:= answer.[pos1]; 677 002220 677 IF t = carriagereturn THEN GOTO null; 678 002220 678 679 002220 679 blankloop: 680 002232 680 t:= answer.[pos1]; 681 002242 681 IF t = carriagereturn THEN GOTO null; 682 002243 682 IF t = blank OR t = tabchar THEN 683 002255 B33 683 BEGIN 684 002255 684 pos1:= pos1+1; 685 002260 685 GOTO blankloop 686 002261 E33 686 END; 687 002267 687 IF answer.[pos1] = carriagereturn THEN GOTO null; 688 002270 688 pos:= pos1+1; 689 002270 689 690 002270 690 wordloop: 691 002304 691 t:= answer.[pos]; 692 002311 692 IF t # blank AND t # carriagereturn THEN 693 002323 B34 693 BEGIN 694 002323 694 pos:= pos+1; 695 002326 695 GOTO wordloop 696 002327 E34 696 END; 697 002334 697 getnextword:= Copy(answer,pos1,pos-1); 698 002347 698 GOTO out; 699 002347 699 700 002347 700 null: 701 002360 701 getnextword:= ""; 702 002360 702 703 002360 703 out: 704 002377 E32 704 END of PR*CEDURE getnextword; 705 002377 705 706 002403 706 getline; 707 002405 707 IF NOT justify THEN 708 002407 B35 708 BEGIN 709 002407 709 screenlines:= 0; 710 002410 710 WHILE answer.[1] # controlchar DO 711 002416 B36 711 BEGIN 712 002416 712 IF answerlength = 0 THEN 713 002421 B37 713 BEGIN 714 002421 714 screenlines:= screenlines + 1; 715 002427 715 IF screenlines < 22 THEN Write("Newline;;[N]") ELSE 716 002433 B38 716 BEGIN 717 002433 717 screenlines:= 0; 718 002434 718 Write("pause;;[N]") 719 002434 E38 719 END 720 002437 E37 720 END 721 002437 721 ELSE 722 002440 B39 722 BEGIN 723 002440 723 screenlines:=screenlines + 1; 724 002443 724 IF screenlines > 21 THEN 725 002446 B40 725 BEGIN 726 002446 726 Write("pause;;[N]"); 727 002451 727 screenlines:= 0 728 002452 E40 728 END; 729 002471 729 textline((temp:=Copy(answer,1,answerlength))); 730 002474 730 delet(temp) 731 002477 E39 731 END; 732 002477 732 getline 733 002477 E36 733 END 734 002501 E35 734 END 735 002502 735 ELSE 736 002503 B41 736 BEGIN 737 002503 737 writingaline:= FALSE; 738 002504 738 screenlines:= 0; 739 002505 739 outpos:= 1; 740 002507 740 WHILE answer.[1] # controlchar DO 741 002515 B42 741 BEGIN 742 002515 742 IF answerlength = 0 THEN 743 002520 B43 743 BEGIN 744 002520 744 IF writingaline THEN 745 002522 B44 745 BEGIN 746 002522 746 Write("[[N]]"");;[N]"); 747 002525 747 screenlines:= screenlines + 1; 748 002530 748 IF screenlines < 22 THEN 749 002533 B45 749 BEGIN 750 002533 750 Write("Newline;;[N]"); 751 002536 751 screenlines:= screenlines + 1 752 002536 E45 752 END 753 002541 753 ELSE 754 002542 B46 754 BEGIN 755 002542 755 Write("pause;;[N]"); 756 002545 756 screenlines:= 0 757 002546 E46 757 END; 758 002546 758 writingaline:= FALSE; 759 002547 759 outpos:= 1 760 002547 E44 760 END 761 002551 761 ELSE 762 002552 B47 762 BEGIN 763 002552 763 screenlines:= screenlines + 1; 764 002555 764 IF screenlines < 22 THEN 765 002560 B48 765 BEGIN 766 002560 766 Write("Newline;;[N]"); 767 002563 767 screenlines:= screenlines + 1 768 002563 E48 768 END 769 002566 769 ELSE 770 002567 B49 770 BEGIN 771 002567 771 Write("pause;;[N]"); 772 002572 772 screenlines:= 0 773 002572 E49 773 END 774 002573 E47 774 END 775 002573 E43 775 END 776 002573 776 ELSE 777 002574 B50 777 BEGIN 778 002574 778 morewords:= TRUE; 779 002577 779 IF NOT writingaline THEN Write("Write("""); 780 002602 780 writingaline:= TRUE; 781 002603 781 WHILE morewords DO 782 002605 B51 782 BEGIN 783 002605 783 delet(nextword); 784 002610 784 nextword:= getnextword; 785 002625 785 IF nextword = "" THEN morewords:= FALSE 786 002625 786 ELSE 787 002627 B52 787 BEGIN 788 002627 788 outpos:= outpos + Length(nextword) + 1; 789 002635 789 IF outpos < rightmargin THEN 790 002640 B53 790 BEGIN 791 002640 791 Write(nextword); 792 002643 792 Write(" ") 793 002643 E53 793 END 794 002646 794 ELSE 795 002647 B54 795 BEGIN 796 002647 796 Write("[[N]]"");;[N]"); 797 002652 797 screenlines:= screenlines + 1; 798 002655 798 IF screenlines > 21 THEN 799 002660 B55 799 BEGIN 800 002660 800 Write("pause;;[N]"); 801 002663 801 screenlines:= 0 802 002664 E55 802 END; 803 002664 803 outpos:= Length(nextword) + 1; 804 002671 804 Write("Write("""); 805 002674 805 Write(nextword); 806 002677 806 Write(" ") 807 002677 E54 807 END 808 002702 E52 808 END 809 002702 E51 809 END morewords loop; 810 002703 E50 810 END writing cycle for string currently in "answer"; 811 002703 811 getline 812 002705 E42 812 END WHIL* answer.[1] # controlchar; 813 002710 813 IF writingaline THEN Write("[[N]]"");;[N]") 814 002713 E41 814 END; 815 002716 815 IF screenlines > 18 THEN Write("pause;;[N]"); 816 002721 816 getcontrolstart(4) 817 002724 E31 817 END of PR*CEDURE textlines; 818 002724 818 819 002724 819 820 002724 820 821 002726 821 PROCEDURE pastoperation; 822 002726 822 COMMENT -------------------------------------------------- 823 002726 823 'Pastoperation' will scan an input line (usually a GNOSIS 824 002726 824 command line) and find the first non-blank character after 825 002726 825 the first blank. Thus, the PROCEDURE scans past the command 826 002726 826 word. The array address of the found character is stored in 827 002726 827 'pos'. 828 002726 828 -----------------------------------------------------------; 829 002737 B56 829 BEGIN 830 002741 830 FOR pos:= 1 STEP 1 UNTIL answerlength+1 DO 831 002755 831 IF answer.[pos] = blank THEN GOTO bskip; 832 002755 832 833 002755 833 bskip: 834 002772 834 FOR pos:= pos STEP 1 UNTIL answerlength+1 DO 835 003006 835 IF answer.[pos] # blank THEN GOTO out; 836 003006 836 out: 837 003020 E56 837 END of PR*CEDURE pastoperation; 838 003020 838 839 003020 839 840 003020 840 841 003021 841 PROCEDURE shortalgol; 842 003021 842 COMMENT -------------------------------------------------- 843 003021 843 Many GNOSIS commands can contain a short ALGOL program 844 003021 844 sequence after the end of the command (e.g., '%QUE IF 845 003021 845 lasterrors > 0 THEN'). 'Shortalgol' will transfer that 846 003021 846 short ALGOL program sequence unchanged from the GNOSIS 847 003021 847 lesson into the ALGOL translation of the lesson. 848 003021 848 -----------------------------------------------------------; 849 003031 B57 849 BEGIN 850 003031 850 pastoperation; 851 003033 851 IF pos <= answerlength THEN 852 003055 852 alglin((temp:=Copy(answer,pos,answerlength))); 853 003060 853 delet(temp) 854 003063 E57 854 END of PR*CEDURE shortalgol; 855 003063 855 856 003063 856 857 003063 857 858 003064 858 PROCEDURE goanywherecommands; 859 003064 859 COMMENT -------------------------------------------------- 860 003064 860 'Goanywherecommands' will determine whether the GNOSIS 861 003064 861 command at the current command line is one of te go-anywhere 862 003064 862 commands (i.e., %JUSTIFY, %NOJUSTIFY, %EXTRA, %NOEXTRA, 863 003064 863 %ORDER, %NOORDER, %GOTO, or %ALGOL) and take appropriate 864 003064 864 action. The first six will set internal BOOLEAN variables 865 003064 865 in the GNOSIS program. %ALGOL will cause an ALGOL program 866 003064 866 sequence to be transferred unchanged from the GNOSIS lesson 867 003064 867 into the ALGOL translation of that lesson. If there are 868 003064 868 more than one of these commands in succession, they will all 869 003064 869 be handled by this PROCEDURE. The PROCEDURE returns when a 870 003064 870 GNOSIS command is encountered which is none of the eight 871 003064 871 handled by this PROCEDURE. 872 003064 872 873 003064 873 Note: In terms of their behavior, %IF, %IFEND, and %IFNOT 874 003064 874 function like the 'goanywhere' commands. They, too, may 875 003064 875 appear anywhere in the lesson as long as a %SWITCH command 876 003064 876 precedes them. 877 003064 877 -----------------------------------------------------------; 878 003076 B58 878 BEGIN 879 003076 879 880 003076 880 loop: 881 003113 881 IF controlstart = "JUS" THEN justify:= TRUE ELSE 882 003122 882 IF controlstart = "NOJ" THEN justify:= FALSE ELSE 883 003122 883 COMMENT -------------------------------------------------- 884 003122 884 The %JUSTIFY command causes all text, includin the text in 885 003122 885 %QUESTION blocks and %HELP blocks, to be semi-justified to 886 003122 886 produce a ragged right at column =< 72. It also causes such 887 003122 887 text material to be paged out in such a way that nothing 888 003122 888 will be lost scrolling off the top of a CRT. 889 003122 889 890 003122 890 Although GNOSIS begins processing text material in the 891 003122 891 %NOJUSTIFY mode, an occurrence of the %JUSTIFY command will 892 003122 892 change th mode of processing until a subsequent %NOJUSTIFY 893 003122 893 command is encountered. 894 003122 894 895 003122 895 In %NOJUSTIFY mode GNOSIS continues to recognize when the 896 003122 896 CRT screen heigth is about to be exceeded and arranges for 897 003122 897 the lesson to issue a call to the 'pause' PROCEDURE at the 898 003122 898 appropriate time. However, there is in this mode no attempt 899 003122 899 at right-justification. Consequently, in %NOJUSTIFY mode, 900 003122 900 text will be displayed to the student exactly as it appears 901 003122 901 in the GNOSIS source script. 902 003122 902 -----------------------------------------------------------; 903 003131 903 IF controlstart = "EXT" THEN extra:= TRUE ELSE 904 003140 904 IF controlstart = "NOE" THEN extra:= FALSE ELSE 905 003140 905 COMMENT -------------------------------------------------- 906 003140 906 The above commands influence the way in which student 907 003140 907 answers are compared to canned answer patterns. After a 908 003140 908 %EXTRA command, and until the next %NOEXTRA command, student 909 003140 909 answers will be considered correct even if they contain 910 003140 910 extra characters not part of the %RIGHT answer pattern 911 003140 911 PROVIDED they do at least contain all the essential 912 003140 912 characters. If they answer DOES contain extra characters, 913 003140 913 then GNOSIS will flag the essential characters with 914 003140 914 uparrows. 915 003140 915 -----------------------------------------------------------; 916 003147 916 IF controlstart = "ORD" THEN order:= TRUE ELSE 917 003156 917 IF controlstart = "NOO" THEN order:= FALSE ELSE 918 003156 918 COMMENT -------------------------------------------------- 919 003156 919 These commands also influence the way in which student 920 003156 920 answers are compared to canned answer patterns. After a 921 003156 921 %ORDER command -- and until the next %NOORDER command -- a 922 003156 922 student's answer will be considered correct only if the 923 003156 923 elements of the student's answer appear in PRECISELY the 924 003156 924 same order as the elements of the canned answer pattern. 925 003156 925 -----------------------------------------------------------; 926 003160 926 IF controlstart = "GOT" OR controlstart = "GO " THEN 927 003160 927 COMMENT -------------------------------------------------- 928 003160 928 The %GOTO command works just the way 'GOTO' works in ALGOL 929 003160 929 itself. Since the old version of GNOSIS allowed %GOTO 930 003160 930 command lines to end without a semicolon and the new version 931 003160 931 doesn't, the code below was added to make the old and new 932 003160 932 versions compatible. Also, in this version, the %GOTO 933 003160 933 command can appear anywhere in the lesson script, not (as 934 003160 934 was formerly the case) just in %QUESTION environments. 935 003160 935 -----------------------------------------------------------; 936 003177 B59 936 BEGIN 937 003200 937 INTEGER i; 938 003217 938 alglin((temp:= Copy(answer,2,answerlength))); 939 003222 939 i:= answerlength; 940 003241 940 WHILE answer.[i] = blank AND i > 4 DO i:= i-1; 941 003245 941 IF answer.[i] # semicolon THEN 942 003253 B60 942 BEGIN 943 003253 943 errmess(FALSE, "0943: Semicolon omitted at end of '%GOTO' command.[N]****** GNOSIS will supply one for you."); 944 003257 944 Outsymbol(semicolon); 945 003257 945 Newline 946 003264 E60 946 END; 947 003264 947 delet(temp) 948 003267 E59 948 END ELSE 949 003273 949 IF controlstart = "ALG" THEN 950 003273 950 COMMENT -------------------------------------------------- 951 003273 951 This command causes one or more lines of ALGOL code to be 952 003273 952 transferred unchanged to the ALGOL translation of the 953 003273 953 lesson. The segment must be legal in ALGOL and, in 954 003273 954 addition, must mesh with the GNOSIS lesson at the point of 955 003273 955 isertion. 956 003273 956 -----------------------------------------------------------; 957 003300 B61 957 BEGIN 958 003300 958 shortalgol; 959 003300 959 960 003300 960 algloop: 961 003313 961 getline; 962 003323 962 IF answer.[1] = controlchar THEN GOTO out; 963 003327 963 IF answerlength = 0 THEN Newline ELSE 964 003332 B62 964 BEGIN 965 003351 965 alglin((temp:=Copy(answer,1,answerlength))); 966 003354 966 delet(temp) 967 003357 E62 967 END; 968 003357 968 GOTO algloop 969 003361 E61 969 END ELSE GOTO return; 970 003362 970 getline; 971 003364 971 IF answer.[1] # controlchar THEN 972 003372 B63 972 BEGIN 973 003372 973 errmess(TRUE, 974 003372 974 "0974: A command line is required at this point. As a result,[N]****** this line up to next command line will be ignored."); 975 003376 975 WHILE answer.[1] # controlchar DO getline 976 003407 E63 976 END; 977 003407 977 978 003407 978 out: 979 003417 979 getcontrolstart(4); 980 003422 980 GOTO loop; 981 003422 981 982 003422 982 return: 983 003434 E58 983 END of PR*CEDURE goanywherecommands; 984 003434 984 985 003434 985 986 003434 986 987 003435 987 PROCEDURE putaway; 988 003435 988 COMMENT -------------------------------------------------- 989 003435 989 'Putaway' writes into the lesson identifying phrases. If 990 003435 990 teacher reports are generated and the student's answer to a 991 003435 991 question is unexpected, then this identifier will be paired 992 003435 992 with his answer and both will be routed to the teacher 993 003435 993 reports. If the teacher gave the question a label, then 994 003435 994 this label will also be included as part of the identifying 995 003435 995 phrase. 996 003435 996 997 003435 997 -----------------------------------------------------------; 998 003445 B64 998 BEGIN 999 003446 999 INTEGER t; 1000 003446 B65 1000 BEGIN 1001 003446 1001 Write("putaway(""%QUE"); 1002 003451 1002 Print(qcount,2); 1003 003455 1003 IF Length(question) > 0 THEN 1004 003462 B66 1004 BEGIN 1005 003462 1005 Write(";;;;"); 1006 003467 1006 FOR pos2:= 1 STEP 1 UNTIL Length(question) DO 1007 003502 B67 1007 BEGIN 1008 003502 1008 t:= question.[pos2]; 1009 003507 1009 IF t = leftsquare OR t = rightsquare 1010 003507 1010 OR t = semicolon OR t = doublequote 1011 003533 1011 THEN Outsymbol(t); 1012 003536 1012 Outsymbol(t) 1013 003536 E67 1013 END 1014 003542 E66 1014 END; 1015 003542 1015 Write(""");;[N]") 1016 003542 E65 1016 END 1017 003545 E64 1017 END of PR*CEDURE putaway; 1018 003545 1018 1019 003545 1019 1020 003545 1020 1021 003551 1021 PROCEDURE unknownmessage; 1022 003551 1022 COMMENT -------------------------------------------------- 1023 003551 1023 'Unknownmessage' will output that ALGOL program sequence 1024 003551 1024 which handles an answer from the student which was not 1025 003551 1025 expected by the teacher (i.e., a "%NEUTRAL or %WRONG" 1026 003551 1026 command with no teacher answer pattern following it). The 1027 003551 1027 ALGOL program produced will give an appropriate message to 1028 003551 1028 the student and write the unexpected answer into the teacher 1029 003551 1029 reports (if any) so that the teacher can study the answer in 1030 003551 1030 order to improve the lesson. Unless ALL the answer commands 1031 003551 1031 following a particular %QUESTION command have been %NEUTRAL 1032 003551 1032 commands, 'unknownmessage' causes a call on 'wrongmessage' 1033 003551 1033 to be issued. 1034 003551 1034 -----------------------------------------------------------; 1035 003562 B68 1035 BEGIN 1036 003562 1036 Write("BEGIN[N]"); 1037 003565 1037 IF allneutral THEN 1038 003567 B69 1038 BEGIN 1039 003567 1039 IF language = 1 THEN 1040 003572 1040 Write("Write(""I don't understand your answer.[[N]]"");;[N]") 1041 003576 1041 ELSE IF language = 2 THEN 1042 003601 1042 Write("Write(""Jag f`rst}r inte ditt svar.[[N]]"");;[N]") 1043 003601 E69 1043 END 1044 003605 1044 ELSE Write("wrongmessage;;[N]"); 1045 003610 1045 IF put THEN putaway 1046 003614 E68 1046 END of PR*CEDURE unknownmessage; 1047 003614 1047 1048 003614 1048 1049 003614 1049 1050 003615 1050 PROCEDURE zeroprint; 1051 003615 1051 COMMENT -------------------------------------------------- 1052 003615 1052 'Zeroprint' will output an ALGOL program sequence which will 1053 003615 1053 determine whether the student answer was empty and, in that 1054 003615 1054 case, tell the student what happened and give the question 1055 003615 1055 once more to the student. 1056 003615 1056 -----------------------------------------------------------; 1057 003625 B70 1057 BEGIN 1058 003625 1058 Write("IF answerlength = 0 THEN[N]"); 1059 003630 1059 Write("BEGIN[N]"); 1060 003633 1060 Write("noanswer;;[N]GOTO repeat;;[N]END;;[N]"); 1061 003636 1061 zeroprinted:= TRUE 1062 003637 E70 1062 END of PR*CEDURE zeroprint; 1063 003637 1063 1064 003637 1064 1065 003637 1065 1066 003645 1066 PROCEDURE checkprecedence(n); 1067 003651 1067 INTEGER n; 1068 003651 1068 COMMENT ------------------------------------------------- 1069 003651 1069 'Checkprecedence' does some rudimentary checking to 1070 003651 1070 determine whether the lesson author used GNOSIS commands in 1071 003651 1071 the proper order, warns him if he did not, and tries to 1072 003651 1072 recover from the error. Not all errors of precedence are 1073 003651 1073 caught by this check since some are context-dependent. A 1074 003651 1074 complete precedence table for GNOSIS commands appears below: 1075 003651 1075 1076 003651 1076 ======================================================= 1077 003651 1077 PRECEDENCE COMMAND COMMENT 1078 003651 1078 ======================================================= 1079 003651 1079 0 %ALGOL Use of these commands is 1080 003651 1080 0 %EXTRA unrestricted. They may go 1081 003651 1081 0 %GOTO anywhere in the lesson. 1082 003651 1082 0 %IF 1083 003651 1083 0 %IFEND However, the %SWITCH 1084 003651 1084 0 %IFNOT command must precede 1085 003651 1085 0 %JUSTIFsY %IF, %IFENDs and %IFNOTs. 1086 003651 1086 0 %NOEXTRA 1087 003651 1087 0 %NOJUSTIFY 1088 003651 1088 0 %NOORDER 1089 003651 1089 0 %ORDER 1090 003651 1090 ------------------------------------------------------- 1091 003651 1091 1 %BELL These commands (if used) 1092 003651 1092 1 %COPYRIGHT must precede all those > 1. 1093 003651 1093 1 %DISK (also %DSK or %DSIC) 1094 003651 1094 1 %KEEP 1095 003651 1095 1 %LANGUAGE 1096 003651 1096 1 %LOCK 1097 003651 1097 1 %NAME 1098 003651 1098 1 %NEXTLESSON 1099 003651 1099 1 %NOCONTROLC 1100 003651 1100 1 %SGNOSIS 1101 003651 1101 1 %SWITCH 1102 003651 1102 1 %TEACHER 1103 003651 1103 ------------------------------------------------------- 1104 003651 1104 2 %VARIABLES This command (if used) 1105 003651 1105 must precede all those > 2. 1106 003651 1106 ------------------------------------------------------- 1107 003651 1107 3 %HELP These commands (if used) 1108 003651 1108 3 %PROCEDURE must precede all those > 3. 1109 003651 1109 ------------------------------------------------------- 1110 003651 1110 4 %INITIALIZE This command (if used) 1111 003651 1111 must precede all those > 4. 1112 003651 1112 ------------------------------------------------------- 1113 003651 1113 5 %LACK These commands (if used) 1114 003651 1114 5 %NEUTRAL must precede all those > 5. 1115 003651 1115 5 %QEND 1116 003651 1116 5 %QUESTION After %QUESTION, %RIGHTs 1117 003651 1117 5 %RIGHT precede %WRONGs (or %LACKs). 1118 003651 1118 5 %SAME %NEUTRALs can go anywhere.. 1119 003651 1119 5 %TEXT Empty patterns of each type 1120 003651 1120 5 %WRONG should appear last. 1121 003651 1121 ------------------------------------------------------- 1122 003651 1122 6 %FINISH This command (if used) must 1123 003651 1123 precede only the %END. 1124 003651 1124 ------------------------------------------------------- 1125 003651 1125 7 %END This command must be last. 1126 003651 1126 ======================================================= 1127 003651 1127 1128 003651 1128 Note: GNOSIS will accept some contextually awkward 1129 003651 1129 orderings of the answer pattern commands. For example, 1130 003651 1130 GNOSIS will accept %NEUTRAL at any point after %QUESTION 1131 003651 1131 even though, in the context of the lesson, that occurrence 1132 003651 1132 of %NEUTRAL may have unintended effects. 1133 003651 1133 -----------------------------------------------------------; 1134 003652 B71 1134 BEGIN 1135 003653 1135 BOOLEAN legalcommand; 1136 003655 1136 STRING ARRAY command [1:16]; 1137 003662 1137 INTEGER i; 1138 003662 1138 command[1]:= "LAN"; 1139 003673 1139 command[2]:= "TEA"; 1140 003704 1140 command[3]:= "COP"; 1141 003715 1141 command[4]:= "NOC"; 1142 003726 1142 command[5]:= "NEX"; 1143 003737 1143 command[6]:= "SGN"; 1144 003750 1144 command[7]:= "SWI"; 1145 003761 1145 command[8]:= "KEE"; 1146 003772 1146 command[9]:= "LOC"; 1147 004003 1147 command[10]:= "BEL"; 1148 004014 1148 command[11]:= "NAM"; 1149 004025 1149 command[12]:= "DIS"; 1150 004036 1150 command[13]:= "DSK"; 1151 004047 1151 command[14]:= "VAR"; 1152 004060 1152 command[15]:= "HEL"; 1153 004071 1153 command[16]:= "PRO"; 1154 004102 1154 WHILE NOT legalcommand DO 1155 004104 B72 1155 BEGIN 1156 004106 1156 FOR i:= 1 STEP 1 UNTIL n DO 1157 004117 B73 1157 BEGIN 1158 004117 1158 IF controlstart = command[i] THEN 1159 004127 B74 1159 BEGIN 1160 004127 1160 errmess(FALSE, 1161 004127 1161 "1161: Command is out of place here. As a result,[N]****** this line up to next command line will be ignored."); 1162 004133 1162 getline; 1163 004143 1163 WHILE answer.[1] # controlchar DO getline; 1164 004146 1164 getcontrolstart(4); 1165 004151 1165 GOTO earlyexit 1166 004151 E74 1166 END 1167 004156 1167 ELSE IF i = n THEN legalcommand:= TRUE; 1168 004157 E73 1168 END; 1169 004157 1169 earlyexit: 1170 004171 E72 1170 END 1171 004172 E71 1171 END PR*CEDURE checkprecedence; 1172 004172 1172 1173 004172 1173 1174 004172 1174 1175 004174 1175 PROCEDURE putvariables; 1176 004174 1176 COMMENT ------------------------------------------------- 1177 004174 1177 The translated GNOSIS lesson is prefaced by (1) a preamble 1178 004174 1178 of global variable declarations (output by "putvariables"), 1179 004174 1179 (2) a set of global PROCEDURE declarations (output by 1180 004174 1180 "putprocedures"), (3) a set of statements to initialize the 1181 004174 1181 value of global variables (output by "putvalues"), and (4) a 1182 004174 1182 lesson header (output by putheader) which does some 1183 004174 1183 additional initialization of I/O. 1184 004174 1184 -----------------------------------------------------------; 1185 004205 B75 1185 BEGIN 1186 004205 1186 Write("BEGIN"); 1187 004210 1187 Write(" COMMENT: This is the lesson """); 1188 004213 1188 Write(lessonname); 1189 004216 1189 Write(""";;[N]"); 1190 004221 1190 IF put AND teacher # "" THEN 1191 004231 B76 1191 BEGIN 1192 004231 1192 Write("COMMENT: This lesson was written by[N]"); 1193 004234 1193 alglin(teacher); 1194 004237 1194 Write(";;"); 1195 004237 1195 Newline 1196 004244 E76 1196 END; 1197 004244 1197 COMMENT ------------------------------------------------- 1198 004244 1198 Output of data declarations follows. 1199 004244 1199 -----------------------------------------------------------; 1200 004244 1200 Write("BOOLEAN firsttry, ihaveblanked, nopause, skip, back, stop, message;;[N]"); 1201 004247 1201 Write("INTEGER lasterrors, score, latescore, qcount, lastqcount, lastqkount, carriagereturn, linefeed, pos, blank;;[N]"); 1202 004252 1202 Write("INTEGER lastscorecount, lastlatescorecount, lastscorekount, lastlatescorekount;;[N]"); 1203 004255 1203 IF language = 2 THEN 1204 004260 B77 1204 BEGIN 1205 004260 1205 Write("INTEGER lcaa, lcae, lcoe, ucaa, ucae, ucoe;;[N]") 1206 004263 E77 1206 END; 1207 004263 1207 Write("INTEGER randno, answerlength, controlstart, controlg, uparrow;;[N]"); 1208 004266 1208 Write("INTEGER lastrights;;[N]"); 1209 004271 1209 Write("STRING answer, answercopy, char, endofline, lessonname, firstname, tempfile1, tempfile2, prompt;;[N]"); 1210 004274 1210 Write("STRING ARRAY right, rightatlast, wrong[[0:9]];;[2N]"); 1211 004277 E75 1211 END of PR*CEDURE putvariables; 1212 004277 1212 1213 004277 1213 1214 004300 1214 PROCEDURE putprocedures; 1215 004300 1215 COMMENT ------------------------------------------------- 1216 004300 1216 'Putprocedures' is the second in a series of four procedures 1217 004300 1217 to output the lesson preface 1218 004300 1218 -----------------------------------------------------------; 1219 004311 B78 1219 BEGIN 1220 004313 1220 IF nocontrolc THEN Write("EXTERNAL PROCEDURE stopkc;;[2N]"); 1221 004320 1221 IF transferlesson THEN Write("EXTERNAL PROCEDURE pub, nolpt, run, r;;[2N]"); 1222 004320 1222 1223 004325 1223 IF put THEN Write("FORWARD PROCEDURE putaway;;[N]"); 1224 004325 1224 1225 004330 1225 Write("FORWARD BOOLEAN PROCEDURE anywhere;;[2N]"); 1226 004330 1226 1227 004333 1227 Write("PROCEDURE getline;;[N]"); 1228 004336 1228 Write("COMMENT: 'Getline' reads in a line of text input by the student,[N]"); 1229 004341 1229 Write("dumping it in the STRING 'answer'. Column one of the line is checked[N]"); 1230 004344 1230 Write("to see if the student typed '%', indicating that he wanted[N]"); 1231 004347 1231 Write("to interrupt the flow of the lesson;;[N]"); 1232 004352 1232 Write("BEGIN[N]INTEGER s, t, i;;[N]BOOLEAN quit;;[N]"); 1233 004355 1233 Write("Breakoutput;;[N]quit:= FALSE;;[N]"); 1234 004360 1234 Write("[N]again:[N]FOR i:= 1 STEP 1 UNTIL 132 DO[N]"); 1235 004363 1235 Write("BEGIN[N]Insymbol(t);;[N]"); 1236 004366 1236 Write("COMMENT: Lower case transform;;[N]"); 1237 004371 1237 Write("IF t >= 97 AND t <= 122 THEN t:= t-32"); 1238 004377 1238 IF language = 1 THEN Write(";;[N]") 1239 004403 1239 ELSE IF language = 2 THEN 1240 004406 B79 1240 BEGIN 1241 004406 1241 Write(" ELSE[N]"); 1242 004411 1242 Write("IF t = lcaa THEN t:= ucaa ELSE[N]"); 1243 004414 1243 Write("IF t = lcae THEN t:= ucae ELSE[N]"); 1244 004417 1244 Write("IF t = lcoe THEN t:= ucoe;;[N]") 1245 004422 E79 1245 END; 1246 004422 1246 Write("answer.[[i]]:= t;;[N]"); 1247 004425 1247 Write("IF t = carriagereturn THEN GOTO out;;[N]"); 1248 004430 1248 Write("END;;[N]"); 1249 004433 1249 Write("GOTO again;;[N]"); 1250 004436 1250 Write("[N]out:[N]Insymbol(t);;[N]i:= i+1;;[N]answer.[[i]]:= t;;[N]pos:= 1;;[N]answerlength:= i-2;;[N]"); 1251 004441 1251 Write("IF answerlength < 0 THEN answerlength:= 0;;[N]"); 1252 004444 1252 Write("Delete(answercopy);;[N]answercopy:= Copy(answer,1,i);;[N]"); 1253 004447 1253 Write("ihaveblanked:= FALSE;;[N]"); 1254 004452 1254 Write("IF answerlength = 1 THEN[N]"); 1255 004455 1255 Write("BEGIN[N]IF answer.[[1]] = controlstart THEN[N]"); 1256 004460 1256 IF language = 1 THEN 1257 004463 B80 1257 BEGIN 1258 004463 1258 Write("BEGIN[N]Write(""Answer 'STOP'"");;[N]"); 1259 004470 1259 IF NOT lock THEN Write("Write("", 'SKIP', 'BACK', "");;[N]"); 1260 004473 1260 Write("Write(""or 'CONTINUE'.[[N]]"");;[N]") 1261 004473 E80 1261 END 1262 004477 1262 ELSE IF language = 2 THEN 1263 004502 B81 1263 BEGIN 1264 004502 1264 Write("BEGIN[N]Write(""Svara """"STOPP"""" om Du vill l{mna lektionen,[[N]]"");;[N]"); 1265 004507 1265 IF NOT lock THEN Write("Write(""""""SKIPPA"""" om Du vill skippa denna fr}ga,[[N]]"");;[N]"); 1266 004514 1266 IF NOT lock THEN Write("Write(""""""BACKA"""" om Du vill g} tillbaka till en tidigare del av lektionen,[[N]]"");;[N]"); 1267 004517 1267 Write("Write(""""""FORTS#TT"""" om Du vill forts{tta.[[N]]"");;[N]") 1268 004522 E81 1268 END; 1269 004524 1269 IF bell THEN Write("Outsymbol(controlg);;[N]"); 1270 004527 1270 Write("Write(prompt);;[N]Breakoutput;;[N]"); 1271 004532 1271 Write("quit:= TRUE;;[N]GOTO again;;[N]"); 1272 004535 1272 Write("END;;[N]END;;[N]"); 1273 004540 1273 Write("IF quit THEN[N]"); 1274 004543 1274 Write("BEGIN[N]quit:= FALSE;;[N]IF anywhere("""); 1275 004551 1275 IF language = 1 THEN Write("STOP") 1276 004560 1276 ELSE IF language = 2 THEN Write("STOPP"); 1277 004563 1277 Write(""") THEN[N]BEGIN[N]"); 1278 004566 1278 Write("stop:= TRUE;;[N]"); 1279 004574 1279 IF language = 1 THEN Write("Write(""Lesson aborted."");;[N]") ELSE 1280 004603 1280 IF language = 2 THEN Write("Write(""Lektionen avbr`t.[[N]]"");;[N]"); 1281 004606 1281 Write("GOTO exit;;[N]END;;[N]"); 1282 004611 1282 Write("pos:= 1;;[N]IF anywhere("""); 1283 004617 1283 IF language = 1 THEN Write("SKIP") 1284 004626 1284 ELSE IF language = 2 THEN Write("SKIPPA"); 1285 004631 1285 Write(""") THEN[N]"); 1286 004634 1286 Write("BEGIN[N]Write("""); 1287 004637 1287 IF NOT lock THEN 1288 004641 B82 1288 BEGIN 1289 004644 1289 IF language = 1 THEN Write("Question skipped.") 1290 004653 1290 ELSE IF language = 2 THEN Write("Fr}gan skippad."); 1291 004656 1291 Write("[[N]]"");;[N]skip:= TRUE;;[N]") 1292 004656 E82 1292 END 1293 004661 1293 ELSE 1294 004662 B83 1294 BEGIN 1295 004665 1295 IF language = 1 THEN Write("??? Skipping not allowed in this lesson.") 1296 004674 1296 ELSE IF language = 2 THEN Write("???"); 1297 004677 1297 Write("[[N]]"");;[N]") 1298 004702 E83 1298 END; 1299 004702 1299 Write("END[N]ELSE[N]BEGIN[N]"); 1300 004705 1300 Write("pos:= 1;;[N]IF anywhere("""); 1301 004713 1301 IF language = 1 THEN Write("BACK") 1302 004722 1302 ELSE IF language = 2 THEN Write("BACKA"); 1303 004725 1303 Write(""") THEN[N]"); 1304 004730 1304 Write("BEGIN[N]Write("""); 1305 004733 1305 IF NOT lock THEN 1306 004735 B84 1306 BEGIN 1307 004740 1307 IF language = 1 THEN Write("Lesson is backing.") 1308 004747 1308 ELSE IF language = 2 THEN Write("Lektionen g}r tillbaka."); 1309 004752 1309 Write("[[N]]"");;[N]back:= TRUE;;[N]") 1310 004752 E84 1310 END 1311 004755 1311 ELSE 1312 004756 B85 1312 BEGIN 1313 004761 1313 IF language = 1 THEN Write("??? Backing not allowed in this lesson.") 1314 004770 1314 ELSE IF language = 2 THEN Write("???"); 1315 004773 1315 Write("[[N]]"");;[N]") 1316 004776 E85 1316 END; 1317 004776 1317 Write("END[N]ELSE[N]BEGIN[N]"); 1318 005001 1318 IF language = 1 THEN 1319 005004 B86 1319 BEGIN 1320 005004 1320 Write("Write(""Please continue, then, giving your response[[N]]"");;[N]"); 1321 005007 1321 Write("Write(""to the PREVIOUS '-->' or 'RETURN' prompt...[[N]]"");;[N]") 1322 005007 E86 1322 END 1323 005013 1323 ELSE IF language = 2 THEN 1324 005016 1324 Write("Write(""Du vill inte avbryta nu. Forts{tt d} med ditt ordinarie svar.[[N]]"");;[N]"); 1325 005021 1325 Write("GOTO again;;[N]"); 1326 005024 1326 Write("END;;[N]END;;[N]"); 1327 005027 1327 Write("END;;[2N]exit:[N]END;;[2N]"); 1328 005027 1328 1329 005032 1329 Write("BOOLEAN PROCEDURE here(comp);;[N]VALUE comp;;[N]STRING comp;;[N]"); 1330 005035 1330 Write("COMMENT: 'Here' determines whether the argument string can be found[N]"); 1331 005040 1331 Write("beginning at 'pos' in the student answer. Blanks, but nothing[N]"); 1332 005043 1332 Write("else, may precede the matching word. 'Here' is mostly used[N]"); 1333 005046 1333 Write("for answers matched in the %NOEXTRA mode;;[N]"); 1334 005051 1334 Write("BEGIN[N]INTEGER cpos;;[N]"); 1335 005054 1335 Write("[N]blankline:[N]IF answercopy.[[pos]] = blank THEN[N]"); 1336 005057 1336 Write("BEGIN[N]pos:= pos+1;;[N]GOTO blankline;;[N]"); 1337 005062 1337 Write("END;;[N]"); 1338 005065 1338 Write("FOR cpos:= 1 STEP 1 UNTIL Length(comp) DO[N]"); 1339 005070 1339 Write("BEGIN[N]"); 1340 005073 1340 Write("IF answercopy.[[pos]] # comp.[[cpos]] THEN GOTO nofit;;[N]"); 1341 005076 1341 Write("pos:= pos+1;;[N]"); 1342 005101 1342 Write("END;;[N]"); 1343 005104 1343 Write("here:= TRUE;;[N]GOTO out;;[N]"); 1344 005107 1344 Write("[N]nofit:[N]here:= FALSE;;[N]"); 1345 005112 1345 Write("[N]out:[N]END;;[2N]"); 1346 005112 1346 1347 005115 1347 Write("BOOLEAN PROCEDURE anywhere(comp);;[N]VALUE comp;;[N]STRING comp;;[N]"); 1348 005120 1348 Write("COMMENT: 'Anywhere' determines whether the argument string can be [N]"); 1349 005123 1349 Write("found anywhere in the student answer after 'pos'. Blanks and[N]"); 1350 005126 1350 Write("unmatched strings will be bypassed. 'Anywhere' is used in[N]"); 1351 005131 1351 Write("the %EXTRA mode and in the %NOEXTRA %NOORDER mode.[N]"); 1352 005134 1352 Write("'Anywhere' will substitute blanks for all characters in[N]"); 1353 005137 1353 Write("the matched strings. This allows the program (e.g., in the[N]"); 1354 005142 1354 Write("%NOEXTRA mode) to determine whether there are[N]"); 1355 005145 1355 Write("any non-blank characters in the student answer. In the[N]"); 1356 005150 1356 Write("%NOEXTRA mode, his answer will be wrong if any non-blank characters remain;;[N]"); 1357 005153 1357 Write("BEGIN[N]INTEGER cpos, nextpos;;[N]"); 1358 005156 1358 Write("[N]blankline:[N]IF answercopy.[[pos]] = blank THEN[N]"); 1359 005161 1359 Write("BEGIN[N]pos:= pos+1;;[N]GOTO blankline;;[N]"); 1360 005164 1360 Write("END;;[N]"); 1361 005167 1361 Write("nextpos:= pos+1;;[N]"); 1362 005172 1362 Write("FOR cpos:= 1 STEP 1 UNTIL Length(comp) DO[N]"); 1363 005175 1363 Write("BEGIN[N]"); 1364 005200 1364 Write("IF answercopy.[[pos]] # comp.[[cpos]] THEN GOTO nofit;;[N]"); 1365 005203 1365 Write("pos:= pos+1;;[N]"); 1366 005206 1366 Write("END;;[N]"); 1367 005211 1367 Write("FOR cpos:= pos-Length(comp) STEP 1 UNTIL pos-1 DO[N]"); 1368 005214 1368 Write("BEGIN[N]answercopy.[[cpos]]:= blank;;[N]"); 1369 005217 1369 Write("END;;[N]"); 1370 005222 1370 Write("anywhere:= ihaveblanked:= TRUE;;[N]GOTO out;;[N]"); 1371 005225 1371 Write("[N]nofit:[N]IF answercopy.[[pos]] # carriagereturn THEN[N]"); 1372 005230 1372 Write("BEGIN[N]pos:= nextpos;;[N]GOTO blankline;;[N]"); 1373 005233 1373 Write("END;;[N]"); 1374 005236 1374 Write("anywhere:= FALSE;;[N]"); 1375 005241 1375 Write("[N]out:[N]END;;[2N]"); 1376 005241 1376 1377 005244 1377 Write("PROCEDURE restore;;[N]"); 1378 005247 1378 Write("COMMENT: Since 'anywhere' substitutes blanks for matched parts of the student[N]"); 1379 005252 1379 Write("answer, the original response must be restored before comparing[N]"); 1380 005255 1380 Write("it to other target patterns. This restoration is done here;;[N]"); 1381 005260 1381 Write("BEGIN[N]ihaveblanked:= FALSE;;[N]"); 1382 005263 1382 Write("Delete(answercopy);;[N]answercopy:= Copy(answer,1,answerlength+2);;[N]"); 1383 005266 1383 Write("END;;[2N]"); 1384 005271 1384 Write("INTEGER PROCEDURE random;;[N]"); 1385 005274 1385 Write("COMMENT: 'Random' is a number generator which gives a random[N]"); 1386 005277 1386 Write("number between 0 and 9. The generator will not repeat[N]"); 1387 005302 1387 Write("itself until after 862 generations;;[N]"); 1388 005305 1388 Write("BEGIN[N]"); 1389 005310 1389 Write("randno:= randno*10 rem 863;;[N]"); 1390 005313 1390 Write("random:= randno div 87;;[N]"); 1391 005316 1391 Write("END;;[2N]"); 1392 005316 1392 1393 005321 1393 Write("PROCEDURE personalize(message);;[N]VALUE message;;[N]STRING message;;[N]"); 1394 005324 1394 Write("COMMENT: 'Personalize' uses the student's firstname in conversational[N]"); 1395 005327 1395 Write("I/O to give a personal touch to the lessons. To avoid monotony[N]"); 1396 005332 1396 Write("and to further efficiency, the probability that the message will be[N]"); 1397 005335 1397 Write("personalized is only .2;;[N]"); 1398 005340 1398 Write("BEGIN[N]IF firstname = """" OR random < 8 THEN Write(message)[N]"); 1399 005343 1399 Write("ELSE BEGIN[N]INTEGER i, j;;[N]i:= 1;;[N]j:= Length(message);;[N]"); 1400 005346 1400 Write("WHILE i < j DO[N]BEGIN[N]Outsymbol(message.[[i]]);;i:= i + 1;;[N]END;;[N]"); 1401 005351 1401 Write("Write("", "");;[N]Write(firstname);;[N]Outsymbol(message.[[j]]);;[N]"); 1402 005354 1402 Write("END;;[N]END;;[2N]"); 1403 005354 1403 1404 005354 1404 1405 005357 1405 Write("PROCEDURE rightmessage;;[N]"); 1406 005362 1406 Write("COMMENT: 'Rightmessage' is called when a student has[N]"); 1407 005365 1407 Write("made a correct answer. He is told about this, and the[N]"); 1408 005370 1408 Write("score is updated. The message to the student is different[N]"); 1409 005373 1409 Write("depending on whether he succeeds on the fist try or[N]"); 1410 005376 1410 Write("only after previous fruitless attempts. Random numbers are[N]"); 1411 005401 1411 Write("used to choose between ten different messages to give[N]"); 1412 005404 1412 Write("some variation to the conversation;;[N]"); 1413 005407 1413 Write("BEGIN[N]"); 1414 005412 1414 Write("lastrights:= lastrights+1;;[N]"); 1415 005415 1415 Write("IF firsttry THEN[N]"); 1416 005420 1416 Write("BEGIN[N]score:= score+1;;[N]qcount:= qcount+1;;[N]firsttry:= FALSE;;[N]"); 1417 005423 1417 Write("personalize(right[[random]]);;[N]"); 1418 005426 1418 Write( 1419 005426 1419 "END[N]ELSE[N]BEGIN[N]personalize(right[[random]]);;[N]IF lasterrors > 1 THEN Write(rightatlast[[random]]);;[N]END;;[N]"); 1420 005431 1420 IF language = 1 THEN 1421 005434 B87 1421 BEGIN 1422 005434 1422 Write("IF lasterrors > 3 THEN[N]BEGIN[N]"); 1423 005437 1423 Write("personalize(""[[N]]I must admit that last one was a bit tricky!"");;[N]"); 1424 005442 1424 Write("Newline;;[N]END;;[N]"); 1425 005445 E87 1425 END; 1426 005445 1426 Write("latescore:= latescore+1;;[N]Newline;;[N]"); 1427 005450 1427 Write("END;;[2N]"); 1428 005450 1428 1429 005453 1429 Write("PROCEDURE wrongmessage;;[N]"); 1430 005456 1430 Write("COMMENT: 'Wrongmessage' is called when a student[N]"); 1431 005461 1431 Write("has made an erroneous answer. He is told about this,[N]"); 1432 005464 1432 Write("and the lesson statistics are updated. Random numbers[N]"); 1433 005467 1433 Write("are used to choose between ten different messages in order[N]"); 1434 005472 1434 Write("provide some variation in the conversation;;[N]"); 1435 005475 1435 Write("BEGIN[N]"); 1436 005500 1436 Write("lasterrors:= lasterrors+1;;[N]"); 1437 005503 1437 Write("IF firsttry THEN[N]"); 1438 005506 1438 Write("BEGIN[N]qcount:= qcount+1;;[N]firsttry:= FALSE;;[N]"); 1439 005511 1439 Write("END;;[N]"); 1440 005514 1440 Write("personalize(wrong[[random]]);;[N]Newline;;[N]"); 1441 005517 1441 Write("END;;[2N]"); 1442 005517 1442 1443 005517 1443 1444 005522 1444 Write("PROCEDURE pause;;[N]"); 1445 005525 1445 Write("COMMENT: Lesson text is given to the student in small portions.[N]"); 1446 005530 1446 Write("One reason for this is that it is easier to read a little[N]"); 1447 005533 1447 Write("at a time. Another reason is that display terminals have[N]"); 1448 005536 1448 Write("a limited screen size. The 'pause' PROCEDURE produces a pause[N]"); 1449 005541 1449 Write("in the display of text to the student, and she can continue[N]"); 1450 005544 1450 Write("whenever she has finished examining the displayed material.[N]"); 1451 005547 1451 Write("To go on, she simply pushes the 'RETURN' key. Normally, this[N]"); 1452 005552 1452 Write("PROCEDURE is called between each %TEXT or %QUESTION,[N]"); 1453 005555 1453 Write("but GNOSIS will introduce ADDITIONAL automatic pause points[N]"); 1454 005560 1454 Write("within large blocks of text or question material.[N]"); 1455 005563 1455 Write("The teacher can inhibit pauses BETWEEN '%' commands by 'nopause:= TRUE', but[N]"); 1456 005566 1456 Write("the pauses which GNOSIS inserts in long text blocks cannot be inhibited;;[N]"); 1457 005571 1457 Write("IF nopause THEN nopause:= FALSE ELSE[N]"); 1458 005574 1458 Write("BEGIN[2N][N]"); 1459 005602 1459 IF language = 1 THEN Write("Write(""[[N]]Push RETURN "");;[N]") ELSE 1460 005611 1460 IF language = 2 THEN Write("Write(""[[N]]Tryck RETURN "");;[N]"); 1461 005614 1461 Write("write(prompt);;[N]"); 1462 005621 1462 IF bell THEN Write("Outsymbol(controlg);;[N]"); 1463 005624 1463 Write("getline;;[N]Newline;;[N]"); 1464 005627 1464 Write("IF stop THEN[N]BEGIN[N]stop:= FALSE;;[N]GOTO endoflesson[N]END;;[N]"); 1465 005632 1465 Write("IF answerlength > 0 THEN[N]"); 1466 005635 1466 Write("BEGIN[N]pos:= 1;;[N]"); 1467 005640 1467 Write("IF NOT here(endofline) THEN[N]BEGIN[N]"); 1468 005646 1468 IF language = 1 THEN textline("Eh? The computer expected you would just push the RETURN button.") ELSE 1469 005655 1469 IF language = 2 THEN textline("??? Datorn v{ntade sig bara RETURN fr}n Dig."); 1470 005660 1470 Write("END;;[N]END;;[N]"); 1471 005663 1471 Write("END;;[2N]"); 1472 005663 1472 1473 005666 1473 Write("PROCEDURE page;;[N]"); 1474 005671 1474 Write("COMMENT: 'Page' can be called by the teacher when he[N]"); 1475 005674 1475 Write("wants to blank the screen on a display terminal).[N]"); 1476 005677 1476 Write("The effect produced is, of course, terminal dependent;;[N]"); 1477 005702 1477 Write("BEGIN[N]pause;;[N]Outsymbol(12);;[N]Outsymbol(12);;[N]Newline;;[N]"); 1478 005705 1478 Write("END;;[2N]"); 1479 005705 1479 1480 005710 1480 Write("PROCEDURE extratest;;[N]"); 1481 005713 1481 Write("COMMENT: 'Extratest' will flag and display those parts of the student answer [N]"); 1482 005716 1482 Write("which WERE matched by the teacher answer pattern IF the[N]"); 1483 005721 1483 Write("student response contained extra (i.e., superfluous) characters[N]"); 1484 005724 1484 Write("'Extratest' is called automatically for %RIGHT answers in the[N]"); 1485 005727 1485 Write("%EXTRA mode. Recall that 'here' scans past leading blanks;;[N]"); 1486 005732 1486 Write("BEGIN[N]"); 1487 005735 1487 Write("pos:= 1;;[N]IF NOT here(endofline) THEN[N]"); 1488 005740 1488 Write("BEGIN[N]Newline;;[N]"); 1489 005743 1489 Write("FOR pos:= 1 STEP 1 UNTIL answerlength + 2 DO Outsymbol(answer.[[pos]]);;[N]"); 1490 005746 1490 Write("FOR pos:= 1 STEP 1 UNTIL answerlength DO[N]"); 1491 005751 1491 Write("IF answercopy.[[pos]] = blank AND answer.[[pos]] # blank THEN Outsymbol(uparrow) ELSE Outsymbol(blank);;[N]"); 1492 005754 1492 Write("Newline;;[N]Newline;;[N]"); 1493 005757 1493 Write("END;;[N]"); 1494 005762 1494 Write("END;;[2N]"); 1495 005762 1495 1496 005765 1496 Write("REAL PROCEDURE percent;;[N]"); 1497 005770 1497 Write("COMMENT: 'Percent' returns the percentage of questions answered correctly[N]"); 1498 005773 1498 Write("by the student on his very first try since the start of the lesson;;[N]"); 1499 005776 1499 Write("percent:= IF qcount = 0 or score = 0 THEN 0.0 ELSE 100.0 * score/qcount;;[2N]"); 1500 005776 1500 1501 006001 1501 Write("REAL PROCEDURE latepercent;;[N]"); 1502 006004 1502 Write("COMMENT: 'Latepercent' returns the percentage of questions answered correctly[N]"); 1503 006007 1503 Write("by the student since the start of the lesson whether[N]"); 1504 006012 1504 Write("student was correct on the first try or afterward;;[N]"); 1505 006015 1505 Write("latepercent:= IF qcount = 0 or latescore = 0 THEN 0.0 ELSE 100.0 * latescore/qcount;;[2N]"); 1506 006015 1506 1507 006020 1507 Write("INTEGER PROCEDURE lastscore;;[N]"); 1508 006023 1508 Write("COMMENT: 'Lastscore' returns number of questions answered correctly on the[N]"); 1509 006026 1509 Write("very first try since this PROCEDURE was last called;;[N]"); 1510 006031 1510 Write("BEGIN[N]lastscore:= score - lastscorecount;;[N]lastscorecount:= score[N]END;;[2N]"); 1511 006031 1511 1512 006034 1512 Write("INTEGER PROCEDURE lastlatescore;;[N]"); 1513 006037 1513 Write("COMMENT: 'Lastlatescore' returns number of questions answered correctly[N]"); 1514 006042 1514 Write("since this PROCEDURE was last called whether student was correct on the[N]"); 1515 006045 1515 Write("very first try or afterward;;[N]"); 1516 006050 1516 Write("BEGIN[N]lastlatescore:= latescore - lastlatescorecount;;[N]lastlatescorecount:= latescore[N]END;;[2N]"); 1517 006050 1517 1518 006053 1518 Write("REAL PROCEDURE lastpercent;;[N]"); 1519 006056 1519 Write("COMMENT: 'Lastpercent' returns the percentage of questions answered correctly[N]"); 1520 006061 1520 Write("on the very first try since this PROCEDURE was last called;;[N]"); 1521 006064 1521 Write("BEGIN[N]INTEGER x;;[N]"); 1522 006067 1522 Write("x:= score - lastscorekount;;[N]lastscorekount:= score;;[N]lastqcount:= qcount - lastqcount;;[N]"); 1523 006072 1523 Write("lastpercent:= IF lastqcount = 0 or x = 0 THEN 0.0 ELSE 100.0 * x/lastqcount;;[N]"); 1524 006075 1524 Write("END;;[2N]"); 1525 006075 1525 1526 006100 1526 Write("REAL PROCEDURE lastlatepercent;;[N]"); 1527 006103 1527 Write("COMMENT: 'Lastlatepercent' returns the percentage of questions answered correctly[N]"); 1528 006106 1528 Write("since this PROCEDURE was last called whether student was correct on the first try[N]"); 1529 006111 1529 Write("or afterward;;[N]"); 1530 006114 1530 Write("BEGIN[N]INTEGER x;;[N]"); 1531 006117 1531 Write("x:= latescore - lastlatescorekount;;[N]lastlatescorekount:= latescore;;[N]lastqkount:= qcount - lastqkount;;[N]"); 1532 006122 1532 Write("lastlatepercent:= IF lastqkount = 0 or x = 0 THEN 0.0 ELSE 100.0 * x/lastqkount;;[N]"); 1533 006125 1533 Write("END;;[2n]"); 1534 006130 1534 IF put THEN 1535 006132 B88 1535 BEGIN 1536 006132 1536 1537 006132 1537 Write("PROCEDURE putaway(question);;[N]"); 1538 006135 1538 Write("COMMENT: If the lesson contained a report-generating command,[N]"); 1539 006140 1539 Write("then unexpected student answers are written into a pair of reports,[N]"); 1540 006143 1540 Write(".DTA and .SRT, which the teacher can use to improve the[N]"); 1541 006146 1541 Write("lesson. 'Putaway' writes the unexpected answers in these files;;[N]"); 1542 006151 1542 Write("VALUE question;;[N]STRING question;;[N]"); 1543 006154 1543 Write("BEGIN[N]INTEGER i;;[N]"); 1544 006157 1544 Write("Breakoutput;;[N]"); 1545 006162 1545 Write("Selectoutput(2);;[N]"); 1546 006165 1546 Write("Write(question);;[N]Write("": "");;[N]"); 1547 006170 1547 Write("FOR i:= 1 STEP 1 UNTIL answerlength DO Outsymbol(answer.[[i]]);;[N]"); 1548 006173 1548 Write("Newline;;[N]"); 1549 006176 1549 Write("Breakoutput;;[N]"); 1550 006201 1550 Write("Selectoutput(3);;[N]"); 1551 006204 1551 Write("Write(question);;[N]Write("": "");;[N]"); 1552 006207 1552 Write("FOR i:= 1 STEP 1 UNTIL answerlength DO Outsymbol(answer.[[i]]);;[N]"); 1553 006212 1553 Write("Newline;;[N]"); 1554 006215 1554 Write("Breakoutput;;[N]"); 1555 006220 1555 Write("Selectoutput(0);;[N]"); 1556 006223 1556 Write("END;;[2N]"); 1557 006226 1557 IF teacher # "" THEN 1558 006233 B89 1558 BEGIN 1559 006233 1559 1560 006233 1560 Write("PROCEDURE putmessage;;[N]"); 1561 006236 1561 Write("COMMENT: If no disk files are being generated for teacher reports,[N]"); 1562 006241 1562 Write("'Putmessage' will tell the student to send hardcopy reports [N]"); 1563 006244 1563 Write("to the teacher -- unless no teacher's name and address[N]"); 1564 006247 1564 Write("was supplied with %TEACHER command);;[N]"); 1565 006252 1565 Write("BEGIN[N]"); 1566 006255 1566 IF language = 1 THEN 1567 006260 B90 1567 BEGIN 1568 006260 1568 textline("He needs the listing to improve the lesson."); 1569 006265 1569 IF NOT name THEN textline("You can send it anonymously - the teacher will"); 1570 006272 1570 IF NOT name THEN textline("not know which student sent it to him."); 1571 006275 1571 Write("Newline;;[N]"); 1572 006300 1572 textline("The name and address of the teacher is:") 1573 006300 E90 1573 END 1574 006304 1574 ELSE IF language = 2 THEN 1575 006307 B91 1575 BEGIN 1576 006307 1576 textline("Han beh`ver den f`r att kunna g`ra lektionen b{ttre."); 1577 006314 1577 IF NOT name THEN textline("Du kan s{nda den anonymt - l{raren beh`ver inte veta"); 1578 006321 1578 IF NOT name THEN textline("vilken elev som s{nde den till honom."); 1579 006324 1579 Write("Newline;;[N]"); 1580 006327 1580 textline("L{rarens namn och adress {r:") 1581 006332 E91 1581 END; 1582 006332 1582 textline(teacher); 1583 006335 1583 Write("Newline;;[N]END;;[2N]") 1584 006335 E89 1584 END 1585 006340 E88 1585 END; 1586 006340 1586 1587 006340 1587 Write("PROCEDURE noanswer;;[N]"); 1588 006343 1588 Write("BEGIN[N]"); 1589 006346 1589 IF language = 1 THEN 1590 006351 B92 1590 BEGIN 1591 006351 1591 Write("personalize(""??? You gave no answer at all."");;[N]Newline;;[N]"); 1592 006354 1592 Write("Write(""If you want to interrupt the lesson, then type the single character """"") 1593 006354 E92 1593 END 1594 006360 1594 ELSE IF language = 2 THEN 1595 006363 B93 1595 BEGIN 1596 006363 1596 Write("personalize(""??? Du gav inget svar alls."");;[N]Newline;;[N]"); 1597 006366 1597 Write("Write(""Om Du vill g} ut ur fr}gan, s} skriv det enda tecknet """"") 1598 006371 E93 1598 END; 1599 006371 1599 Outsymbol(controlchar); 1600 006374 1600 Write(""""".[[N]]"");;[N]"); 1601 006377 1601 Write("end noanswer;;[2N]"); 1602 006377 1602 1603 006402 1603 Write("PROCEDURE tryagain;;[N]"); 1604 006405 1604 Write("COMMENT: Questions output to students who give no answer, a wrong[N]"); 1605 006410 1605 Write("answer, or an incomplete answer are usually repeated by GNOSIS.[N]"); 1606 006413 1606 Write("'Tryagain' will output to such students a 'try again' message[N]"); 1607 006416 1607 Write("which varies according to circumstances. In %NEUTRAL mode,[N]"); 1608 006421 1608 Write("the message will always be 'Please try again'. Otherwise,[N]"); 1609 006424 1609 Write("the content of the message depends on the number of times[N]"); 1610 006427 1610 Write("the student has failed to give a correct response;;[N]"); 1611 006432 1611 IF language = 1 THEN 1612 006435 B94 1612 BEGIN 1613 006435 1613 Write("BEGIN[N]Newline;;[N]"); 1614 006440 1614 Write("personalize(""Please try again."");;[N]"); 1615 006443 1615 Write("IF lasterrors = 3 THEN Write(""[[N]]You have at least eliminated some of the possibilities."") ELSE[N]"); 1616 006446 1616 Write("IF lasterrors = 4 THEN Write(""[[N]](You might want to rethink some of your previous answers.)"") ELSE[N]"); 1617 006451 1617 Write("IF lasterrors > 4 THEN Write(""[[N]]Or...interrupt the lesson by typing the symbol """""); 1618 006454 1618 Outsymbol(controlchar); 1619 006457 1619 Write("""""."");;[N]"); 1620 006462 1620 Write("Newline;;[N]Newline;;[N]"); 1621 006465 1621 Write("END;;[2N]") 1622 006465 E94 1622 END 1623 006471 1623 ELSE IF language = 2 THEN 1624 006474 B95 1624 BEGIN 1625 006474 1625 Write("BEGIN[N]Newline;;[N]"); 1626 006477 1626 Write("personalize(""F`rs`k igen."");;[N]"); 1627 006502 1627 Write("IF lasterrors = 3 THEN Write(""[[N]]Ddu har eliminerat flera m`jligheter redan."") ELSE[N]"); 1628 006505 1628 Write("IF lasterrors > 3 THEN Write(""[[N]]Eller...avbryt lektionen genom att skriva symbolen """""); 1629 006510 1629 Outsymbol(controlchar); 1630 006513 1630 Write("""""."");;[N]"); 1631 006516 1631 Write("[N]Newline;;[N]Newline;;[N]END;;[2N]") 1632 006521 E95 1632 END; 1633 006521 1633 1634 006521 1634 Write("PROCEDURE giveanswer;;[N]"); 1635 006524 1635 Write("COMMENT: 'Giveanswer' displays a right answer to a student who is skipping[N]"); 1636 006527 1636 Write("the question or who repeatedly fails to give a right answer.[N]"); 1637 006532 1637 Write("The answer given will always be the one following the FIRST[N]"); 1638 006535 1638 Write("%RIGHT command for the preceding %QUESTION;;[N]"); 1639 006540 1639 Write("BEGIN[N]"); 1640 006543 1640 IF language = 1 THEN 1641 006546 B96 1641 BEGIN 1642 006546 1642 Write("Newline;;[N]personalize(""Just for the record,"");;[N]"); 1643 006551 1643 Write("Write("" GNOSIS will simulate an acceptable answer:[[2N]]-->"");;[N]"); 1644 006554 E96 1644 END 1645 006555 1645 ELSE IF language = 2 THEN 1646 006560 B97 1646 BEGIN 1647 006560 1647 Write("Newline;;[N]personalize(""F`r den h{ndelse du {r intresserad,"");;[N]"); 1648 006563 1648 Write("Write("" h{r {r ett svar[[N]]"");;[N]"); 1649 006566 1649 Write("Write(""vilket skulle ha varit acceptabelt:[2N]-->"");;[N]") 1650 006571 E97 1650 END; 1651 006571 1651 Write("END;;[N]"); 1652 006574 E78 1652 END of PR*CEDURE putprocedures; 1653 006574 1653 1654 006574 1654 1655 006575 1655 PROCEDURE putvalues; 1656 006575 1656 COMMENT ------------------------------------------------- 1657 006575 1657 'Putvalues' writes code which handles the initialization of 1658 006575 1658 variables before the start of the lesson. This is phase 1659 006575 1659 three of the preface output routines. 1660 006575 1660 -----------------------------------------------------------; 1661 006605 B98 1661 BEGIN 1662 006605 1662 Write( 1663 006605 1663 "[4N]lasterrors:= latescore:= score:= lastqcount:= lastqkount:= qcount:= 0;;[N]carriagereturn:= 13;;[N]linefeed:= 10;;[N]"); 1664 006610 1664 Write("lastrights:= lastscorecount:= lastscorekount:= lastlatescorecount:= lastlatescorekount:= 0;;[N]"); 1665 006613 1665 Write("blank:= "" "".[[1]];;uparrow:= ""^"".[[1]];;[N]controlg:="""".[[1]];;[N]"); 1666 006616 1666 IF language = 2 THEN 1667 006621 B99 1667 BEGIN 1668 006621 1668 Write("ucaa:= ""$"".[[1]];;[N]ucae:= ""#"".[[1]];;[N]ucoe:= ""@"".[[1]];;[N]"); 1669 006624 1669 Write("lcaa:= ""}"".[[1]];;[N]lcae:= ""{"".[[1]];;[N]lcoe:= ""`"".[[1]];;[N]") 1670 006627 E99 1670 END; 1671 006627 1671 Write("answer:= Newstring(135,7);;[N]answercopy:= Copy("" "");;[N]firstname:= """";;[N]prompt:= Copy(""-->"");;[N]"); 1672 006632 1672 Write("answer.[[134]]:= carriagereturn;;[N]answer.[[135]]:= linefeed;;[N]"); 1673 006635 1673 Write("char:= Newstring(1,7);;[N]"); 1674 006640 1674 Write("endofline:= Newstring(1,7);;[N]endofline.[[1]]:= carriagereturn;;[N]"); 1675 006643 1675 Write("randno:= 1;;[N]nopause:= skip:= message:= FALSE;;[N]"); 1676 006646 1676 Write("controlstart:= """); 1677 006651 1677 Outsymbol(controlchar); 1678 006654 1678 Write(""".[[1]];;[N]"); 1679 006657 1679 Write("lessonname:= """); 1680 006662 1680 Write(lessonname); 1681 006665 1681 Write(""";;[N]"); 1682 006670 B100 1682 BEGIN 1683 006670 1683 COMMENT ------------------------------------------------- 1684 006670 1684 Here the 30 STRINGs with different responses to right and 1685 006670 1685 wrong student answers are initialized. A simple PROCEDURE 1686 006670 1686 "m" is used to simplify the repetitive part of this 1687 006670 1687 initialization. 1688 006670 1688 -----------------------------------------------------------; 1689 006671 1689 INTEGER type, index; 1690 006671 1690 STRING arrayname; 1691 006671 1691 1692 006671 1692 1693 006671 1693 1694 006677 1694 PROCEDURE m(message); 1695 006703 1695 STRING message; 1696 006704 B101 1696 BEGIN 1697 006704 1697 IF index = 9 THEN 1698 006710 B102 1698 BEGIN 1699 006710 1699 index:= 0; 1700 006711 1700 type:= type+1; 1701 006717 1701 IF type = 1 THEN arrayname:= "right" ELSE 1702 006733 1702 IF type = 2 THEN arrayname:= "rightatlast" ELSE 1703 006747 1703 IF type = 3 THEN arrayname:= "wrong" 1704 006760 E102 1704 END ELSE index:= index+1; 1705 006763 1705 Write(arrayname); 1706 006766 1706 Write("[["); 1707 006771 1707 Print(index,1); 1708 006775 1708 Write("]]:= """); 1709 007000 1709 Write(message); 1710 007003 1710 Write(""";;[N]") 1711 007006 E101 1711 END of PR*CEDURE m; 1712 007006 1712 1713 007007 1713 type:= 0; 1714 007010 1714 index:= 9; 1715 007012 1715 IF language = 1 THEN 1716 007015 B103 1716 BEGIN 1717 007015 1717 m("Good for you!"); 1718 007020 1718 m("Very good."); 1719 007023 1719 m("Sure!"); 1720 007026 1720 m("Bravo!"); 1721 007031 1721 m("Exactly right!"); 1722 007034 1722 m("Right!"); 1723 007037 1723 m("Well done!"); 1724 007042 1724 m("That's it!"); 1725 007045 1725 m("Excellent!"); 1726 007050 1726 m("OK!"); 1727 007053 1727 m(" You're doing better!"); 1728 007056 1728 m(" Now you're catching on!"); 1729 007061 1729 m(" You're improving!"); 1730 007064 1730 m(" Yo've got the idea now!"); 1731 007067 1731 m(" I knew you could do it."); 1732 007072 1732 m(" There is hope for you after all!"); 1733 007075 1733 m(" You're making progress."); 1734 007100 1734 m(" Aren't you glad you kept trying?"); 1735 007103 1735 m(" Keep up the good work!"); 1736 007106 1736 m(" You've got the hang of it now."); 1737 007111 1737 m("Wrong!"); 1738 007114 1738 m("No!"); 1739 007117 1739 m("You gave the wrong answer."); 1740 007122 1740 m("Your answer was wrong."); 1741 007125 1741 m("Incorrect!"); 1742 007130 1742 m("No, you're wrong this time."); 1743 007133 1743 m("Sorry."); 1744 007136 1744 m("That wasn't correct."); 1745 007141 1745 m("You're mistaken."); 1746 007144 1746 m("No, you missed this one.") 1747 007144 E103 1747 END 1748 007150 1748 ELSE IF language = 2 THEN 1749 007153 B104 1749 BEGIN 1750 007153 1750 m("Bra gjort!"); 1751 007156 1751 m("Mycket bra."); 1752 007161 1752 m("Javisst!"); 1753 007164 1753 m("Utm{rkt!"); 1754 007167 1754 m("Precis r{tt."); 1755 007172 1755 m("R{tt!"); 1756 007175 1756 m("Korrekt."); 1757 007200 1757 m("Du svarade r{tt igen."); 1758 007203 1758 m("Bra!"); 1759 007206 1759 m("OK!"); 1760 007211 1760 m(" Just det - Du klarar dig b{ttre nu."); 1761 007214 1761 m(" Nu b`rjar Du fatta!"); 1762 007217 1762 m(" B{ttre och b{ttre!"); 1763 007222 1763 m(" Nu har Du fattat det hela!"); 1764 007225 1764 m(" Javisst! Nu klarar Du det h{r."); 1765 007230 1765 m(" S}ja, till slut g}r det bra!"); 1766 007233 1766 m(" Du g`r framsteg."); 1767 007236 1767 m(" #ntligen r{tt!"); 1768 007241 1768 m(" Bra! Forts{tt p} det s{ttet."); 1769 007244 1769 m(" Just det. Bara man anstr{nger sig lite s} g}r det bra."); 1770 007247 1770 m("Fel!"); 1771 007252 1771 m("Nej!"); 1772 007255 1772 m("Du valde fel svar."); 1773 007260 1773 m("Ditt svar var felaktigt."); 1774 007263 1774 m("Det {r inte r{tt!"); 1775 007266 1775 m("Nej, den h{r g}ngen svarade Du fel."); 1776 007271 1776 m("Tyv{rr inte r{tt."); 1777 007274 1777 m("Det d{r {r inte riktigt."); 1778 007277 1778 m("Nej, inte riktigt s}."); 1779 007302 1779 m("Nej, den fr}gan missade Du.") 1780 007305 E104 1780 END; 1781 007305 1781 Newline 1782 007307 E100 1782 END; 1783 007310 E98 1783 END of PR*CEDURE putvalues; 1784 007310 1784 1785 007310 1785 1786 007311 1786 PROCEDURE putheader; 1787 007311 1787 COMMENT ------------------------------------------------- 1788 007311 1788 'Putheader' is the last of four procedures used to output 1789 007311 1789 the lesson preface. This procedure writes code which 1790 007311 1790 handles I/O initialization. 1791 007311 1791 -----------------------------------------------------------; 1792 007321 B105 1792 BEGIN 1793 007321 1793 Write("[N]Input(0,""TTY"");;[N]"); 1794 007324 1794 IF put THEN 1795 007326 B106 1795 BEGIN 1796 007330 1796 IF NOT disk THEN Write("Output(2,""LPT"");;[N]Selectoutput(2);;[N]"); 1797 007335 1797 IF disk THEN Write("Input(1,""DSK"");;[N]Output(2,""DSK"");;[N]Output(3,""DSK"");;[N]"); 1798 007342 1798 IF nocontrolc THEN Write("stopkc;;[N]"); 1799 007345 1799 IF NOT disk AND NOT keep THEN 1800 007351 B107 1800 BEGIN 1801 007354 1801 IF language = 1 THEN textline("Please send this listing to the teacher.") ELSE 1802 007363 1802 IF language = 2 THEN textline("L{raren {r tacksam om Du s{nder denna lista till honom."); 1803 007366 1803 Write("putmessage;;[N]") 1804 007371 E107 1804 END; 1805 007371 1805 Write("Breakoutput;;[N]"); 1806 007374 1806 Write("Selectoutput(0);;[2N]") 1807 007377 E106 1807 END; 1808 007377 1808 COMMENT ------------------------------------------------- 1809 007377 1809 Now we write code which displays certain standard text 1810 007377 1810 material to the student at the beginning of a new lesson. 1811 007377 1811 Most of this code will NOT be written into the lesson, 1812 007377 1812 however, if the %SGNOSIS command was used. 1813 007377 1813 -----------------------------------------------------------; 1814 007377 1814 IF name THEN 1815 007401 B108 1815 BEGIN 1816 007401 1816 IF language = 1 THEN 1817 007404 B109 1817 BEGIN 1818 007404 1818 Write("Write(""[[N]]Hello! This is GNOSIS talking.[[N]]"");;[N]"); 1819 007407 1819 Write("[N]repeat:[N]Write(""I'd like to know your full name--[[N]]just type it in after the arrow.[[N]]"");;[N]"); 1820 007412 1820 IF put THEN 1821 007414 B110 1821 BEGIN 1822 007414 1822 COMMENT The following code brings GNOSIS into compliance with privacy laws; 1823 007414 1823 Write("Write(""[[NT]](Unless you enter a made-up name, GNOSIS will"");;[N]"); 1824 007417 1824 Write("Write(""[[NT]]generate personal data based on this session.)[[2N]]"");;[N]") 1825 007422 E110 1825 END; 1826 007424 1826 IF bell THEN Write("Outsymbol(controlg);;[N]"); 1827 007427 1827 Write("Write(prompt);;[N]getline;;[N]"); 1828 007432 1828 Write("IF answerlength < 6 THEN[N]"); 1829 007435 1829 Write("BEGIN[N]Write(""That's too short to be your FULL name.[[N]]"");;[N]Newline;;[N]GOTO repeat;;[N]END;;[N]"); 1830 007440 1830 Write("FOR pos:= 1 STEP 1 UNTIL answerlength DO IF answer.[[pos]] = blank THEN GOTO continue;;[N]"); 1831 007443 1831 Write("Write(""That's only ONE of your names.[[N]]"");;[N]GOTO repeat;;[N]"); 1832 007446 1832 Write("[N]continue:[N]Write(""Glad to meet you, "");;[N]") 1833 007446 E109 1833 END 1834 007452 1834 ELSE IF language = 2 THEN 1835 007455 B111 1835 BEGIN 1836 007455 1836 Write("Write(""[[N]]Hej! Det h{r {r GNOSIS-programmet som talar.[[N]]"");;[N]"); 1837 007460 1837 Write("[N]repeat:[N]Write(""Jag skulle vilja veta ditt fullst{ndiga namn--skriv det p} terminalen.[[N]]"");;[N]"); 1838 007465 1838 IF bell THEN Write("Outsymbol(controlg);;[N]"); 1839 007470 1839 Write("Write(prompt);;[N]getline;;[N]"); 1840 007473 1840 Write("IF answerlength < 6 THEN[N]"); 1841 007476 1841 Write("BEGIN[N]Write(""???[[N]]"");;[N]Newline;;[N]GOTO repeat;;[N]END;;[N]"); 1842 007501 1842 Write("FOR pos:= 1 STEP 1 UNTIL answerlength DO IF answer.[[pos]] = blank THEN GOTO continue;;[N]"); 1843 007504 1843 Write("Write(""???[[N]]"");;[N]GOTO repeat;;[N]"); 1844 007507 1844 Write("[N]continue:[N]Write(""Trevligt att tr{ffas, "");;[N]") 1845 007512 E111 1845 END; 1846 007512 1846 Write("BEGIN[N]INTEGER pos, t;;[N]"); 1847 007515 1847 Write("pos:=1;;[N]"); 1848 007520 1848 Write("[N]nameloop:[N]t:=answer.[[pos]];;[N]"); 1849 007523 1849 Write("IF pos