objref pc
pc = new ParallelContext()
{load_file("param.hoc")} // just for Nx and Ny

create soma
access soma
objref sl
sl = new SectionList()
objref s
s = new PlotShape(sl)
s.colormap(3)
s.colormap(0, 0, 0, 255)
s.colormap(1, 0, 0, 0)
s.colormap(2, 255, 0, 0)
s.scale(0, 2)
objref vec
nx = Nx
ny = Ny
vec = new Vector(nx*ny)
vec.fill(0)
for i=0,ny-1 for j=0,nx-1 {
  s.hinton(&vec.x[i*nx + j], i/nx, j/ny, 2/nx, 2/ny)
}
s.size(0.0, 2, 0, 0.5)
s.exec_menu("Shape Plot")

objref r, infile, on, ton, off
on = new Vector()
ton = new Vector()
off = new Vector()

doNotify()
delay=0
frame=1
infile= new File()
proc p() {local i
  time=0
  tframe=100+frame
  on.resize(0)
  ton.resize(0)
  off.resize(0)
  vec.fill(0)
  infile.ropen("spk.std")
  while (!infile.eof()) {
    while (time<tframe && !infile.eof()) {
      time=infile.scanvar()
      cell=infile.scanvar()
      on.append(cell)
      ton.append(time)
      vec.x[cell]=2
      s.flush()
      for xx=0, delay {a=0}
    }
    print "frame at ",time
    off.resize(0)
    for z=0, on.size()-1 {
      if (time>=ton.x[z]+frame) {off.append(on.x[z])}
    }
    if (off.size>0) {
      for z=0, off.size()-1 {
        index=on.indwhere("==",off.x[z])
        on.remove(index) 
        ton.remove(index)
      }
    }
    if (on.size()>0) for z=0, vec.size()-1 {if (on.contains(z)) {vec.x[z]=2} else {vec.x[z]=0}}
    s.flush()
    doNotify()
    tframe=time+frame
  }
  infile.close()
}