You are previewing TouchDevelop: Programming on the Go, Third Edition.
O'Reilly logo
TouchDevelop: Programming on the Go, Third Edition

Book Description

"The book is great! It's clear and easy to read, with loads of examples that showed my students what to do."

-- Larry Snyder, Emeritus Professor, University of Washington, Department of Computer Science and Engineering

"Having the TouchDevelop book available made our events so much easier. Students could figure things out for themselves with help from the book."

-- Jennifer Marsman, Microsoft Principal Developer Evangelist

Mobiledevices such as smartphones and tablets are set to become the main computersthat virtually all people will own and carry with them at all times. And yet,mobile devices are not yet used for all computing tasks. A project at MicrosoftResearch was created to answer a simple question: "It is possible to createinteresting apps directly on a smartphone or tablet, without using a separatePC or a keyboard?" The result is TouchDevelop, a programming environment thatruns on all modern mobile devices such as Windows Phone, iPhone, iPad, Androidphones and tablets, and also on PCs and Macs.

This book walks you through all of the screens of the TouchDevelop app, and itpoints out similarities and differences of the TouchDevelop language comparedto other programming languages. For users, the book can serve as a handyreference next to the phone. The book systematically addresses all programminglanguage constructs, starting from the very basic constructs such as variablesand loops. The book also explores many of the phone sensors and data sourceswhich make creating apps for mobile devices so rewarding.

If you are new to programming with TouchDevelop, or if you have not yet workedon touchscreen devices, we suggest that you read the book starting from Chapter1. If you are already familiar with the basic paradigm of the TouchDevelopprogramming environment, then feel free to jump ahead to the later chaptersthat address particular topic areas.

This book is written from theperspective of a person developing their code using a web browser. TheTouchDevelop Web App runs in many modern browsers on many different devicesincluding smartphones and tablets, Macs, PC. All screenshots and navigationinstructions refer to the TouchDevelop Web App running in a browser. ForWindows Phone, there is a dedicated TouchDevelop app in the Windows Phone Storewhich gives access to many more sensors and data sources. Starting with theTouchDevelop app v3.0 for Windows Phone 8, the phone app will share the samelook and navigation structure and all features of the Web App.

What you'll learn

  • The little tricks to programming on your mobile devices and for a mobile device

  • The scripting language and cloud-based ecosystem

  • Using cameras, video and audio, and other sensors such as a microphone, accelerometer, compass, and gyroscope

  • Access to the web, authorized access to web services

  • How to write simple games using a built-in physics engine

Who this book is for

This programming language was written for people who wish tobe able to create apps from their phone. This scenario is particularlyappealing to enthusiastic end-users who own mobile devices and students, whoare the target audience of this book.

