Trailing-Edge
-
PDP-10 Archives
-
decuslib10-01
-
43,50110/beloop.dem
There are 2 other files named beloop.dem in the archive. Click here to see a list.
100' NAME--BELOOP
110'
120' DESCRIPTION--DETAILED EXPLANATION OF THE LOOP PROCESS.
130'
140' SOURCE--UNKNOWN
150'
160' INSTRUCTIONS--TYPE "RUN" AND FOLLOW INSTRUCTIONS.
170'
180'
190' * * * * * MAIN PROGRAM * * * * * * * * * * * *
200'
210 REM THIS IS THE BEGINNING OF THE LOOP ASSIGNMENTS.
220 REM IF YOU WANT THE ASSIGNMENT, TYPE RUN .
230 PRINT" YOU MAY READ THIS EXPLANATION IN THE BOOKLET. DO YOU"
240 PRINT"HAVE A BOOKLET";
250 INPUT Z$
260 IF Z$="YES" THEN 870
270PRINT
280PRINT
290 PRINT" **** LOOPS****"
300 PRINT
310 PRINT" IN ORDER TO ALLOW THE PROGRAMMER TO WRITE ONLY A FEW"
320 PRINT"STEPS AND YET HAVE THE MACHINE DO A LARGE NUMBER OF COMPUTATIONS,"
330 PRINT"THERE IS A METHOD OF HAVING THE MACHINE GO BACK AND REPEAT A"
340 PRINT"SERIES OF STATEMENTS--- LOOPS."
350 PRINT
360 PRINT" MAKING A PROGRAM LOOP MAKES THE MACHINE DO THE SAME OPERATION"
370 PRINT"ON A SET OF VARIABLES OVER AND OVER AGAIN. IF NEW NUMBERS"
380 PRINT "ARE ASSIGNED TO THE VARIABLES AT THE END OF EACH PASSAGE THROUGH"
390 PRINT"THE LOOP, THE OPERATIONS PERFORMED ON THESE VARIABLES YIELD"
400 PRINT"NEW RESULTS EACH TIME."
410 PRINT
420 PRINT" ****THE *GOTO* STATEMENT****"
430 PRINT
440 PRINT" WHEN THE MACHINE ENCOUNTERS A STATEMENT SUCH AS ,"
450 PRINT"70 GOTO 100 , IT GOES TO THE LINE NUMBER FOLLOWING THE"
460 PRINT"*GOTO* AND CONTINUES ON THROUGH THE PROGRAM.(IN OUR EXAMPLE"
470 PRINT"THE MACHINE WOULD SKIP DOWN OVER ALL STATEMENTS FROM 71 TO 99"
480 PRINT"AND CONTINUE THROUGH THE PROGRAM FROM LINE 100)"
490 PRINT
500 PRINT" IF THE *GOTO* STATEMENT SENDS THE MACHINE BACK TO AN EARLIER"
510 PRINT"LINE IN THE PROGRAM, THE MACHINE WILL GO BACK TO THAT LINE AND"
520 PRINT"CONTINUE THROUGH THE PROGRAM UNTIL IT COMES TO THE *GOTO*"
530 PRINT"STATEMENT AT WHICH POINT IT WILL RETURN AGAIN , AND AGAIN,"
540 PRINT"AND AGAIN, AND AGAIN...IN OTHER WORDS,THE MACHINE"
550 PRINT"IS IN AN INFINITE LOOP."
560 PRINT
570 PRINT" ONE WAY TO AVOID AN INFINITE LOOP IS TO INCLUDE A *READ* STATEMENT"
580 PRINT"IN THE LOOP AND THE MACHINE WILL STOP AFTER IT EXHAUSTS THE"
590 PRINT"*DATA* STATEMENT. BUT PROGRAMS MAY BE WRITTEN WITHOUT A *READ*"
600 PRINT"STATEMENT IN THE LOOP. CONSIDER THE FOLLOWING PROGRAM WHERE"
610 PRINT"THE LOOP IS LINES 30,40,50,AND 60. "
620 PRINT
630 PRINT"10 READ N"
640 PRINT"20 LET X=0"
650 PRINT"30 PRINT X, X*X*X"
660 PRINT"40 LET X=X+1"
670 PRINT"50 IF X=N THEN 70"
680 PRINT"60 GO TO 30"
690 PRINT"70 DATA 10"
700 PRINT"80 END"
710 PRINT
720 PRINT" IF YOU MAKE A LOOP WITH A *GOTO* STATEMENT AND THE LOOP"
730 PRINT"DOES NOT CONTAIN A *READ* STATEMENT, THEN TO HAVE THE MACHINE"
740 PRINT"END THE PROGRAM THERE MUST BE A STATEMENT CONTAINED IN "
750 PRINT"THE LOOP TO BREAK OUT AT A CERTAIN TIME. THIS CAN BE DONE "
760 PRINT"BY HAVING AN *IF..THEN* STATEMENT CHECK TO SEE IF A CERTAIN"
770 PRINT"CONDITION IS MET AT WHICH TIME IT DIRECTS THE MACHINE TO GO "
780 PRINT"TO A LINE BELOW THE *GOTO* STATEMENT AND THEREFORE OUT OF THE"
790 PRINT"LOOP."
800 PRINT
810 PRINT" IF WHEN RUNNING YOUR PROGRAM THE MACHINE APPEARS TO"
820 PRINT"BE RUNNING AN EXTRA LONG PERIOD OF TIME, TYPE RUN AGAIN."
830 PRINT" THE MACHINE SHOULD THEN TYPE BACK RUNNING TIME--(TIME) ."
840 PRINT"IF THE TIME EXCEEDS 10 SECONDS YOU ARE PROBABLY IN AN"
850 PRINT"INFINITE LOOP. TYPE STOP AND CHECK YOUR PROGRAM AND LOCATE"
860 PRINT"YOUR ERROR--MAKE SURE YOUR CONDITIONAL WILL WORK--"
870PRINT
880 PRINT" YOUR NEXT ASSIGNMENT IS TO COPY THE FOLLOWING PROGRAM,"
890 PRINT"STUDY IT UNTIL YOU ARE SURE YOU UNDERSTAND WHAT IS GOING ON,"
900 PRINT"RUN IT, AND THEN TYPE TEST ."
910 PRINT
920 PRINT" NAME YOUR NEW PROBLEM LOOP--"
930 PRINT"10 READ N"
940 PRINT"20 LET X=0"
950 PRINT"30 PRINT X, X*X*X"
960 PRINT"40 LET X=X+1"
970 PRINT"50 IF X=N THEN 70"
980 PRINT"60 GO TO 30"
990 PRINT"70 DATA 10"
1000 PRINT"80 END"
1010 PRINT"GOOD LUCK..."
1020 END