Trailing-Edge
-
PDP-10 Archives
-
decuslib20-01
-
decus/20-0024/tutr07.bas
There are 2 other files named tutr07.bas in the archive. Click here to see a list.
00080REM TUT7
00100GOTO130
00110PRINT"NO SUCH CHOICE. LETS TRY AGAIN - WHICH ONE";
00120RETURN
00130PRINT"FOR A LOOP, WE NEED SPECIAL MACHINE INSTRUCTIONS. WHAT FORM"
00140PRINT"THESE TAKE DEPENDS ON HOW THE COMPUTER IS TOLD THE NUMBER OF"
00150PRINT"NECESSARY ITERATIONS. IT MAY BE ASKED TO DECIDE THIS, WHICH"
00160PRINT"MEANS THAT 'DECISION-MAKING' CAN ENTER INTO THE LOOP PROCESS."
00170PRINT
00180PRINT"IN THE PROGRAM FOR COMPUTING RADIUS VECTORS, THE COMPUTER MADE"
00190PRINT"A DECISION AS TO HOW MANY RADIUS VECTORS TO COMPUTE, BASED ON"
00200PRINT"THE AMOUNT OF DATA PROVIDED. THERE ARE MANY REASONS WHY SUCH A"
00210PRINT"MEANS OF DECISION-MAKING IS IMPRACTICAL FOR ORDINARY PURPOSES."
00220PRINT"FOR ONE THING, YOU MAY NOT WANT TO USE ALL OF THE DATA FOR A"
00230PRINT"PARTICULAR 'RUN'. OTHER REASONS WILL SUGGEST THEMSELVES."
00240PRINT
00250PRINT"ORDINARY DECISION-MAKING IS DONE BY MEANS OF ONE OF THESE FOUR"
00260PRINT"CODE WORDS: (1) 'NEXT' (2) 'THEN' (3) 'IF' OR (4) 'FOR'"
00270PRINT"WHICH DO YOU THINK IT MIGHT BE (USE THE NUMBER OF THE CHOICE,"
00280PRINT"FOLLOWING MY QUESTION MARK)..";
00290INPUTQ
00300PRINT
00310IFQ<=4THEN 340
00320GOSUB 180
00330GOTO 360
00340IFQ=3THEN 370
00350PRINT"THIS IS USED FOR SOMETHING ELSE. TRY AGAIN. WHICH ONE";
00360GOTO 290
00370PRINT"YOU'RE RIGHT. 'IF' WARNS THE COMPUTER THAT IT IS TO MAKE A"
00380PRINT"CHOICE, BASED ON A GIVEN CONDITION. OF COURSE SINCE A COMPUTER"
00390PRINT"CAN'T ACTUALLY THINK (ALMOST BUT NOT QUITE) IT NEEDS ANOTHER"
00400PRINT"CODE WORD TO TELL IT HOW TO MAKE THE CHOICE. THAT OTHER WORD"
00410PRINT"IS ALSO ONE OF THOSE FOUR LISTED ABOVE. WHICH DO YOU SUGGEST"
00420PRINT"IT MIGHT BE (REMEMBER - SINCE YOU'VE ALREADY PICKED '3' FOR"
00430PRINT"THE FIRST QUESTION, IT COULDN'T BE THE RIGHT CHOICE HERE)..";
00440INPUTJ
00450PRINT
00460IFJ=2THEN 490
00470PRINT"YOU SHOULD HAVE TYPED '2', BECAUSE 'THEN' IS THE WORD THAT"
00480GOTO 500
00490PRINT"VERY GOOD. AND TO EXPLAIN: THE WORD 'THEN' IS THE ONE THAT"
00500PRINT"CONDITIONALLY (I.E., DEPENDING ON SOME CONDITION) 'CLUES' THE"
00510PRINT"MACHINE AS TO JUST WHAT STATEMENT (IDENTIFIED BY LINE NUMBER)"
00520PRINT"IS TO BE USED NEXT IN THE PROGRAM. 'IF' AND 'THEN' ARE COMBINED"
00530PRINT"IN A PATICULAR WAY. ONE OF THE FOLLOWING IS THE CORRECT FORM:"
00540
00550PRINT
00560PRINT" (1) IF X=4 THEN 35583 (3) IF X EQUALS 4 THEN 35583"
00570PRINT
00580PRINT" (2) IF X THEN 25 (4) IF X IS 4 THEN 35583"
00590PRINT
00600PRINT"PICK THE ONE (NUMBER OF CHOICE) WHICH SEEMS CORRECT. WHICH ONE";
00610INPUTL
00620PRINT
00630IFL=1THEN 730
00640IFL=2THEN 710
00650IFL=3THEN 690
00660IFL=4THEN 690
00670GOSUB 110
00680GOTO 610
00690PRINT"NO, BUT YOU HAVE THE RIGHT IDEA. SO WHICH MUST IT BE" ;
00700GOTO 610
00710PRINT"THIS DOESN'T ACTUALLY PUT ANY CONDITION ON 'X'. WHICH OTHER ONE";
00720GOTO 610
00730PRINT"YOU FIGURED THAT ONE OUT. THE '=' SYMBOL, RATHER THAN THE WORD"
00740PRINT"'EQUALS', IS NECESSARY, AND 'X=4' PUTS A CONDITION ON 'X'. THE"
00750PRINT"'35583' IS A LEGITIMATE LINE NUMBER, SINCE ANY LINE NUMBER"
00760PRINT"THROUGH 99999 IS ACCEPTABLE. THE COMPUTER WILL TRANSFER CONTROL"
00770PRINT"TO LINE 35583 ONLY IF 'X' IS EXACTLY 4; OTHERWISE IT WILL"
00780PRINT"IGNORE THE INSTRUCTION AND CONTINUE WITH THE NEXT ONE."
00790PRINT
00800PRINT"LET'S PLAY A MATCHING GAME WITH THE FOLLOWING:"
00810PRINT
00820PRINT" (A) 'IS EQUAL TO' (1) > (6) <>"
00830PRINT" (B) 'IS NOT EQUAL TO' (2) => (7) >="
00840PRINT" (C) 'IS LESS THAN' (3) >< (8) <"
00850PRINT" (D) 'IS GREATER THAN' (4) <= (9) =<"
00860PRINT" (E) 'IS LESS THAN OR EQUAL TO' (5) ="
00870PRINT" (F) 'IS GREATER THAN OR EQUAL TO'"
00880PRINT
00890PRINT"THE THREE SYMBOLS '=', '<', AND '>', SHOWN ALONE AND IN VARIOUS"
00900PRINT"COMBINATIONS IN THE CHOICES (1) THROUGH (9), GIVE CONDITIONAL"
00910PRINT"CONTROL TO THE 'IF' STATEMENT. SIX OF THE CHOICES HAVE MEANINGS"
00920PRINT"GIVEN BY THE LETTER-IDENTIFIED LIST (A) THROUGH (F). NOW"
00930PRINT"SEE IF YOU CAN MATCH THE SYMBOLS WITH THE MEANINGS."
00940PRINT"DECIDE WHAT SEQUENCE OF NUMBER CHOICES AGREE WITH THE LETTER"
00950PRINT"SEQUENCE, AND TYPE THOSE SIX NUMBERS SEPARATED BY COMMAS (FOR"
00960PRINT"INSTANCE, IF YOU WERE TO SELECT THE FIRST 6 IN ORDER, YOU WOULD"
00970PRINT"TYPE THEM AS: 1,2,3,4,5,6). WHAT'S YOUR ANSWER.." ;
00980INPUTA,B,C,D,E,F
00990PRINT
01000IFA<>5THEN 1080
01010IFB<>6THEN 1080
01020IFC<>8THEN 1080
01030IFD<>1THEN 1080
01040IFE<>4THEN 1080
01050IFF<>7THEN 1080
01060PRINT"NICE GOING - YOU GOT IT COMPLETELY RIGHT. SO NOW REMEMBER THAT"
01070GOTO 1160
01080PRINT"WON'T WORK. IF YOU WANT ME TO TELL YOU, TYPE '1' - IF YOU WANT"
01090PRINT"TO TRY AGAIN, TYPE ANY OTHER NUMBER. WHAT'S YOUR PLEASURE" ;
01100INPUTG
01110PRINT
01120 IF G=1 THEN 1150
01130PRINT"OK....THEN WHAT DO YOU THINK THE COMBINATION IS" ;
01140GOTO 980
01150PRINT"WELL, YOU SHOULD HAVE HAD 5,6,8,1,4,7 IN THAT ORDER. YOU SEE,"
01160PRINT"'=' MEANS 'IS EQUAL TO', '<>' MEANS 'IS NOT EQUAL TO', '<'"
01170PRINT"MEANS 'IS LESS THAN', '>' MEANS 'IS GREATER THAN' '<=' MEANS"
01180PRINT"'IS LESS THAN OR EQUAL TO', AND '>=' MEANS 'IS GREATER THAN OR"
01190PRINT"EQUAL TO'. THE SYMBOLS NOT USED ABOVE ARE INVALID."
01200PRINT
01210PRINT"NOW THAT YOU UNDERSTAND 'IF' AND 'THEN', LET'S SEE HOW WE CAN"
01220PRINT"USE THEM TO CONTROL ITERATIONS. THIS WILL BE AN 'IF' LOOP, AND"
01230PRINT"THE COMPUTER WILL DECIDE THE NUMBER OF TIMES WE GO THROUGH IT."
01240PRINT"WE'LL TAKE A LOOK AT AN EXAMPLE OF THIS AND WORK OUT A USABLE"
01250PRINT"SOLUTION, BUT FIRST WE'LL NEED TO CALL IN A DIFFERENT PROGRAM"
01260PRINT"FROM THE LIBRARY. YOU SHOULD BE GETTING GOOD AT CALLING THESE"
01270PRINT"IN BY NOW. THIS ONE IS 'TUTR08*' - SO CALL IT AND WE-LOOP."
01280END