-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathEXS-Example.xs
More file actions
97 lines (97 loc) · 2.88 KB
/
EXS-Example.xs
File metadata and controls
97 lines (97 loc) · 2.88 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
include "EXS.xs";
void Simple(){
//================================
// CLASSES
//================================
NewClass("Unit");
Field("Name",Box("Champion"));
Field("Health",500);
Field("Attack",12);
//================================
// INSTANCES
//================================
int unitA = New("Unit");Value("Health",9);
int unitB = New("Unit");Text("Name","Rick");
Display(unitA);
DisplayText("-----------");
Display(unitB);
//================================
// DICTIONARY
//================================
int colors1 = NewDict("red",0,"blue",1,"green",2);
int colors2 = NewDict();
Item("purple",33);
Item("pink",9);
Item("gray",11);
Remove("pink");
Merge(colors1);
DisplayFields(colors2);
DisplayText("-----------");
//================================
// LIST
//================================
int listA = NewList(10,500,67,1);
Append(100,listA);
Pop(-2,listA);
DisplayList(listA,"ListA");
int listB = NewListString("a","b","c");
for(index=0;<Size(listB)){
string value = GetString(index,listB);
PrintOrange("" + index + " = " + value);
}
}
void Advanced(){
//================================
// CLASSES
//================================
NewClass("Resources");
Field("lots",11);
NewClass("Simple");
Field("Name",Box("Champion"));
Field("Bacon",42);
Field("Supplies",Ref(Type("Resources")));
Field("Health",1);
Field("Stuff",Ref(List(22)));
NewClass("Unit");Inherit("Simple");
Field("Health",500);
Field("Attack",12);
//================================
// INSTANCES
//================================
int unitA = New("Unit");
This("Stuff");Append(88);
This("Supplies",unitA);
Value("lots",Ref(List(1,2,3)));
int unitB = New("Unit");
Text("Name","Billy");
This("Stuff");Append(90);
int unitC = New("Unit");
This("Stuff");Append(100);
int unitD = New("Unit");
This("Supplies");Value("lots",9);
DisplayText("-----------");
Display(unitA);
DisplayText("-----------");
Display(unitB);
DisplayText("-----------");
Display(unitC);
DisplayText("-----------");
Display(unitD);
DisplayText("-----------");
//================================
// LIST
//================================
int listA = NewList(unitA,unitB,unitC);Pop(1);
int listB = NewList(unitC,unitA,unitD);Concat(listA);
int listC = NewList(Ref(listA),Ref(unitD),Box("Cool"));
DisplayList(listB);
DisplayText("-----------");
DisplayList(listC);
DisplayText("-----------");
PrintAqua("Unit Instances : " + GetCount("Unit"));
}
void main(){
EXSetup();
Simple();
//Advanced();
}