Procedures.

Slides:



Advertisements
Similar presentations
P5, M1, D1.
Advertisements

E-2020 Science Classes New Year 2012 Procedures. Vocabulary Write each vocabulary word Each definition, in your own words if possible Draw a picture to.
ABNIAC The following slide presentation is to acquaint the student with ABNIAC. The version used for presentation is the Java version, which can be found.
Write a program that allows a user to enter information relating to the name and salary details of an employee The user should be able to enter the name.
An Introduction to Textual Programming
Welcome! The Topic For Today Is…Review for Test. Your Topic Basics of Programming Control Statements Programming Concepts InteractionAlice Concepts 200.
Spreadsheet-Based Decision Support Systems Chapter 22:
Higher Grade Computing Studies 2. Languages and Environments Higher Computing Software Development S. McCrossan 1 Classification of Languages 1. Procedural.
Submitting your work online This is a two stage process 1.First you need to add your submission to Moodle, this is usually done by uploading one or more.
Introduction to Visual Basic. Quick Links Windows Application Programming Event-Driven Application Becoming familiar with VB Control Objects Saving and.
Python Programming Using Variables and input. Objectives We’re learning to build functions and to use inputs and outputs. Outcomes Build a function Use.
7 1 User-Defined Functions CGI/Perl Programming By Diane Zak.
Making Python Pretty!. How to Use This Presentation… Download a copy of this presentation to your ‘Computing’ folder. Follow the code examples, and put.
Build-A-Button Glenn G. Chappell U. of Alaska Fairbanks CS 381 Lecture Notes Wednesday, October 8, 2003.
Simple Quiz Assessment David Yan Under the direction of Susan Rodger Duke University June 2015.
Algorithms Writing instructions in the order they should execute.
This is an example of an interactive PowerPoint presentation click the button to find out more Enter.
It works! PPInfoScreen Server is now running and will display your deployed presentations Some instructions will follow…
Oracle PL/SQL Loops Please use speaker notes for additional information!
Chapter 13 Do It, Then Ask Permission (Posttest Loops) Clearly Visual Basic: Programming with Visual Basic nd Edition.
GCSE Computing#BristolMet Session Objectives #23 MUST understand what is meant by the programming term iteration SHOULD describe methods of looping used.
AVCE ICT – Unit 7 - Programming Session 12 - Debugging.
If screen is locked press: Ctrl*Alt*Delete Login: Your Sharepoint Login & Password Go to: Sharepoint then Construction Administration Go to: Drawing Review.
Microsoft® Small Basic Conditions and Loops Estimated time to complete this lesson: 2 hours.
JavaScript 101 Lesson 6: Introduction to Functions.
Timed Quiz You are about to see 6 questions. You need to work out which answer is the odd one out. You have 30 seconds per question Click to continue.
Introduction to Scratch We will be using the Scratch Environment today, so please log in to the Scratch website (scratch.mit.edu)
World of Wokcraft The very best in Single pan cooking themed fantasy gaming!
Scratch Programming Cards
Власенко Юлия Сергеевна, учитель математики МОУ ООШ №5 г. Качканар
Multiple Forms and Menus
Task 2f – part a Prove that you can receive an WITH an attachment, open it AND save the attachment to your user area. Open the with the attachment.
Computer Programming.
Testing for Conductivity
3.01 Apply Controls Associated With Visual Studio Form
UNIT 3 – LESSON 5 Creating Functions.
Introduction To Flowcharting
3.01 Apply Controls Associated With Visual Studio Form
3rd prep. – 2nd Term MOE Book Questions.
Using the Stopwatch object
While Loops Chapter 3.
Explain what touch develop is to your students:
Loopy Motion Control.
For a new user you must click on the “Registration for Generator” link
For Loops October 12, 2017.
For -G7 programing language Teacher / Shamsa Hassan Alhassouni.
Introduction to pseudocode
For -G7 programing language Teacher / Shamsa Hassan Alhassouni.
Looping and Random Numbers
Loops CIS 40 – Introduction to Programming in Python
Unit 3: Lesson 9-Looping and Random Numbers
Introduction to TouchDevelop
Hour of Code.
Programs. at the code at the site..
7 The Paradox Of Meaning A MASTERCLASS ON MEANING AND VALUED LIVING.
Data and Flowcharts Session
CSCI N207 Data Analysis Using Spreadsheet
Using Waits, Loops and Switches
Library Search Procedure
IPC144 Introduction to Programming Using C Week 4 – Lesson 2
Data and Flowcharts Session
Using Placeholders to Simplify your Methods: Learning Methods, Part 2
True / False Variables.
Intro to Programming Review for Quiz.
Lecture 20 – Practice Exercises 4
Lecture 20 – Practice Exercises 4
Intro to Programming (in JavaScript)
Basic Procedures By Phil Bagge HIAS Computing Inspector / Advisor
Executive Reports, Instructions and Documentation
Step 1: Click Registration Link
Presentation transcript:

Procedures

What is a procedure? Often in a program we will need to repeat the same task over and over again. Rather than repeat writing the code every time we use it, we can use what is called a procedure.

Consider our quiz program where we might wish for our user to click a continue button after each question. That means every question we ask we need to draw the box: drawfillbox(50,50,150,100) locatexy(75,75) put(“continue”)

Then after they answer the question, we need to check whether they have clicked the button: loop mousewhere(x, y, button) exit when x<150 and x >50 and y >50 and y<100 and button=1 then end loop

If we are asking only one or two questions, repeating this code is fine. But if we intend to ask 30-50 questions, then this isn’t the best way to do things.

A procedure is essentially a small program within a program, that we will call whenever it is needed. A procedure is created to perform a very limited and specific task. In our example we would create two procedures. The first to create the button, and the second to check whether the button was pressed.

Syntax Just as we declare a variable in order for the program to recognize it later, we must also declare a procedure: procedure name ( parameters ) instructions end name Then when we wish to use the procedure in our program we call it by it’s name.

Example procedure create_button drawfillbox(50,50,150,100,blue) locatexy(75,75) put(“continue”) end create_button

procedure is_continue_clicked loop mousewhere(x, y, button) exit when x<150 and x >50 and y >50 and y<100 and button=1 then end loop end is_continue_clicked

Now our program will look like: put “What is your name” get name create_button is_continue_clicked put “What is your age” get age createbutton

Special notes on procedures Procedures must be declared at the beginning of the file! You may call a procedure within a procedure but it must have already been declared. (See example B) Two or more procedures may not call each other!

Example B procedure terrence put “Hi my name is Terrence” end terrence procedure philip terrence put “Hi Terrence my name is Philip” end philip

Example C procedure one two % calls procedure two end one % but two hasn’t been % declared yet procedure two one % calls procedure one end two