MemeScript Language

2,297 views
2,137 views

Published on

This is the downloadable development resource shown in the video tutorial 102- Introduction to MemeScript. For any mobile app developers currently using or considering using adopting Meme IDE.

find out more
http://www.memeapps.com/

0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total views
2,297
On SlideShare
0
From Embeds
0
Number of Embeds
656
Actions
Shares
0
Downloads
11
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

MemeScript Language

  1. 1. introduction to102 - MemeScript Prerequisites 101 - Hello Meme IDE
  2. 2. 1Contents2 MemeScript Example 21 Naming Conventions3 Meme IDE Function Editor 22 Defining an Address Record4 Primitive Types 23 Adding List of Addresses to Person5 Declaring Integer Variables 24 Creating a Person Record6 Declaring Decimal Variables 25 ‘Dot’ Notation7 Declaring Boolean Variables 26 String Concatenation8 Declaring Strings 27 String Comparison9 Default Initializations 28 String Utilities10 Pre-defined Complex Types 29 Collections11 IF 30 INSERT12 IF/ELSE 31 Collections and {}13 IF/ELSEIF/ELSE 32 Removing from a Collection14 WHILE 33 Date and Time Types15 FOR 34 Date and Time Arithmetics16 Arithmetic 35 Date and Time Utilities17 Logical Operations 36 Date Formatting18 Dataspace 37 Time Formatting19 Defining a ‘Person’ Record 38 Other Free Tutorials20 Adding Attributes to the ‘Person’ Record
  3. 3. 2MemeScript Example var x = 10; var y = 20; var z : Integer; z = x + y; notify(z);
  4. 4. 3Meme IDE Function Editor
  5. 5. 4Primitive Types• Integer 10, -234• Decimal 1.23• String “ABC”• Boolean true, false
  6. 6. 5Declaring Integer VariablesLocal variables within functionsvar x : Integer;var x2 = 1;
  7. 7. 6Declaring Decimal Variablesvar d : Decimal(2);var d2 = 1.23;
  8. 8. 7Declaring Boolean Variablesvar b : Boolean;var b2 = true;
  9. 9. 8Declaring Stringsvar s : String;var s = “abc”;
  10. 10. 9Default Initializations• String - empty string “”• Integer and Decimal – 0• Boolean – false
  11. 11. 10Pre-defined Complex Types• Date – day, month, year• Time – hour, minute, second• Duration – hour, minute, second• Timestamp
  12. 12. 11IFvar a = 15;if (a > 10){ notify(“A is big”);}
  13. 13. 12IF / ELSEvar a = 15;if (a > 10){ notify(“A is big”);}else{ notify(“A is small”);}
  14. 14. 13IF / ELSEIF / ELSEvar a = 15;if (a > 10){ notify(“A is big”);}elseif (a > 5){ notify(“A is medium sized”);}else{ notify(“A is small”);}
  15. 15. 14WHILEvar x = 0;while (x < 10){ x++; // do other things}
  16. 16. 15FORvar names : String[];append(names, “Simon”);append(names, “Graham”);append(names, “Joe”);for (name in names){ notify(name);}
  17. 17. 16Arithmeticvar c = 20;f = c * (9.0 / 5.0) + 32;notify(f);
  18. 18. 17Logical Operatorsvar x = 10;if ((x > 10) and not (x > 20)){ notify(“x is middle sized”);}
  19. 19. 18Dataspace
  20. 20. 19Defining a ‘Person’ Record
  21. 21. 20Adding Attributes to the ‘Person’ Record
  22. 22. 21Naming 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
  23. 23. 22Defining an Address Record
  24. 24. 23Adding List of Addresses to Person
  25. 25. 24Creating a Person Recordvar p : Person;var a : Address;a.line1 = “12 High St”;a.zip = “PA 12345”;p.name = “Simon”;p.tel = “1234567”;append(p.addresses, a);
  26. 26. 25‘Dot’ Notationnotify(p.addresses[0].line1);p.addresses[0].line1 = “13 High St”
  27. 27. 26String 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.
  28. 28. 27String Comparisonvar s1 = “String 1”;var s2 = “String ONE”;if (s1 == s2){ notify(“Yes”);}
  29. 29. 28String 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)
  30. 30. 29Collectionsvar people : Person[];var names : String[];append(names, “Simon”);append(names, “Graham”);
  31. 31. 30INSERTvar people : Person[];var names : String[];append(names, “Simon”);append(names, “Graham”);insert(names, “Joe”, 0);
  32. 32. 31Collections and []var people : Person[];var fred : Person;simon.name = “Simon”;simon.tel = “12345”;people.append(simon);var graham : Person;graham.name = “Simon”;graham.tel = “12345”;people.append(graham);people.remove(simon);
  33. 33. 32Removing from a Collectionvar people : Person[];var simon : Person;simon.name = “Simon”;simon.tel = “12345”;people.append(simon);var graham : Person;graham.name = “Simon”;graham.tel = “12345”;people.append(graham);notify(people[1].name);
  34. 34. 33Date and Time Types• Date - day, month, year• Time - hour, minute, second• Duration - hour, minute, second• Timestamp
  35. 35. 34Date and Time Arithmeticvar t : Time;t = timeNow();var dt : Duration;dt.hour = 1;t = addTime(t, dt);
  36. 36. 35Date 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)
  37. 37. 36Date FormattingCode Description 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 yearwithout 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”
  38. 38. 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”
  39. 39. 38Please check www.memeapps.com for more free tutorials in the developers centerLevel one:101 - Hello World Hello Meme IDE102 - Introduction to MemeScript Language103 - Meme IDE Fundamentals201 - Records and Record Types202 - Designing Business Apps203 - Advanced MemeScript301 - MemeApps and Communications302 - MemeApps advanced User Interfaces303 - MemeApps and Persistence

×