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

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

100 PRINT •BACKWARD, IT IS •;R105 PAUSE 200110 GOTO 10l45 Number Reverser IIGive the computer a number. It will immediately,display the number printed backward on the videodisplay.Line 20 collects the number from you. Line 30measures its length. Lines 40-70 reverse it and line 80displays the reversed number.Program Listing10 LET B$= 0 •20 PRINT 0 GIVE ME A NUMBER •;25 INPUT N$30 LET L=LEN N$35 PRINT N$40 FOR Y=L TO 1 STEP -150 LET B$=B$+N$(Y)60 NEXT Y70 LET B=VAL B$80 PRINT 0 REVERSED, THE NUMBER IS •;B90 PRINT100 GOTO 1046 Number-Error TrappingGood programs, those which are well written, neederror trapping. It's a technique for making sure personscommunicating with the computer don't key in inappropriatedata or make mistakes which would cause computationproblems for the computer.For instance, see the example program here. In line65

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

Saved successfully!

Ooh no, something went wrong!