constant debug;
constant story "IMEM Demo";
constant headline "^An Interactive demo for IMem.h^";
include "parser";
include "verblib";
include "grammar";
include "imem";

Object Startroom "" has light swapped_out;
[ StartRoom_prop prop code;
 if (code==0)
  if (prop==description or short_name or e_to) rtrue;
  else rfalse;
 else switch(prop)
 {
   description: return "You are in the Start Room. If you go east,
                        this room and everything in it will be swapped
                        out.";
   short_name: return "Start Room";
   e_to: return StartRoom_e_to;

 }
];
[ StartRoom_e_to;
 UnloadPage(1);
 LoadPage(2);
 return OtherRoom;
];
Object -> madprop "" has swapped_out static;
[ madprop_props prop code;
 if (code==0)
  if (prop==description  or name or short_name) rtrue;
  else rfalse;
 else switch(prop)
 {
   description: return "It's a simple prop. It's fixed in place to stop
                        you from carrying it when it's swapped out.";
   short_name: return "prop";
   name: return 'prop';
 }
];
Object -> otherprop "" has swapped_out static;
[ otherprop_props prop code;
 if (code==0)
  if (prop==description or short_name or name) rtrue;
  else rfalse;
 else switch(prop)
 {
   description: return "It's another prop. It's fixed in place to stop
                        you from carrying it when it's swapped out.";
   short_name: return "second";
   name: return 'second';
 }

];

Object -> lastprop "" has swapped_out static;
[ lastprop_props prop code;
 if (code==0)
  if (prop==description or short_name or parse_name or initial) rtrue;
  else rfalse;
 else switch(prop)
 {
   description: return "It's the third prop. It's fixed in place to stop
                        you from carrying it when it's swapped out.";
!    short_name: return "last prop";
   parse_name: return lp_pn;
   initial: return "A third thing, which you can call ~last~ is here.";

 }

];
[ lp_pn i;
 while (nextword()=='last' or 'third' or 'thing') i++;
 return i;
];
Object Otherroom "" has swapped_out light;
[ Otherroom_prop prop code;
 if (code==0)
  if (prop==description or short_name or w_to) rtrue;
  else rfalse;
 else switch(prop)
 {
   description: return "You are in the Other Room. If you go west,
                        this room and everything in it will be swapped
                        out.";
   short_name: return "Other Room";
   w_to: return Other_w_to;

 }
];
[ Other_W_to;
 UnloadPage(2);
 LoadPage(1);
 return StartRoom;
];
object -> foo "" has swapped_out static;
[ foo_props prop code;
 if (code==0)
  if (prop==short_name or name) rtrue;
  else rfalse;
 else switch(prop)
 {
   short_name: return "foo";
   name: return 'foo';
 }

];
[ Loadpage i;
 if (i==1)
 {

  SwapIn(StartRoom,StartRoom_prop);
  SwapIn(Madprop,madprop_props);
  SwapIn(otherprop,otherprop_props);
  SwapIn(lastprop,lastprop_props);
 }
 else
 {
  Swapin(Otherroom,otherroom_prop);
  Swapin(foo,foo_props);
 }
];
[ Unloadpage i;
 if (i==1)
 {
  SwapOut(lastprop);
  SwapOut(otherprop);
  SwapOut(Madprop);
  SwapOut(StartRoom);
 }
 else
 {
  SwapOut(foo);
  SwapOut(Otherroom);
 }
];

[ initialise;
 Loadpage(1);
 location=startroom;
 "^^^^^";
];