Using Parameters http://www.alice.org/resources/lessons/using-parameters/

Slides:



Advertisements
Similar presentations
Mike Scott University of Texas at Austin
Advertisements

Adventures in Animation Alice – Advanced! Michelle Venable-Foster June 2006.
Don Slater Wanda Dann
Chapter 9 Macros, Navigation Forms, PivotTables, and PivotCharts
01-Intro-Object-Oriented-Prog-Alice1 Barb Ericson Georgia Institute of Technology Aug 2009 Introduction to Object-Oriented Programming in Alice.
Microsoft Visual Basic 2005 CHAPTER 8 Using Procedures and Exception Handling.
Working with Numbers in Alice - Converting to integers and to strings - Rounding numbers. - Truncating Numbers Samantha Huerta under the direction of Professor.
Power Point EDU 271 Microsoft PowerPoint is a powerful tool to create professional looking presentations and slide shows. PowerPoint allows you to construct.
Programming Logic Program Design. Objectives Steps in program development Algorithms and Pseudocode Data Activity: Alice program.
STAY CONNECTED TOLLFREEEXPRESS CONTROL PANEL GUIDE.
Microsoft Visual Basic 2012 Using Procedures and Exception Handling CHAPTER SEVEN.
by Chris Brown under Prof. Susan Rodger Duke University June 2012
Branching and Looping Examples, cont’d. Remember the generic triple jump world…
Making a Timer in Alice.
Automating Tasks with Visual Basic. Introduction  When can’t find a readymade macro action that does the job you want, you can use Visual Basic code.
Nonvisual Arrays and Recursion by Chris Brown under Prof. Susan Rodger Duke University June 2012.
Teaching a character to walk in more than one world: Parameters and Inheritance. By Lana Dyck under the direction of Professor Susan Rodger Duke University.
Oracle Data Integrator Procedures, Advanced Workflows.
How to use the timing feature Click to choose a shape, then click on the screen and drag it to place in on the slide.
Website Editing From Gingerweb The Image Gallery.
View Controllers Content taken from book: “iPhone SDK Development” by Bill Dudney and Chris Adamson.
Microsoft Access 2013 ®® Tutorial 10 Automating Tasks with Macros.
Making a Timer in Alice By Jenna Hayes under the direction of Professor Susan Rodger Duke University July
Piñata Game: Keeping Score in Alice By Maggie Bashford Professor Susan Rodger Duke University July
Flow Control: boolean expressions, “if” selection statements (Alice In Action, Ch 4) Slides Credit: Joel Adams, Alice in Action CS 120 Lecture September.
Sub Procedures. A Sub procedure is a block of code that is executed in response to an event. There are two types of Sub procedures, general procedures.
Creating and Calling Procedures Alice 3 Beta. A few choices to be made Right window, upper left hand corner start by clicking on Class “MyScene” button.
Headshots in Alice Duke University Professor Susan H. Rodger Gaetjens Lezin July 2008.
Tutorial on Bunny visiting his animal friends - parameters, events for Alice 3 Susan Rodger Duke University June 2009 Updated by Yossra Hamid on October.
Product Training Program
Teaching Characters to Walk: Learning Methods, Part 1
Comparing objects and changing color
Using the HTML and CSS Validation Services
Text and Sound in Alice Worlds
Putting Objects in Motion
Making Objects Move in Unison: Using Lists
Tutorial on Kangaroo visiting his animal friends - parameters, events
Using Procedures and Exception Handling
Programming Logic Alice.
Introduction to Events
World-level Methods with Parameters
Using local variable without initialization is an error.
Learning Java with Alice 3.0 Game Design Kathy Bierscheid
Objectives Learn about Function procedures (functions), Sub procedures (subroutines), and modules Review and modify an existing subroutine in an event.
CS320n –Visual Programming
Programming using Alice 3
PRACTICE OVERVIEW PL/SQL Part - 2.
Making Objects Move in Unison: Using Lists
File Handling Programming Guides.
Using Objects in Alice.
Michelle Venable-Foster Barb Ericson Jan 2007
INTERMEDIATE PROGRAMMING LESSON
Making Procedural Methods
Alice Variables Pepper.
Passing Parameters by value
Parameters and World-level methods
Chapter 2: Programming in Alice
Making Objects Move in Unison: Using Lists
Arrays
Checking for Collisions: Using Functions in Alice
Using Functions
Princess & Dragon Part 3: A Knight Comes Riding In—Cameras & Events
Introduction to Object-Oriented Programming in Alice
How Tall Are You? Introducing Functions
PRACTICE OVERVIEW PL/SQL Part - 1.
Headshots in Alice Duke University Professor Susan H. Rodger
Using Placeholders to Simplify your Methods: Learning Methods, Part 2
Making Objects Move in Unison: Using Lists
Chapter (3) - Procedures
under the direction of Professor Susan Rodger
Presentation transcript:

Using Parameters http://www.alice.org/resources/lessons/using-parameters/

Using Parameters What is a Parameter A parameter is used to pass information to a procedure when the procedure is used (invoked) Most built-in Alice statements use parameters move parameters are: direction, distance turn parameters are: direction, turn amount A parameter allows you to pass information between methods including between methods of different classes

Using Parameters Why Use Parameters A parameter can be used to broaden the use of custom methods by allowing you to customize the behavior when it is used - much like our built in move and turn. A parameter can be used to pass data between methods such as passing outputs of events into handler methods making methods aware of variables

Using Parameters Adding Parameters To add a parameter to a method click the add parameter button found at the top of the method tab.

Using Parameters Parameter Data Type Select the type of data that you will pass through the parameter. The available data types will vary depending on where it is being added. When using gallery classes it is important to choose the right level of class to insure all of the classes you want to pass will be possible.

Using Parameters Naming Your Parameter Be sure to name your parameter in a way that you will know how the data will be used to modify the custom method such as: textBubbleText moveToTarget Examples from built in procedures are: distance direction target

Using Parameters Parameter Declaration A parameter declaration consists of: <type> <parameterName> example: <SSphere> < target>

Using Parameters Using the Parameter The declared parameter is then used as a representational placeholder (variable) in the code developed in the method. Whatever value is given to the parameter when the method is called will replace this variable. You can access the parameter in drop downs for parameters that match the data type or you can drag the parameter into the program where you would like the argument to be passed. The data type of the parameter will dictate where you will be able to add the parameter variable.

Using Parameters Required Argument Once you have added a parameter you will see it is now a required parameter when using the custom method. The data given for the parameter will then be passed through the parameter into the custom method and used where it is has been added to your custom method statements.

Using Parameters Parameter Warning If you add a parameter after you have invoked the custom method you will receive a warning that there will be procedures with unset parameters. You can chose to ignore this warning but you should be sure to go and update the existing uses or they will create errors where the procedures don’t have the required information to successfully perform the intended action.

Using Parameters Thor Greeting Guests We created a greeting procedure to allow us to reuse the arm wave and text greeting for each guest that joined the party. However if Thor says “howdy” to every guest as they arrive he will start to sound like a broken record. What if we want to reuse the greeting method each time but we want to customize what he says?

Using Parameters Customizable Greeting We can add a parameter for the text to allow us to change the included text each time the custom method is used. Now each time you use the greeting procedure you will be asked to add text to fulfill the expected argument.