introduction to touchdevelop statements overview disclaimer: this document is provided “as-is”....

Download Introduction to touchdevelop statements overview Disclaimer: This document is provided “as-is”. Information and views expressed in this document, including

If you can't read please download the document

Upload: bertram-allison

Post on 17-Jan-2018

224 views

Category:

Documents


0 download

DESCRIPTION

introduction to touchdevelop adding o tap one of the + in the statement menu o tap intended statement button

TRANSCRIPT

introduction to touchdevelop statements overview Disclaimer: This document is provided as-is. Information and views expressed in this document, including URL and other Internet Web site references, may change without notice. You bear the risk of using it. This document does not provide you with any legal rights to any intellectual property in any Microsoft product. You may copy and use this document for your internal, reference purposes. 2012 Microsoft Corporation. All rights reserved. Microsoft, Windows, and Windows Live are trademarks of the Microsoft group of companies. All other trademarks are property of their respective owners. introduction to touchdevelop statements o expression statement o if then else o for each [var] in where do o for 0 [var] < do o while do o // comments o do nothing introduction to touchdevelop adding o tap one of the + in the statement menu o tap intended statement button introduction to touchdevelop editing o first, enter condition/bound/ collection o tap the hardware back button when done introduction to touchdevelop editing o to modify condition/bound/collection, select entire expression o to modify body, select statement in body introduction to touchdevelop expression statement o any expression is a statement o unassigned expression results are simply forgotten introduction to touchdevelop if then else o empty else-branch is shown in compact form, but cannot be removed introduction to touchdevelop for each [var] in where do o iterates over a collection actually equivalent to a loop from i :=0 to (collectioncount-1), assigning collectionat(i ) to loop variable [var] in each iteration o iteration variable is automatically synthesized to rename it, use it in the body, tap on it, and rename o use where clause to filter, if desired equivalent to if, but more efficient o example: for each song in media songs where songduration > 180 do songpost to wall introduction to touchdevelop demo / exercise lets write this script: for each song in media songs where songduration > 180 do songpost to wall introduction to touchdevelop for 0 [var] < do o iterates from 0 (includes) to an upper bound (exclusive) o iteration variable is automatically synthesized to rename it, use it in the body, tap on it, and rename o example: for 0 i < 4 do ipost to wall prints introduction to touchdevelop for 0 [var] < do o surprised by the ordering on the wall? try this: for 0 i < 4 do ipost to wall timesleep(1) introduction to touchdevelop while do o executes loop body while condition is true o example: i := 0 while i < 4 do i post to wall i := i + 1 prints introduction to touchdevelop demo / exercise lets write this script: i := 0 while i < 4 do i post to wall i := i + 1 introduction to touchdevelop scope o in the app, scope is indicated by indentation (and gray lines) o to add a statement in a particular scope, select an existing statement in that scope, and tap + introduction to touchdevelop // comments o comments do nothing o (unlike many other language, comments are maintained in the abstract syntax tree to play nice with the editor) introduction to touchdevelop do nothing o place holder statement introduction to touchdevelop title o item 1 o item 2 songpost to wall anecdote (link to sample)http://touchdevelop.com/velk an exercise a reference