Table of Contents

  1. Title Page
  2. Contents
  3. Preface
    1. Who this book is for
    2. Background to the book
    3. Other learning materials
    4. Acknowledgments
    5. Important websites
    6. The TouchDevelop Team
  4. List of figures
  5. List of tables
  6. Chapter 1: Introduction to TouchDevelop
    1. 1.1 Computers want to be programmed
    2. 1.2 What is TouchDevelop?
    3. 1.3 The TouchDevelop ecosystem
    4. 1.4 History and Future
    5. 1.5 Platforms
    6. 1.6 The scripting language
  7. Chapter 2: The Scripting Language
    1. 2.1 Introduction – the language flavor
    2. 2.2 Datatypes and variables
    3. 2.3 Expressions
    4. 2.4 Statements
    5. 2.5 Actions
    6. 2.6 Events
    7. 2.7 Pages
    8. 2.8 Creating library scripts
  8. Chapter 3: The Wall – using the screen
    1. 3.1 Output – the writing on the wall
    2. 3.2 Input of values from the touchscreen
    3. 3.3 Updating the wall’s content
    4. 3.4 Events on the touchscreen
    5. 3.5 Pushing and popping pages
    6. 3.6 Titles and subtitles
    7. 3.7 Wall buttons
    8. 3.8 On-demand creation of output
  9. Chapter 4: The Web
    1. 4.1 URLs and webpages
    2. 4.2 Downloading and uploading files
    3. 4.3 Downloading structured data
    4. 4.4 REST guidelines and web requests
  10. Chapter 5: Audio
    1. 5.1 Music
    2. 5.2 Sounds
    3. 5.3 Microphone
  11. Chapter 6: Camera, Graphics and Video
    1. 6.1 Camera
    2. 6.2 Working with pictures
    3. 6.3 Static graphics drawing and display
    4. 6.4 Playing videos from the internet
  12. Chapter 7: Sensors
    1. 7.1 The sensors
    2. 7.2 Sensor-driven events
    3. 7.3 Accelerometer
    4. 7.4 Compass
    5. 7.5 Gyroscope
    6. 7.6 Motion
  13. Chapter 8: Interactions
    1. 8.1 Social messages
    2. 8.2 Locations, places, maps
    3. 8.3 Emails
    4. 8.4 Phone Calls
    5. 8.5 2D barcodes
    6. 8.6 SMS messages (WP8 only)
    7. 8.7 Calendar and appointments (WP8 only)
    8. 8.8 Contacts (WP8 and Android only)
  14. Chapter 9: Game Board
    1. 9.1 Introduction
    2. 9.2 The Board datatype
    3. 9.3 The Sprite datatype
    4. 9.4 The Sprite Collection datatype
    5. 9.5 Touching and board events
    6. 9.6 Debugging games
  15. Chapter 10: UI with Boxes and Pages
    1. 10.1 Page Overview
    2. 10.2 Box Overview
    3. 10.3 Examples of Boxes and Pages
    4. 10.4 Working with Pages
    5. 10.5 Live Editing of the User Interface
    6. 10.6 API Support for Boxes and Pages
  16. Chapter 11: Authenticating Web Services
    1. 11.1 Registering your app
    2. 11.2 Authenticating
    3. 11.3 Libraries
    4. 11.4 Advanced topics
  17. Appendix A: Editing TouchDevelop Scripts
    1. A.1 The starting point
    2. A.2 The editing steps
    3. A.3 Additional steps
    4. A.4 More advanced editing features
  18. Appendix B: TouchDevelop Services
    1. B.1 bazaar
    2. B.2 box
    3. B.3 collections
    4. B.4 colors
    5. B.5 contract
    6. B.6 invalid
    7. B.7 languages
    8. B.8 locations
    9. B.9 maps
    10. B.10 math
    11. B.11 media
    12. B.12 phone
    13. B.13 player
    14. B.14 senses
    15. B.15 social
    16. B.16 tags
    17. B.17 tile
    18. B.18 time
    19. B.19 wall
    20. B.20 web
  19. Appendix C: TouchDevelop Datatypes
    1. C.1 Appointment
    2. C.2 Appointment Collection
    3. C.3 Board
    4. C.4 Boolean
    5. C.5 Camera
    6. C.6 Color
    7. C.7 Contact
    8. C.8 Contact Collection
    9. C.9 DateTime
    10. C.10 Form Builder
    11. C.11 Json Builder
    12. C.12 Json Object
    13. C.13 Link
    14. C.14 Link Collection
    15. C.15 Location
    16. C.16 Location Collection
    17. C.17 Map
    18. C.18 Matrix
    19. C.19 Message
    20. C.20 Message Collection
    21. C.21 Motion
    22. C.22 Number
    23. C.23 Number Collection
    24. C.24 Number Map
    25. C.25 OAuth Response
    26. C.26 Page
    27. C.27 Page Button
    28. C.28 Page Collection
    29. C.29 Picture
    30. C.30 Picture Album
    31. C.31 Picture Albums
    32. C.32 Pictures
    33. C.33 Place
    34. C.34 Place Collection
    35. C.35 Playlist
    36. C.36 Playlists
    37. C.37 Song
    38. C.38 Songs
    39. C.39 Song Album
    40. C.40 Song Albums
    41. C.41 Songs
    42. C.42 Sound
    43. C.43 Sprite
    44. C.44 Sprite Set
    45. C.45 String
    46. C.46 String Collection
    47. C.47 String Map
    48. C.48 TextBox
    49. C.49 Vector3
    50. C.50 Web Request
    51. C.51 Web Response
    52. C.52 Xml Object
  20. Appendix D: Platform Capabilities
    1. D.1 Supported Browsers
    2. D.2 General Features
    3. D.3 Supported Sensors and Devices
    4. D.4 Support for Services/Resources
    5. D.5 Support for Created Apps
  21. Appendix E: TouchDevelop Editor on a Windows Phone
    1. E.1 The sample program
    2. E.2 The back button, undo and mistakes
    3. E.3 The editing example
    4. E.4 Additional steps
    5. E.5 Refactoring code into a new action
  22. Index