get col(1) -e npts
  /* find out the total number of rows in the
   * first column, and assume that to be the
   * same for the worksheet
   */

FirstWaveNum = 1004
  /* you may open a dialog box here
   * to get the actual value
   */
col(WaveNum)=data(FirstWaveNum,FirstWaveNum+npts-1)
  /* column WaveNum contains the X values */

col(Diff)=col(Sample)
col(Diff)-=col(Ref)
  /* these two lines perform the same as
   * col(Diff)=col(Sample)-col(Ref)
   * but it is much faster
   */

for(i=2;i<npts;i+=1) {
  y = col(Diff)[i];
  x = col(WaveNum)[i];
  if(y > col(Diff)[i-1] && y > col(Diff)[i+1]) {
     %(%H,5,i)=$(x);
      /* we can not use the col()[] notation for
       * text values.
       */
     type -q "Found a peak at $(x)";
  }
}

worksheet -s 4 0 5 0
   /* select column 4 through 5 */

worksheet -plot 200 Scatter
   /* plot the selected columns into a template
    * named Scatter and plot as a line(200) graph
    */
