Upcoming SlideShare
×

# 04 meme script

538
-1

Published on

Meme IDE Training Material

0 Likes
Statistics
Notes
• Full Name
Comment goes here.

Are you sure you want to Yes No
Your message goes here
• Be the first to comment

• Be the first to like this

Views
Total Views
538
On Slideshare
0
From Embeds
0
Number of Embeds
0
Actions
Shares
0
2
0
Likes
0
Embeds 0
No embeds

No notes for slide

### 04 meme script

1. 1. Meme Script● Type System● If, while etc● Dates, times, strings
2. 2. Meme Script Examplevar x = 10;var y = 20;var z : Integer;z = x + y;notify(z);
3. 3. Meme IDE Function Editor
4. 4. Primitive Types● Integer 10, -234● Decimal 1.23● String “ABC”● Boolean true, false
5. 5. Declaring Integer Variables● Local variables within functionsvar x : Integer;var x2 = 1;
6. 6. Declaring Decimal Variablesvar d : Decimal(2);var d2 = 1.23;
7. 7. Declaring Boolean Variablesvar b : Boolean;var b2 = true;
8. 8. Declaring Stringsvar s : String;var s = “abc”;
9. 9. Default Initializations● String - empty string “”● Integer and Decimal – 0● Boolean – false
10. 10. Pre-defined Complex Types● Date – day, month, year● Time – hour, minute, second● Duration – hour, minute, second● Timestamp
11. 11. IFvar a = 15;if (a > 10){ notify(“A is big”);}
12. 12. IF / ELSEvar a = 15;if (a > 10){ notify(“A is big”);}else{ notify(“A is small”);}
13. 13. IF / ELSIF / ELSE notify(“A is small”);} notify(“A is big”);}elsif (a > 5){ notify(“A is medium sized”);}else{ notify(“A is small”);}
14. 14. WHILEvar x = 0;while (x < 10){ x++; // do other things}
15. 15. FORvar names : String[];append(names, "Jack");append(names, "Jill");append(names, "Jane");for (name in names){ notify(name);}
16. 16. Arithmeticvar c = 20;f = c * (9.0 / 5.0) + 32;notify(f);
17. 17. Logical Operatorsvar x = 10;if ((x > 10) and not (x > 20)){ notify(“x is middle sized”);}
18. 18. Dataspace
19. 19. Defining a Person Record
20. 20. Adding Attributes to the Person Record
21. 21. Naming ConventionsRecord Type Names● bumpy case with initial uppercase,● - E.g. Person or EmployeeDetailsAttribute names in records● - bumpy case with initial lowercase● - E.g. name or firstName
22. 22. Defining an Address Record
23. 23. Adding List of Addresses to Person
24. 24. Creating a Person Recordvar p : Person;var a : Address;a.line1 = "12 Hight St";a.zip = "PA 12345";p.name = "Simon";p.tel = "1234567";append(p.addresses, a);
25. 25. Dot Notationnotify(p.addresses[0].line1);p.addresses[0].line1 = "13 High St"
26. 26. String Concatenationvar s1 = "The Start"var s2 = "The Middle"var s3 = "The End"var result = s1 + ", " + s2 + ", " +s3 + ". " + 3 + " parts.";The Start, The Middle, The End. 3 parts.
27. 27. String Comparisonvar s1 = "String 1";var s2 = "String ONE";if (s1 == s2){ notify("Yes");}
28. 28. String Utilities● Boolean startsWith(sourceString, matchString)● Boolean endsWith(sourceString, matchString)● String subString(sourceString, startPos, length)● Integer size(sourceString)● String toLower(sourceString)● String toUpper(sourceString)● String trim(sourceString)● String replaceAll(sourceString, matchString, replacementString)● String replaceFirst(sourceString, matchString, replacementString)● String replaceLast(sourceString, matchString, replacementString)
29. 29. Collectionsvar people : Person[];var names : String[];append(names, "Fred");append(names, "Jane");
30. 30. INSERTvar people : Person[];var names : String[];append(names, "Fred");append(names, "Jane");insert(names, "Joe", 0);
31. 31. Collections and []var people : Person[];var fred : Person[];fred.name = "Fred";fred.tel = "12345";people.append(fred);var jane : Person[];jane.name = "Fred";jane.tel = "12345";people.append(jane);
32. 32. Removing from a Collectionvar people : Person[];var fred : Person[];fred.name = "Fred";fred.tel = "12345";people.append(fred);remove(people, fred);notify(people[1].name);
33. 33. Date and Time Types● Date - day, month, year● Time - hour, minute, second● Duration - hour, minute, second● Timestamp
34. 34. Date and Time Arithmeticvar t : Time;t = timeNow();var dt : Duration;dt.hour = 1;t = addTime(t, dt);
35. 35. Date and Time Utilities● dateNow()● timeNow()● setDate(Date, year, month, day)● setTime(Time, hour, min, sec)● addDays(Date, days)● dayOfWeek(Date)● monthOfYear(Date)● formatDate(Date, formatString)● formatTime(Time, formatString)● formatTimestamp(Timestamp, String)
36. 36. Date FormattingCode Description Example Resultd Day of the month without leading zero “1”dd Day of the month with leading zero “01”ddd The localised name for the day of the week “Sunday”m Month of the year without leading zero “1”mm Month of the year with leading zero “01”mmm The localised short (3 letter) name for the month “Jan”mmmm The localised full name for the month “January”yy The year as two digits “10”yyyy The year as four digits “2010” var today : Date; today = dateNow(); formatDate(today, “mmm d, yyyy”); “January 1, 2011”
37. 37. Time FormattingCode Description Example resultHHH Hour in 24 hour format with leading zero 19HH Hour in 24 hour format with leading zero 08H Hour in 12 hour format without leading zeros 8MM Minute with leading zero 05M Minute without leading zero 5SS Seconds with leading zero 09S Seconds without leading zero 9PP am / pm indicator am var t : Time; t = timeNow(); formatTime(t, “HH:MM:SS PP”); “12:34:10 am”
38. 38. Questions?
1. #### A particular slide catching your eye?

Clipping is a handy way to collect important slides you want to go back to later.