10 'DECIDE
20 'ORIGINAL VERSION COPYRIGHT 1980 PHIL FELDMAN & TOM RUGG
21 'MODIFIED BY J HOPE JAN 1983 TO RUN ON OTRONA ATTACHE
22 'MODIFIED BY DICK SCARISBRICK JULY/83 FOR OSBORNE
30 'TEXT
35 WIDTH 255
40 DIM L$(10), F$(10),V(10),C(10,10),D(10),Z(10)
50 E$ = ""
60 GOSUB 1470
70 GOSUB 1540
80 PRINT"       I can help you to make a decision.  All you to do is to "
90 PRINT"answer some questions.  I will analyze the information you give."
100 PRINT
110 PRINT
120 PRINT"Which of the following best describes the type"
130 PRINT"of decision you face?"
140 PRINT:PRINT
150 PRINT"      1) Choosing an item from various alternatives." : PRINT
160 PRINT"      2) Choosing a course of action from various alternatives.":PRINT
170 PRINT"      3) Making a YES or NO decision." : PRINT 
180 P$="Please indicate which ( 1, 2, or 3)":PRINT P$ : GOSUB 1650
190 T = INT(VAL(R$))
200 IF T<1 OR T>3 THEN 180
210 '
220 GOSUB 1470
230 ON T GOTO 240,270,300       'SELECT SUBROUTINE
240 INPUT "What type of item must you decide upon "; T$
250 GOTO 330
260 '
270 T$ = "course of action":GOTO 330
280 '
290 '
300 T$ = "'YES or No'"
310 NI = 2: L$(1) = "DECIDING YES":L$(2) = "DECIDING NO"
320 GOTO 550
330 GOSUB 1470:NI = 0
340 PRINT "     I need to have a list of each ";T$;" underconsideration.":PRINT
350 PRINT "Please input them one at a time.":PRINT
360 PRINT"The order you put them in has no significance.":PRINT
370 PRINT"Please hit the RETURN key to indicate that whole list has"
380 PRINT"been entered.  Thank you."
390 PRINT:PRINT
400 PRINT TAB(16);UNDER$;"Types of ";T$;UNDER.STOP$
410 NI = NI+1:INPUT L$(NI)     
420 IF L$(NI)<>E$ THEN 410
430 NI = NI-1
440 IF NI=>2 THEN GOTO 460 ELSE PRINT "You must have at least 2 choices.Pleasetry again."
450 GOSUB 1520 :  GOTO 330 
460 GOSUB 1470:PRINT"OK here's the list you've given me.":PRINT
470 FOR J = 1 TO NI : PRINT"  ";J;") ";L$(J):NEXT  : PRINT
480 P$=" Is this list correct? (Y/N)":PRINT P$:GOSUB 1650 
490 IF R$ = "Y" OR  R$ = "y" THEN PRINT"YES":GOTO 550
500 IF R$ = "N" OR R$ = "N" THEN PRINT "NO" 
510 PRINT "Then the list must be re-entered.  Sorry..."
520 IF R$ = "N" OR  R$ = "n" THEN GOSUB 1520:GOSUB 330
530 '
540 GOSUB 1470
550 PRINT CLSCR$"Now think of the ";REVERSE$;"different factors";REVERSE.OFF$
560 IF T<3 THEN PRINT "that are important to you in chosing"
570 IF T<3 THEN PRINT"the best ";T$;"."
580 IF T = 3 THEN PRINT "that are important to you in deciding"
590 IF T = 3 THEN PRINT " YES or NO."
600 PRINT:PRINT"        Input them one at a time please, and hit the RETURNkey"
610 PRINT"Hit the RETURN key again when the list is complete."
620 PRINT: PRINT : PRINT 
630 PRINT TAB(16) UNDER$ "Different Factors Important to You";UNDER.STOP$
640 PRINT UNDER.STOP$
650 PRINT TAB(16) UNDER$ "When Choosing a ";T$;UNDER.STOP$
660 PRINT:NF = 0 
670 NF = NF + 1 : INPUT "Factor";F$(NF)
680 IF F$(NF)<> E$ THEN 670
690 NF = NF - 1 : PRINT
700 IF NF=>2 THEN GOTO 730
710 IF NF<1 THEN PRINT " Please... You must have at least one, let's go back."
720 IF NF < 1 THEN GOSUB 1520:GOTO 550
730 GOSUB 1470:PRINT"Here's the list of the factors you gave me:" :PRINT
740 FOR J = 1 TO NF:PRINT"  ";J;") "F$(J):NEXT:PRINT
750 PRINT"Now please decide which of these is the most important factor.":PRINT  
760 PRINT"What number is it please?"
770 PRINT"You can type '0' if the list needs changing."
780 P$ = "Most important factor number":PRINT P$:GOSUB 1650:A=VAL(R$)
790 'INPUT"Most important factor number";A : A = INT(A): IF A = 0 THEN 750
800 A = INT(A) : IF A = 0 THEN 550
810 IF A < 0 OR A > NF THEN 730
820 GOSUB 1470: IF NF = 1 THEN 940
830 PRINT"Let's suppose we have a scale of importance ranging from 0 to 10"
840 PRINT:PRINT:PRINT
850 PRINT"We'll give ";F$(A); " a value of 10"
860 PRINT"since you rated ";F$(A);" as the most important."
870 PRINT
880 PRINT"On this scale, what value of importance would the otherfactorshave?":PRINT:PRINT
890 PRINT"IF ";F$(A);" is 10"
900 FOR J = 1 TO NF: Q=A: IF J = Q THEN 930
910 PRINT"then ";F$(J);" is":INPUT V(J)
920 IF V(J) <0 OR V(J)>10 THEN PRINT "That value is not between 0 and10":GOTO910
930 NEXT J
940 V(A) = 10: Q = 0 : FOR J = 1 TO NF: Q = Q + V(J): NEXT J: FOR J = 1 TO NF
950 V(J) = V(J)/Q:NEXT J : GOSUB 1470
960 IF T<> 3 THEN PRINT "   Each ";T$
970 IF T = 3 THEN PRINT"  Deciding YES or deciding NO"
980 PRINT"must now be compared with respect to "
990 PRINT"each importance factor.":PRINT:PRINT
1000 PRINT"We'll consider each factor separately and then rate "
1010 IF T<>3 THEN PRINT " each ";T$;" in terms "
1020 IF T = 3 THEN PRINT " deciding YES or NO in terms"
1030 PRINT "of that factor in isloation from the other(s)"
1040 PRINT"     Let's give ";L$(1)
1050 PRINT" a value of 10 on every scale.":PRINT
1060 IF T<>3 THEN PRINT "  then every other  " ;T$
1070 IF T = 3 THEN PRINT " then deciding NO"
1080 PRINT" will be assigned a value higher or lower than 10"
1090 PRINT"This value depends on how much you think it is better or worse than"
1100 PRINT;L$(1)
1110 PRINT: FOR J = 1 TO NF
1120 PRINT "   _____________________________":PRINT
1130 PRINT "Considering only "REVERSE$;F$(J); REVERSE.OFF$
1140 PRINT "     If "L$(1);" is 10:"
1150 PRINT "what would you assign to"
1160 PRINT : FOR K = 2 TO NI
1170 PRINT L$(K):INPUT"  ";C(K,J) : PRINT : IF C(K,J)=>0 THEN 1190
1180 PRINT "  ** Negative Values Are Not Valid here **"
1190 NEXT  : PRINT : C(1,J)=10: NEXT 
1200 FOR J = 1 TO NF: Q = 0 : FOR K = 1 TO NI
1210 Q = Q + C(K,J):NEXT: FOR K = 1 TO NI
1220 C(K,J) = C(K,J)/Q:NEXT:NEXT
1230 FOR K = 1 TO NI:D(K)=0 : FOR J = 1 TO NF
1240 D(K)=D(K) +C(K,J)*V(J):NEXT:NEXT
1250 MX = 0 : FOR K = 1 TO NI
1260 IF D(K)>MX THEN MX = D(K)
1270 NEXT : FOR K = 1 TO NI :D(K) = D(K)*100/MX:NEXT
1280 FOR K = 1 TO NI:Z(K) = K:NEXT: NM=NI-1
1290 FOR K = 1 TO NI:FOR J = 1 TO NM:N1 = Z(J):N2 = Z(J+1):IF D(N1)>D(N2) THEN GOTO 1310
1300 Z(J+1) = N1:Z(J)=N2
1310 NEXT:NEXT:J1=Z(1):J2 = Z(2): DF = D(J1)-D(J2):GOSUB 1470
1311 PRINT "DO YOU WANT A PRINTED ANSWER? Y/N"
1312 GOSUB 1650
1313 IF R$ = "N" GOTO 2320
1320 LPRINT L$(J1);
1330 LPRINT "    comes out best"
1340 IF DF<5 THEN LPRINT"but it is very close." : GOTO 1390
1350 IF DF<10 THEN LPRINT"but it is fairly close.":GOTO 1390
1360 IF DF<20 THEN LPRINT"by a fair amount.":GOTO 1390
1370 LPRINT "quite decisively."
1380 LPRINT
1390 LPRINT"Here is the final list in order.":LPRINT
1400 LPRINT L$(J1)  
1410 LPRINT"has been given a value of 100 and the others rated accordingly."
1420 FOR J = 1 TO NI: Q=Z(J):LPRINT D(Q);TAB(16);L$(Q):NEXT
1430 GOTO 2430
1440 GOSUB 1650
1450 IF R$="Y" THEN 60
1460 GOTO 2320 
1470 FOR J = 1 TO 100 : NEXT
1480 'GRAPH
1490 PRINT TAB(32);"THE DECISION MAKER"
1500 PRINT
1510 RETURN
1520 FOR J = 1 TO  100 
1530 NEXT: RETURN
1540 '********** FUNCTIONS USED IN PROGRAM *******
1550 CLSCR$ = CHR$(26)
1560 BELL$ = CHR$(7)
1570 REVERSE$ = CHR$(27) + CHR$(85) +CHR$(41)
1580 REVERSE.OFF$ = CHR$(27) + CHR$(85) + CHR$(32)
1590 HOME$ = CHR$(30)
1600 UNDER$ = CHR$(27) +CHR$(85) + CHR$(40)
1610 UNDER.STOP$ = CHR$(27) + CHR$(85) + CHR$(32)
1620 BIG$ = CHR$(27)+CHR$(83)+CHR$(49)
1630 BIG.STOP$ = CHR$(27)+CHR$(83)+CHR$(48)
1640 RETURN
1650 '******** INPUT RESPONSE *******
1660 TIMEOUT% =20000
1670 PRINT BELL$
1680 RESPONSE$ = ""  
1690 FOR I% = 1 TO TIMEOUT%
1700 A$ = INKEY$ : IF LEN(A$) = 0 THEN 1740
1710 IF ASC(A$) = 13 THEN TIMEOUT% = 0 : GOTO 1760
1720 IF LEN(A$) <>0 THEN GOTO 1780   
1730 R$ = RESPONSE$ + A$
1740 NEXT I%
1750 PRINT BELL$
1760 PRINT P$
1770 GOTO 1660
1780 R$ = RESPONSE$ + A$
1790 RETURN
2320 PRINT L$(J1);
2330 PRINT "    comes out best"
2340 IF DF<5 THEN PRINT"but it is very close." : GOTO 1390
2350 IF DF<10 THEN PRINT"but it is fairly close.":GOTO 1390
2360 IF DF<20 THEN PRINT"by a fair amount.":GOTO 1390
2370 PRINT "quite decisively."
2380 PRINT
2390 PRINT"Here is the final list in order.":PRINT
2400 PRINT L$(J1)  
2410 PRINT"has been given a value of 100 and the others rated accordingly."
2420 FOR J = 1 TO NI: Q=Z(J):PRINT D(Q);TAB(16);L$(Q):NEXT
2430 PRINT:PRINT:P$="DO YOU WISH TO WORK OUT MORE DECISIONS? Y/N" :PRINT P$
2440 GOSUB 1650
2450 IF R$="Y" THEN 60
2460 PRINT"It was nice working with you.  Bye bye...":END
2470 FOR J = 1 TO 100 : NEXT
2480 PRINT CHR$(26)
2490 PRINT TAB(32);"THE DECISION MAKER"
2500 PRINT
2510 RETURN
2520 FOR J = 1 TO  100 
2530 NEXT: RETURN
 PRINT CHR$(26)
2490 PRINT TAB(32);"THE DECISION MAKER"
2500 PRINT
2510 RETURN
