MODELCT1, PLOTCT1

[From Bruce Abbott (960213.1810 EST)]

Just to make things tidy, Bill Powers's MODELCT1.PAS program should have the
following two lines added at the bottom, just before the final END statement:

restorecrtmode;
closegraph;

I tried a run and found that on my system the cursor lags behind the mouse
enough to create problems. However, I was running the program in a DOS box
within Windows, which probably slows things up considerably. Also, I'm
using a 25 mHz 386, which is slow by today's standards. I'll try it later
outside Windows and post the data after I've had some practice.

Appended is a simple Turbo Pascal program that reads the data file created
by MODELCT1 and plots the target and cursor positions as a function of time
during the run.

Regards,

Bruce

···

------------------------------------------------------------------------------
program plotct1;
{
  This program displays the target and cursor movements during a run of
  MODELCT1, as recorded in the data file SQUARE.DAT, and is written in
  Turbo (Borland) Pascal (compile with version 5.0 or higher).

  written by Bruce Abbott
             Psychological Sciences
             Indiana U. - Purdue U. Fort Wayne
             Fort Wayne IN 46815
  (960213)
}

uses dos, crt, graph, grutils;

type datatype = array[0..3599] of integer;

var cursor,target: integer;
    c,t: datatype;
    i,maxx,maxy,graphmode: integer;
    ch: char;
    sqrdat: text;

procedure initial;
begin
initgraphics;
graphmode := getmaxmode;
setgraphmode(graphmode);
end;

procedure plotdata;
var
  i, j, k, x, y, z, offset, amount: integer;
begin
  k := 0;
  amount := 65;
  offset := MaxY - MaxY div 5;
  outtextxy(MaxX div 2 - 125, 10, 'Square Wave Data Display');
  for j := 1 to 6 do
    begin
      for i := 1 to 600 do
        begin
          x := i div 1;
          y := MaxY-offset - t[k] div 4;
          z := MaxY-offset - c[k] div 4;
          putpixel(x, y, white);
          putpixel(x, z, yellow);
          inc(k);
        end;
      offset := offset - amount;
    end;
end;

begin
initial;
maxx := getmaxx; maxy := getmaxy;
assign(sqrdat,'square.dat');
reset(sqrdat);
for i := 0 to 3599 do
  begin
   read(sqrdat,t[i],c[i]);
  end;
plotdata;
ch := readkey;
close(sqrdat);
restorecrtmode;
closegraph;
end.