12.07.2015 Views

page-1983-101-timex-sinclair-programming-tricks

page-1983-101-timex-sinclair-programming-tricks

page-1983-101-timex-sinclair-programming-tricks

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

9 Mystery CluesWant to create your own murder mystery? Figure outwhodunit and write your program backwards from there.When your players make wrong guesses, give them tantalizingclues.Here's a short program which you can load into yourcomputer in a matter of minutes. Key it in and try it out. Itshows how you can add clues to your mysteries.For simplicity, we assume here the Butler did it. Notethat, in line 20, we are making him equal to X$. At line 30,the computer stops to ask you whom you think did it. Youranswer is recorded in A$.In line 40, your answer, lodged in A$, is comparedwith the computer's already-certain knowledge that theButler did it. A$ is compared with X$. If they agree, andonly if they agree, the computer displays the message,"You guessed it." If you got it right, things will end rightthere.If, however, you missed it, program execution (sorryabout using that word in a murder mystery!) drops to line50 where we hear the computer, "Clue: servant." Afterdeftly dropping that clue, the computer moves back toline 10 and runs through the whole affair another time. Itwill keep running through it until you answer, "Butler," inresponse to its question in line 30.Program Listing10 CLS20 LET X$=•BUTLER"30 PRINT •WHODlOJNIT ?•35 INPUT A$40 IF X$=A$ THEN GOTO 10045 CLS50 PRINT •cLUE: SERVANT•60 FOR T=l TO 10070 NEXT T80 GOTO <strong>101</strong>00 PRINT •you GUESSED IT: BUTLER.24

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!