Programming 4 SubRoutines ContentObjective Learn BASIC programming subroutine
Programming 4 Sub-Routines Content-Objective: Learn BASIC programming sub-routine skills. Language-Objective: Create a BASIC program utilizing subroutines from scratch using JUST BASIC.
Programming 4 Sub-Routines Utah State Robotics 1 Standard 3 Common Core High School Algebra Reasoning Common Core High School Interpreting Functions
Do today’s Starter Quiz! (in Canvas)
Starter Information DEFINITION Sub-Routine A set of computer related instructions placed into a structure where they can be called up and executed from anywhere in the program.
Starter Information PURPOSE Sub-routine Simplify programming task by placing instruction sequences that are repeatedly executed into an area where they can be repeatedly called up.
BASIC SUB-ROUTINE COMMANDS 1. GOSUB Calls the subroutine placed elsewhere in the program. An address or label for the sub-routine must be given after the GOSUB command. 2. RETURN (End of subroutine structure returns program execution to the instruction placed after the GOSUB instruction in the main program.
END STARTER INFORMATION
Today's Class Task Create a simple BASIC program from a flowchart using Just Basic v 1. 01
Just BASIC SCREEN
Just BASIC Information 1. Click on “File” then “new BASIC source file” to start entering program. 2. The white area of the screen below the menu bar is where you write your program. 3. All program commands must have a line number before them and numerically they must be in ascending (progressively higher) order as the program goes down the page.
EXAMPLE SUB-ROUTINED BASIC PROGRAM MAIN PROGRAM 10 GOSUB INPUT 20 GOSUB OUTPUT 30 END
EXAMPLE SUB-ROUTINED BASIC PROGRAM INPUT ROUTINE INPUT 40 X=0 50 WHILE X = 0 60 PRINT “Input your name “ 70 INPUT Y$ 80 IF Y$ = “” THEN 90 GOTO 60 100 WEND 110 END IF 120 RETURN
EXAMPLE SUB-ROUTINED BASIC PROGRAM OUTPUT ROUTINE OUTPUT 130 PRINT “My name is “; Y$ 140 X = X + 1 150 RETURN
Program Execution Click on the “RUN” command on the top line of Just BASIC window
- Slides: 14