04 meme script
-
Upload
memeapps -
Category
Technology
-
view
515 -
download
2
description
Transcript of 04 meme script
![Page 1: 04 meme script](https://reader031.fdocuments.in/reader031/viewer/2022020110/5560e78dd8b42a016e8b513d/html5/thumbnails/1.jpg)
Meme Script
● Type System
● If, while etc
● Dates, times, strings
![Page 2: 04 meme script](https://reader031.fdocuments.in/reader031/viewer/2022020110/5560e78dd8b42a016e8b513d/html5/thumbnails/2.jpg)
Meme Script Example
var x = 10;
var y = 20;
var z : Integer;
z = x + y;
notify(z);
![Page 3: 04 meme script](https://reader031.fdocuments.in/reader031/viewer/2022020110/5560e78dd8b42a016e8b513d/html5/thumbnails/3.jpg)
Meme IDE Function Editor
![Page 4: 04 meme script](https://reader031.fdocuments.in/reader031/viewer/2022020110/5560e78dd8b42a016e8b513d/html5/thumbnails/4.jpg)
Primitive Types
● Integer 10, -234
● Decimal 1.23
● String “ABC”
● Boolean true, false
![Page 5: 04 meme script](https://reader031.fdocuments.in/reader031/viewer/2022020110/5560e78dd8b42a016e8b513d/html5/thumbnails/5.jpg)
Declaring Integer Variables
● Local variables within functions
var x : Integer;
var x2 = 1;
![Page 6: 04 meme script](https://reader031.fdocuments.in/reader031/viewer/2022020110/5560e78dd8b42a016e8b513d/html5/thumbnails/6.jpg)
Declaring Decimal Variables
var d : Decimal(2);
var d2 = 1.23;
![Page 7: 04 meme script](https://reader031.fdocuments.in/reader031/viewer/2022020110/5560e78dd8b42a016e8b513d/html5/thumbnails/7.jpg)
Declaring Boolean Variables
var b : Boolean;
var b2 = true;
![Page 8: 04 meme script](https://reader031.fdocuments.in/reader031/viewer/2022020110/5560e78dd8b42a016e8b513d/html5/thumbnails/8.jpg)
Declaring Strings
var s : String;
var s = “abc”;
![Page 9: 04 meme script](https://reader031.fdocuments.in/reader031/viewer/2022020110/5560e78dd8b42a016e8b513d/html5/thumbnails/9.jpg)
Default Initializations
● String - empty string “”
● Integer and Decimal – 0
● Boolean – false
![Page 10: 04 meme script](https://reader031.fdocuments.in/reader031/viewer/2022020110/5560e78dd8b42a016e8b513d/html5/thumbnails/10.jpg)
Pre-defined Complex Types
● Date – day, month, year
● Time – hour, minute, second
● Duration – hour, minute, second
● Timestamp
![Page 11: 04 meme script](https://reader031.fdocuments.in/reader031/viewer/2022020110/5560e78dd8b42a016e8b513d/html5/thumbnails/11.jpg)
IF
var a = 15;
if (a > 10)
{
notify(“A is big”);
}
![Page 12: 04 meme script](https://reader031.fdocuments.in/reader031/viewer/2022020110/5560e78dd8b42a016e8b513d/html5/thumbnails/12.jpg)
IF / ELSE
var a = 15;
if (a > 10)
{
notify(“A is big”);
}
else
{
notify(“A is small”);
}
![Page 13: 04 meme script](https://reader031.fdocuments.in/reader031/viewer/2022020110/5560e78dd8b42a016e8b513d/html5/thumbnails/13.jpg)
IF / ELSIF / ELSE notify(“A is small”);
}
notify(“A is big”);
}
elsif (a > 5)
{
notify(“A is medium sized”);
}
else
{
notify(“A is small”);
}
![Page 14: 04 meme script](https://reader031.fdocuments.in/reader031/viewer/2022020110/5560e78dd8b42a016e8b513d/html5/thumbnails/14.jpg)
WHILE
var x = 0;
while (x < 10)
{
x++;
// do other things
}
![Page 15: 04 meme script](https://reader031.fdocuments.in/reader031/viewer/2022020110/5560e78dd8b42a016e8b513d/html5/thumbnails/15.jpg)
FOR
var names : String[];
append(names, "Jack");
append(names, "Jill");
append(names, "Jane");
for (name in names)
{
notify(name);
}
![Page 16: 04 meme script](https://reader031.fdocuments.in/reader031/viewer/2022020110/5560e78dd8b42a016e8b513d/html5/thumbnails/16.jpg)
Arithmetic
var c = 20;
f = c * (9.0 / 5.0) + 32;
notify(f);
![Page 17: 04 meme script](https://reader031.fdocuments.in/reader031/viewer/2022020110/5560e78dd8b42a016e8b513d/html5/thumbnails/17.jpg)
Logical Operators
var x = 10;
if ((x > 10) and not (x > 20))
{
notify(“x is middle sized”);
}
![Page 18: 04 meme script](https://reader031.fdocuments.in/reader031/viewer/2022020110/5560e78dd8b42a016e8b513d/html5/thumbnails/18.jpg)
Dataspace
![Page 19: 04 meme script](https://reader031.fdocuments.in/reader031/viewer/2022020110/5560e78dd8b42a016e8b513d/html5/thumbnails/19.jpg)
Defining a 'Person' Record
![Page 20: 04 meme script](https://reader031.fdocuments.in/reader031/viewer/2022020110/5560e78dd8b42a016e8b513d/html5/thumbnails/20.jpg)
Adding Attributes to the 'Person' Record
![Page 21: 04 meme script](https://reader031.fdocuments.in/reader031/viewer/2022020110/5560e78dd8b42a016e8b513d/html5/thumbnails/21.jpg)
Naming Conventions
Record Type Names● bumpy case with initial uppercase, ● - E.g. Person or EmployeeDetails
Attribute names in records● - bumpy case with initial lowercase● - E.g. name or firstName
![Page 22: 04 meme script](https://reader031.fdocuments.in/reader031/viewer/2022020110/5560e78dd8b42a016e8b513d/html5/thumbnails/22.jpg)
Defining an Address Record
![Page 23: 04 meme script](https://reader031.fdocuments.in/reader031/viewer/2022020110/5560e78dd8b42a016e8b513d/html5/thumbnails/23.jpg)
Adding List of Addresses to Person
![Page 24: 04 meme script](https://reader031.fdocuments.in/reader031/viewer/2022020110/5560e78dd8b42a016e8b513d/html5/thumbnails/24.jpg)
Creating a Person Record
var p : Person;
var a : Address;
a.line1 = "12 Hight St";
a.zip = "PA 12345";
p.name = "Simon";
p.tel = "1234567";
append(p.addresses, a);
![Page 25: 04 meme script](https://reader031.fdocuments.in/reader031/viewer/2022020110/5560e78dd8b42a016e8b513d/html5/thumbnails/25.jpg)
'Dot' Notation
notify(p.addresses[0].line1);
p.addresses[0].line1 = "13 High St"
![Page 26: 04 meme script](https://reader031.fdocuments.in/reader031/viewer/2022020110/5560e78dd8b42a016e8b513d/html5/thumbnails/26.jpg)
String Concatenation
var 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.
![Page 27: 04 meme script](https://reader031.fdocuments.in/reader031/viewer/2022020110/5560e78dd8b42a016e8b513d/html5/thumbnails/27.jpg)
String Comparison
var s1 = "String 1";
var s2 = "String ONE";
if (s1 == s2)
{
notify("Yes");
}
![Page 28: 04 meme script](https://reader031.fdocuments.in/reader031/viewer/2022020110/5560e78dd8b42a016e8b513d/html5/thumbnails/28.jpg)
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)
![Page 29: 04 meme script](https://reader031.fdocuments.in/reader031/viewer/2022020110/5560e78dd8b42a016e8b513d/html5/thumbnails/29.jpg)
Collections
var people : Person[];
var names : String[];
append(names, "Fred");
append(names, "Jane");
![Page 30: 04 meme script](https://reader031.fdocuments.in/reader031/viewer/2022020110/5560e78dd8b42a016e8b513d/html5/thumbnails/30.jpg)
INSERT
var people : Person[];
var names : String[];
append(names, "Fred");
append(names, "Jane");
insert(names, "Joe", 0);
![Page 31: 04 meme script](https://reader031.fdocuments.in/reader031/viewer/2022020110/5560e78dd8b42a016e8b513d/html5/thumbnails/31.jpg)
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);
people.remove(fred);
![Page 32: 04 meme script](https://reader031.fdocuments.in/reader031/viewer/2022020110/5560e78dd8b42a016e8b513d/html5/thumbnails/32.jpg)
Removing from a Collection
var people : Person[];
var fred : Person[];
fred.name = "Fred";
fred.tel = "12345";
people.append(fred);
remove(people, fred);
notify(people[1].name);
![Page 33: 04 meme script](https://reader031.fdocuments.in/reader031/viewer/2022020110/5560e78dd8b42a016e8b513d/html5/thumbnails/33.jpg)
Date and Time Types
● Date - day, month, year
● Time - hour, minute, second
● Duration - hour, minute, second
● Timestamp
![Page 34: 04 meme script](https://reader031.fdocuments.in/reader031/viewer/2022020110/5560e78dd8b42a016e8b513d/html5/thumbnails/34.jpg)
Date and Time Arithmetic
var t : Time;
t = timeNow();
var dt : Duration;
dt.hour = 1;
t = addTime(t, dt);
![Page 35: 04 meme script](https://reader031.fdocuments.in/reader031/viewer/2022020110/5560e78dd8b42a016e8b513d/html5/thumbnails/35.jpg)
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)
![Page 36: 04 meme script](https://reader031.fdocuments.in/reader031/viewer/2022020110/5560e78dd8b42a016e8b513d/html5/thumbnails/36.jpg)
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”
![Page 37: 04 meme script](https://reader031.fdocuments.in/reader031/viewer/2022020110/5560e78dd8b42a016e8b513d/html5/thumbnails/37.jpg)
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”
![Page 38: 04 meme script](https://reader031.fdocuments.in/reader031/viewer/2022020110/5560e78dd8b42a016e8b513d/html5/thumbnails/38.jpg)
Questions?