Here - 1000 BiT

Here - 1000 BiT Here - 1000 BiT

11.07.2015 Views

LESSON 24 PRETTY PROGRAMS, GOSUB, RETURN, ENDRun this program, then SAVE it:100 REM TAKE A TRIP101 :105 POKE 53281.0110 PRINT "clr HOP TO THE SUBROUTINE dn"120 GOSUB 200130 PRINT "grh BACK FROM THE SUBROUTINE dn"133 FORT=1 TO 1000:NEXTT135 PRINT "blu HOP AGAIN dn"140 GOSUB 200150 PRINT "cyn HOME FOR GOOD dn whf'190 END199:200 REM SUBROUTINE201 :210 PRINT "red GOT HERE OK dn"215 FORT=1 TO 1000:NEXTT220 PRINT "yel PACK YOUR BAGS. BACK WE GO dn"230 FOR T=1 TO 1000:NEXT T290 RETURNThis is the skeleton of a long program. The main program starts at line 100 and ends atline 190.Where there are PRINT commands, you may put in many more program lines.The END command in line 190 tells the computer that the program is over. The computergoes back to the edit mode.Line 120 and line 140 "call the subroutine." This means the computer goes to thecommands in the subroutine, does them and then comes back.The GOSUB 200 command is like a GOTO 200 command except that the computerremembers where it came from so that it can go back there again.The RETURN command tells the computer to go back to the statement after the GOSUB.136

Assignment 24A:1. The delay loop is written three times in the above program. Add another subroutinewith a delay loop in it, and GOSUB every time you need a delay.WHAT GOOD IS A SUBROUTINE?In a short program, not much good.In a long program, it does two things:1. It saves you work and saves space in memory. You do not have to repeat thesame program lines in different parts of the program.2. It makes the program easier to understand and faster to write and debug.THE END COMMANDThe program may have zero, one or many END commands.RULE: The END command tells the computer to stop running and go back to theEdit Mode.That is really all it does. You can put an END command anywhere in the program: forexample, after THEN in an IF statement.137

LESSON 24 PRETTY PROGRAMS, GOSUB, RETURN, ENDRun this program, then SAVE it:100 REM TAKE A TRIP101 :105 POKE 53281.0110 PRINT "clr HOP TO THE SUBROUTINE dn"120 GOSUB 200130 PRINT "grh BACK FROM THE SUBROUTINE dn"133 FORT=1 TO <strong>1000</strong>:NEXTT135 PRINT "blu HOP AGAIN dn"140 GOSUB 200150 PRINT "cyn HOME FOR GOOD dn whf'190 END199:200 REM SUBROUTINE201 :210 PRINT "red GOT HERE OK dn"215 FORT=1 TO <strong>1000</strong>:NEXTT220 PRINT "yel PACK YOUR BAGS. BACK WE GO dn"230 FOR T=1 TO <strong>1000</strong>:NEXT T290 RETURNThis is the skeleton of a long program. The main program starts at line 100 and ends atline 190.Where there are PRINT commands, you may put in many more program lines.The END command in line 190 tells the computer that the program is over. The computergoes back to the edit mode.Line 120 and line 140 "call the subroutine." This means the computer goes to thecommands in the subroutine, does them and then comes back.The GOSUB 200 command is like a GOTO 200 command except that the computerremembers where it came from so that it can go back there again.The RETURN command tells the computer to go back to the statement after the GOSUB.136

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

Saved successfully!

Ooh no, something went wrong!