service {
/* begin htmls section */
const html showIBS =
harro!
<[message]>
i0: <[i0]> b0: <[b0]> s0: <[s0]>
i1: <[i1]> b1: <[b1]> s1: <[s1]> ;
const html Done =
Done! ;
/* the htmls of the forum */
const html Error = Error!<[errorMessage]>;
const html TopicList =
ForuM!
COOL FORUM YA!
<[topics]>
Create new topic
Subject
message
username
byootiful HTML by Jesse, brilliant forum logic by Anton, gobs of awful code generated by Kamal
;
const html Topic =
<[topic]> - ForuM!
topic: <[topic2]>
<[messages]>
Create new message
message
username
back to topic list
byootiful HTML by Jesse, brilliant forum logic by Anton, gobs of awful code generated by Kamal
;
/* end htmls section */
/* begin schemas section */
/* tuple for creating new message */
schema New {
string topic;
string username;
string message;
}
/* a schemata telling us what actions to do (i.e. given the receives of the webpages) */
schema Action {
string choice;
string topic;
string username;
string message;
}
/* a schema for an error - for return valus of functions */
schema Success {
bool success;
string errorMessage;
}
schema IBS {
int i;
bool b;
string s;
}
schema Array {
int i0;
bool b0;
string s0;
int i1;
bool b1;
string s1;
int i2;
bool b2;
string s2;
int i3;
bool b3;
string s3;
int i4;
bool b4;
string s4;
int i5;
bool b5;
string s5;
int i6;
bool b6;
string s6;
int i7;
bool b7;
string s7;
int i8;
bool b8;
string s8;
int i9;
bool b9;
string s9;
int i10;
bool b10;
string s10;
int i11;
bool b11;
string s11;
int i12;
bool b12;
string s12;
int i13;
bool b13;
string s13;
int i14;
bool b14;
string s14;
int i15;
bool b15;
string s15;
int i16;
bool b16;
string s16;
int i17;
bool b17;
string s17;
int i18;
bool b18;
string s18;
int i19;
bool b19;
string s19;
int i20;
bool b20;
string s20;
int i21;
bool b21;
string s21;
int i22;
bool b22;
string s22;
int i23;
bool b23;
string s23;
int i24;
bool b24;
string s24;
int i25;
bool b25;
string s25;
int i26;
bool b26;
string s26;
int i27;
bool b27;
string s27;
int i28;
bool b28;
string s28;
int i29;
bool b29;
string s29;
int i30;
bool b30;
string s30;
int i31;
bool b31;
string s31;
int i32;
bool b32;
string s32;
int i33;
bool b33;
string s33;
int i34;
bool b34;
string s34;
int i35;
bool b35;
string s35;
int i36;
bool b36;
string s36;
int i37;
bool b37;
string s37;
int i38;
bool b38;
string s38;
int i39;
bool b39;
string s39;
int i40;
bool b40;
string s40;
int i41;
bool b41;
string s41;
int i42;
bool b42;
string s42;
int i43;
bool b43;
string s43;
int i44;
bool b44;
string s44;
int i45;
bool b45;
string s45;
int i46;
bool b46;
string s46;
int i47;
bool b47;
string s47;
int i48;
bool b48;
string s48;
int i49;
bool b49;
string s49;
int i50;
bool b50;
string s50;
int i51;
bool b51;
string s51;
int i52;
bool b52;
string s52;
int i53;
bool b53;
string s53;
int i54;
bool b54;
string s54;
int i55;
bool b55;
string s55;
int i56;
bool b56;
string s56;
int i57;
bool b57;
string s57;
int i58;
bool b58;
string s58;
int i59;
bool b59;
string s59;
int i60;
bool b60;
string s60;
int i61;
bool b61;
string s61;
int i62;
bool b62;
string s62;
int i63;
bool b63;
string s63;
int i64;
bool b64;
string s64;
int i65;
bool b65;
string s65;
int i66;
bool b66;
string s66;
int i67;
bool b67;
string s67;
int i68;
bool b68;
string s68;
int i69;
bool b69;
string s69;
int i70;
bool b70;
string s70;
int i71;
bool b71;
string s71;
int i72;
bool b72;
string s72;
int i73;
bool b73;
string s73;
int i74;
bool b74;
string s74;
int i75;
bool b75;
string s75;
int i76;
bool b76;
string s76;
int i77;
bool b77;
string s77;
int i78;
bool b78;
string s78;
int i79;
bool b79;
string s79;
int i80;
bool b80;
string s80;
int i81;
bool b81;
string s81;
int i82;
bool b82;
string s82;
int i83;
bool b83;
string s83;
int i84;
bool b84;
string s84;
int i85;
bool b85;
string s85;
int i86;
bool b86;
string s86;
int i87;
bool b87;
string s87;
int i88;
bool b88;
string s88;
int i89;
bool b89;
string s89;
int i90;
bool b90;
string s90;
int i91;
bool b91;
string s91;
int i92;
bool b92;
string s92;
int i93;
bool b93;
string s93;
int i94;
bool b94;
string s94;
int i95;
bool b95;
string s95;
int i96;
bool b96;
string s96;
int i97;
bool b97;
string s97;
int i98;
bool b98;
string s98;
int i99;
bool b99;
string s99;
}
/* end schemas section */
/* begin globals section */
/*
topics
- string: topic name
- int: index of last message in messages
messages
- string: message
- int: index of previous message in messages or -1 for first is first message
usernames
- string: username
- int: index of topic
*/
tuple Array topics;
tuple Array usernames;
tuple Array messages;
int messageCount;
int topicCount;
int arraySize; //should be initialized to the size of the array
/* end globals section */
/* begin functions section */
/* all sorts of useful functions */
/* some more helper functions for arrays*/
string array_getString(tuple Array a,int n){
tuple IBS ibs;
ibs = array_get(a,n);
return ibs.s;
}
int array_getInt(tuple Array a,int n){
tuple IBS ibs;
ibs = array_get(a,n);
return ibs.i;
}
bool array_getBool(tuple Array a,int n){
tuple IBS ibs;
ibs = array_get(a,n);
return ibs.b;
}
tuple Array array_setInt(tuple Array a, int n, int new) {
tuple IBS ibs;
ibs = array_get(a,n);
ibs.i = new;
return array_set(a,n,ibs);
}
tuple Array array_setBool(tuple Array a, int n, bool new) {
tuple IBS ibs;
ibs = array_get(a,n);
ibs.b = new;
return array_set(a,n,ibs);
}
tuple Array array_setString(tuple Array a, int n, string new) {
tuple IBS ibs;
ibs = array_get(a,n);
ibs.s = new;
return array_set(a,n,ibs);
}
string genMessage(string uname, string body){
string m;
m = "";
m = m + uname + "
";
m = m + body + "
";
return m;
}
string genTopic(string topic){
string m;
m = "";
m = m+ " "+topic+"
";
return m;
}
/* functions for showing pages */
string getTopicList(){
string t;
int i;
t = "";
i = 0;
while(i