Working with Strings and Text in Alice



Similar documents
Importing Contacts to Outlook

Objects in Alice: Positioning and Moving Them

BOOLEAN LOGIC IN PROGRAMMING

AN INTRODUCTION TO ALICE AND OBJECT-ORIENTED PROGRAMMING

2 Programming in Alice: Program Design and Implementation

TUTORIAL: BOARDMAKER STUDIO START-UP

University of Hull Department of Computer Science. Wrestling with Python Week 01 Playing with Python

Sample only. Unit 4a Lesson 1: Pop game 50 minutes. Cross-curricular links. Overview. Learning objectives. Success Criteria. Key words. 1.

CAPITAL V8. Capital Business Software Tutorial Series. Introduction to Capital Business Manager V8 User Interface 1.2

First Bytes Programming Lab 2

Word basics. Before you begin. What you'll learn. Requirements. Estimated time to complete:

SPSS Workbook 1 Data Entry : Questionnaire Data

A capacity planning / queueing theory primer or How far can you go on the back of an envelope? Elementary Tutorial CMG 87

Introduction to Microsoft Access XP

GETTING STARTED: Office365 OneDrive for Business

Document Versions in ProjectWise

Sources: On the Web: Slides will be available on:

Using SPSS, Chapter 2: Descriptive Statistics

Getting Started with Crystal Reports Session Description:

Microsoft Excel Tips & Tricks

Search help. More on Office.com: images templates

Tutorial. Reference Genome Tracks. Sample to Insight. November 27, 2015

Automate tasks with Visual Basic macros

Connecting System Platform to TOP Server. Using the SuiteLink DI Object

Maths Workshop for Parents 2. Fractions and Algebra

WIX: Building a Website with a Template. Choosing a Template First you will need to choose a template from the Create section of the Wix website.

DESIGNING YOUR WEBSITE. The following guide will show you how to setup your music website using

Creating a New Search

Scrolling Tutorial For The Games Factory 2 / Multimedia Fusion 2

SCHOOL LOOP TRAINING - IMPORTANT CONCEPTS

Ohio University Computer Services Center August, 2002 Crystal Reports Introduction Quick Reference Guide

15.0. Percent Exceptions

Excel Reports and Macros

Add a custom a color scheme

Like any function, the UDF can be as simple or as complex as you want. Let's start with an easy one...

Handout 1. Introduction to Java programming language. Java primitive types and operations. Reading keyboard Input using class Scanner.

Lab 7 Keyboard Event Handling Mouse Event Handling

Citrix Single Sign-On Self-Service Password Reset

GOOGLE DOCS APPLICATION WORK WITH GOOGLE DOCUMENTS

Character Animation Tutorial

Microsoft Office 365 Portal

Notepad++ The COMPSCI 101 Text Editor for Windows. What is a text editor? Install Python 3

Arena Tutorial 1. Installation STUDENT 2. Overall Features of Arena

MS Excel Template Building and Mapping for Neat 5

Creating Electronic Portfolios using Microsoft Word and Excel

Analytics Canvas Tutorial: Cleaning Website Referral Traffic Data. N m o d a l S o l u t i o n s I n c. A l l R i g h t s R e s e r v e d

How to Edit Your Website

CS 1133, LAB 2: FUNCTIONS AND TESTING

Access Part 2 - Design

HRIS On - Demand Report Training

Working with forms in PHP

Exporting to DVD with EDIUS

SYMETRIX SOLUTIONS: TECH TIP August 2015

Hands-on Exercise 1: VBA Coding Basics

Quick Start Guide: Mac vpad September 2007

Internet and Computing Core Certification Guide Module A Computing Fundamentals

University of Southern California Marshall Information Services

13 Reading Device/PLC from Database

Creating Stop Motion Animation in Corel VideoStudio Pro

VHDL Test Bench Tutorial

How-to Guide: Creating a Mobile Website Using bmobilized

BAR CODE 39 ELFRING FONTS INC.

First Certificate in English Online Practice Test Free Sample. How to complete the FCE Online Practice Test Free Sample: Writing

Blender Notes. Introduction to Digital Modelling and Animation in Design Blender Tutorial - week 9 The Game Engine

Gmail Merge. Step 1: Writing the actual e mail

Teaching Pre-Algebra in PowerPoint

User Guide. Chapter 6. Teacher Pages

The Center for Teaching, Learning, & Technology

5. At the Windows Component panel, select the Internet Information Services (IIS) checkbox, and then hit Next.

Automatic Scheduling Using AutoTrack Command Line Options

Reduced Quality Sample

Create an ios App using Adobe Flash Side by Side Training, And without using a Mac

Time Clock Import Setup & Use

Created With ScreenSteps Trial

4. You must link at least one student before you can create a user profile for yourself.

