Presentation is loading. Please wait.

Presentation is loading. Please wait.

Programming on the Go Chapters 1and 2 Siddharth Patel 1000773753.

Similar presentations


Presentation on theme: "Programming on the Go Chapters 1and 2 Siddharth Patel 1000773753."— Presentation transcript:

1 Programming on the Go Chapters 1and 2 Siddharth Patel 1000773753

2 INSTALLING TOUCHDEVELOP SCRIPTING LANGUAGE IMPORTANT WEBSITES Administrator INTRODUCTION

3 What Is Touchdevelop-definition TouchDevelop is an application development environment which allows users to script and design applications their mobile devices. The apps developed using Touchdevelop can use sensors, media, data on mobile, tablets or PC The scripts can interacts with cloud services including storage computing and social networks. What Can Be Done Using Touchdevelop? Games,productive apps, personalized phone …

4 In future smartphone might me the only computing device. SMARTPHONECAPABILITIES YesTEXT YesTALK YesEMAIL YesGAMES YesNAVIGATION NoPROGRAMMING

5 Traditional Mobile App Development Technique Use Computer to make mobile App Download APIs, SDK or need specific software For testing on mobile connect phone to computers Share project with teammates using hosting server

6 Touchdevelop Benefits and Challenges No specific device need No need to install huge SDKs for do specific settings. Share project or scripts with teammates on touchdevelop itself Benefits Challenges Mobile Phone Small Screen No Keyboard Touch screen interface as input

7 Installing Touchdevelop on a Windows Phone 1.Tap the Marketplace tile on the Windows phone. 2. Press the search icon at the bottom of the screen, and type the text ‘touchdevelop’ into the Marketplace Search text box. Before you finish typing all the letters, the TouchDevelop app should appear as a choice on the screen. 3.Tap that choice to select it. 4. Tap Install.

8 Installing Touchdevelop on Other Platforms Touchdevelop runs on web browser on any device Supported Browsers IE 10 Chrome(mobile) Firefox Safari(mobile) 1.Go to https://www.touchdevelop.com/app/#https://www.touchdevelop.com/app/# 2.Log in and that’s it!

9 The TouchDevelop Ecosystem the script can be shared on cloud infrastructure A user can share, comment, like the scripts User can find scripts in different categories like new, top featured, installed.

10 The Web interface It’s the same as the phone interface Mouse Keyboard Larger screen helps to increase productive to user might prefer the web interface but the PC may not have all the sensors like phone (GPS). Demo

11 The Scripting Language Statement oriented. Statements are executed in a sequential manner. The language is strongly typed. Its not an object oriented language.

12 Data types The Invalid Value: every data type has special value as Invalid value, it is assigned to show that the global variable has not been initialized or the method was unable to return the value. Example var numUsers := 0 … if connection failure detected then numUsers := invalid → number else … if numUsers → is invalid then “Script is terminating” → post to wall else The Invalid Type The Nothing Type A method or an operation which does not return a usable result, but which otherwise succeeded, actually returns a value of type Nothing. The sole value of type Nothing does not require any storage. Therefore this type is neither a value type nor a reference type. It is a special case.

13 Data types contd. Value Type Value types storages on the stack used for local variables. The storage is automatically deallocated on exit from an action.(Actions is called functions in other langualges ). Number: combines the integer and floating-point IEEE 754 (plus infinity, minus infinity can be computed) String : A sequence of zero or more Unicode characters. Showed as doublequote and backslash are used for special characters. Boolean: The type whose constants are true and false.

14 Data types contd. Value Type

15 Reference Type Global defined variables are stored as Reference Type. Storage for an instance of a reference type is allocated in a different place from a variable declared with that type. A local variable with a reference type is implemented as a pointer (a reference) to the actual value which is stored elsewhere. If the value represents any entity which exists outside TouchDevelop, then storage is allocated outside the TouchDevelop application. Otherwise the storage is allocated within an area of memory controlled by TouchDevelop which is called the heap. Data types contd.

16 Reference Type Data types contd.

17 Reference Type Data types contd.

18 Reference Type Data types contd.

19 Collection Types Touchdevelop provides homogeneous collections. A collection contains zero or more elements whose type is one of the value types or one of the reference types Collections which allow to insert or delete an element is called mutable, others are immutable. Data types contd.