Microsoft Access 2010 Overview of Basics

First Java Programs. V. Paúl Pauca. CSC 111D Fall, Department of Computer Science Wake Forest University. Introduction to Computer Science

ANCS+ 8.0 Remote Training: ANCS+ 8.0, Import/Export

ASCII Encoding. The char Type. Manipulating Characters. Manipulating Characters

Outline. hardware components programming environments. installing Python executing Python code. decimal and binary notations running Sage

Advisor Workstation Quick Start Guide

Getting Started in Fireside21

Creating Your PALS Online Account for New Teachers Navigate to the PALS Online homepage

Software Requirements Specification

Real Vision Software, Inc. Create a Spool File Capture

Batch and Import Guide

Studio Manager Manual

Bioinformatics Resources at a Glance

Scheduling WebEx Meetings

Introduction to Python

Operating Systems. and Windows

What is File Management. Methods for Categorizing Data. Viewing Data on a Computer

Database Applications Microsoft Access

Microsoft Migrating to Access 2010 from Access 2003

Some past questions and guidance on answering

Transcription:

A string is a sequence of characters, while a character is (in general) any of the letters, numbers, or symbols represented on your keyboard. In computer programs, strings are used to represent very common and useful information such as names, addresses, messages, and many others. Alice provides various features for dealing with strings. In this tutorial, we will consider the following: 1. Variables to hold strings 2. Asking the user to enter a string 3. Joining two or more strings together 4. Converting a non-string to a string 1. Variables to Hold Strings So far, we have been creating world variables, and will continue this practise as we learn about strings. To create a world variable, use the create new variable button at the top of the world.my first method program window, as shown. Page 1 of 5

Create a new world using the grass template. Add the an instance of the plato object from the galleries. Position Plato in the middle of the scene and have him face the camera. R ather than trying to move the camera around, you could right click on p lato and use the p rimitive method called p lato turn to face camera. Create a new variable called name of type string. 2. Asking the U ser to E nter a String In a previous tutorial, we asked the user to enter a number. N ow we will ask the user to enter a string, which is a very similar process. There is a world function called ask user for a string, which prompts the user with a q uestion, and the user's response is returned as a string. W e will store this string in the variable called name. D rag the variable name into the programming window, where we will set value to d e fau lt strin g for now. Instead of the d e fau lt strin g, we want to have name set by the user's input. F ind the world function called ask user for a string and drag it into the programming window to replace d e fau lt strin g. Change the q uestion to W hat is your name?. N ow have Plato repeat the name back to the user using plato's say method. Page 2 of 5

3. J oining Two Strings Together It is often useful to join strings together, which is accomplished using the world function called a joined with b, where a and b are the strings to be joined together. The string output in our current world could use some improvement. After asking the user their name, it simply says the name back to the user. Perhaps a H ello followed by the name might be a bit more useful. D rag the a joined with b function to replace the name variable in the plato say... method. Set the first string (a) to be H ello, and set the second string (b) to be the name variable. R un the world. Y ou may have noticed that it doesn't look q uite right. M ost programming languages do not make assumptions about things like punctuation or spacing with strings. If you want them, you need to provide them yourself. M odify the first string (a) to be H ello, making sure you include a space at the end. N ow run the program and it should look more like what you ex pect. Page 3 of 5

4. C onverting a N on-string to a String Working with Strings and Text in Alice It is often necessary to display information that is not a string (e.g., numbers). Although many languages allow this automatically, Alice req uires all displayed information to be a string. There are two p rimitive methods for displaying information: think and say. B oth of these methods only accept string arguments as their p arameters. To convert any other type of variable to a string, use the what as a string world function. L et us modify our world so that plato also performs a (number) calculation, and then tells us the answer. W e will need to convert his numeric answer into a string. Create two new world variables, both of which will be numbers. Call the first one userprice and the second one platoprice. W e are going to use these to do some haggling with Plato. Initializ e the new variables to z ero. Y ou might have noticed that Plato is holding an object in his hand. L et's assume he wants to sell us this object. H e will ask the user their price (that they want to pay), and then he will calculate his own price, which is three times higher, which he will tell the user. D rag the userp rice variable into the programming window and set value to the world function ask user for a number. Since Plato seems to be holding out the object in his hand, have him ask, H ow much will you give me for this? Plato is a bit greedy, so he thinks the object in his hand is worth three times as much as you do. Set the value of the p latop rice variable to be three times as much as userp rice using a mathematical exp ression. Page 4 of 5

F inally, have Plato tell you his price using the plato method say. Since you cannot display a number in Alice, you will need to convert it to a string using the what as a string world function. Plato isn't communicating this new price very well. See if you can improve this by using the world function called a joined with b. Y ou final program should look very similar to this: Page 5 of 5