20 Art Items Some scripts need to display pictures or to produce sounds. These pictures or sounds can be added to the script as global constants and become part of the script. Such items are held in the Art section of the script.

21 Expressions Explicit Constants Number constants are regular IEEE 754 standard 64 bit floating point numbers. String constants can be entered using Touchdevelop editor and string is implemented as Sequence of Unicode characters. Named Constants Touchdevelop has mechanism to construct constants for color and sounds. Such constants are called name constants. Demo

22 Variables Local Variables Local variables follow the usual visibility rules and lifetime rules for block structured languages. var s1 := “Hello!” Global Data Variables The data section of a script contains declarations for variables which are accessible by all actions within the script. If the type is Number, Boolean, String or DateTime, the variable has a neutral initial value. It is 0, false, “” or 1 January 0001 12:00 am respectively. For any other datatype, the initial value is invalid. An access to a global data variable inside a script uses the special symbol. game := media → create board(480)

23 Operators

24 Operators Contd..

25 Statements Expression: Any expression may be used as a statement. For example, this is a valid statement. (“Hello “ || “ there!”) → post to wall Declaration and Assignment: A declaration of a local variable is combined with an assignment to initialize the variable. var places := collections → create location collection If an action has more than one return parameter. var street name := “” var street number := 0 street name, street number := ▷ Get Address Info(“Joanie”) If Statement: The TouchDevelop editor always generates the if-then-else form for an if statement, supplying empty bodies for the then clause and the else clause. if a < b then if a < c then min := a else min := c else if b < c then min := b else min := c

26 Statements Contd.. While Loop: while loop has a controlling expression which must evaluate to a Boolean value. The loop body is repeatedly executed as long as the controlling expression evaluates to true. var long song := invalid → song var my music := media → songs var num songs := my music → count var i := 0 while i < num songs and long song → is invalid do var sng := my music → at(i) if sng → duration > 10*60 then long song := sng else // nothing i := i + 1 For Loop: The for loop in TouchDevelop is similar to for loops in other programming Languages, but with some added constraints. The index variable must be a Number; it must be initialized to zero for the first iteration and it must be incremented in steps of one. For Each Loop: A for each loop is used for iterating through all the elements of a collection.

27 Actions Actions are basically the function of other languages. An action can have zero or more input parameters and zero or more result parameters. For example, consider the action Replicate defined as follows. action Replicate( s: String, n: Number ) returns r: String r := “” while n > 0 do r := r || s n := n – 1 The action can be invoked and its resulting value used in a statement like the following. (“The answer is “ || ▷ Replicate(“NO! “, 10) || “forever!”) → post to wall When an action is invoked, each result parameter is initialized to an invalid value of the correct type. When control reaches the end of the action, the final values of the result parameters are returned as the results of the call.

28 Calling a Library Action An action can be invoke action in a script which has been declare as library. Each such library script must be added to the library section of the script. When editing code in the script, the editor provides a button labeled libs. Tapping this key inserts the symbol into the code and the editor then provides a choice between the various names used for the imported library scripts. Once a name has been selected, the editor allows any action in that library script, other than those marked as private, to be called. There is no direct access to any global data items or art items declared in the script. Creating Library Scripts While editing the property of a script tick to the check box option library converts the script in to library. A library script cannot define any entries in its Events or Records sections.

29 Events Events are like actions. They cannot be invoked they must invoke when some external action happens. It might be phone sensors, like shaking the phone or touch to a particular area. An event will interrupt the normal execution of a script. However an event will never interrupt the code for another event while it is still executing.

30

31 IMPORTANT WEBSITES https://www.touchdevelop.com/app/# http://research.microsoft.com/en-us/projects/touchdevelop/ https://www.touchdevelop.com/slides https://www.touchdevelop.com/learn REFERENCES 1.https://www.touchdevelop.com/bookhttps://www.touchdevelop.com/book 2.introduction to touchdevelop presentation at https://www.touchdevelop.com/slidesintroduction to touchdevelop

32


Download ppt "Programming on the Go Chapters 1and 2 Siddharth Patel 1000773753."

Similar presentations


Ads by Google