Hi People,
I have been given to work on this program written some 15 years ago for data acquisition but i cannot figure out how to get this to compile as i am getting a lot of compilation errors.
Any insight would be highly appriciated.
Thanks in advance
argus

#define CS_USR_HOME
#define SPIKE_TIME_ARRAY_SIZE  1
#define EVENT_TIME_ARRAY_SIZE  1

#include <dos.h>
#include <string.h>
#include <conio.h>
#include <memory.h>
#include <time.h>
#include <math.h>
#include <stdlib.h>
#include <CMN_g.h>
#include <DACQ_g.h>
#include <clock_g.h>
#include <UI_g.h>
#include <CC_g.h>
#include <UFF_g.h>
#include "su_g.h"
#include "su_defs.h"
#include "su_types.h"
#include "su_vars.h"
#include "su_fref.h"
#include "su_ui.h"
#include "cs_l.h"
#include "tm__defs.h"   /* specific for this clocked sequence */
#include "tm__vars.h"   /* specific for this clocked sequence */
#include "tm__fref.h"   /* specific for this clocked sequence */

static int Template(int);
static int LickCS(int);

SEQUENCE_CONTROL_BLOCK	
			sequence_cb[] = {
			0,0L,0L,Template,		/* SEQUENCE 0 - not started from Keyboard */
			0,0L,0L,LickCS,  		/* SEQUENCE 1 */
			};
						
int nnum_clocked_sequences = 2;

static char *module = "cs_usr.c";
static char *version = "$Revision:   1.5  $$Date:   16 Sep 1988 18:30:48  $";


/*============== Start of functions for the Clocked Sequences ==============*/

int Template( int nprocessing_state )
/* This function is clocked sequence #0.
 * It is meant for a starting place for users to write a new clocked sequence.
 * It will just BEEP the computer speaker 3 times at two second intervals.
 */

{
    static int ncounter;

#define SECOND_STATE      2


    switch (nprocessing_state){

    case INITIAL_STATE:
        UI_Beep();
	ncounter = 0;
	vCS_SetNextState( SECOND_STATE , 2000L );
        break;

    case SECOND_STATE:
        UI_Beep();
        ncounter++;
	if (ncounter >1){
            vCS_SetNextState( TERMINATION_STATE , 1L );
        }
	break;

    case TERMINATION_STATE:
        UI_DisplayError(UI_NOTICE, "All done with the Template Sequence",
 	              "               Please hit RETURN                 ");
        vCS_SetNextState( IDLE_STATE, 0L);
	break;

    default:   /* this one should never never be executed */
        UI_DisplayError(UI_ERROR, "Clocked Sequence Error",
		        "  Template Sequence hit Default State       ");
        return(-1);   /* this will abort the sequence */
        break;
    }

    return(0);
}
/*======================================================================*/

int LickCS(int nprocessing_state)
{

	#define WATER_ON_STATE			2
	#define WATER_OFF_STATE			3	
	#define PROCESS_KEYS_STATE		4
	#define CLEAN_UP_STATE			5
	#define PULSE_STATE				6
	#define PREP_ON_STATE			7
	#define PREP_OFF_STATE			8

static int dis_track;

	/* register int i; */
	static int vidstart = 0;

	dwcurrent_time = (DWORD)lCTM05TSRead();
		
	switch( nprocessing_state ) {

		case INITIAL_STATE:
			if( vidstart ) {
				vCS_SetNextState( wstate, NO_DELAY );
				break;
			}
			if( !bfile_open ) {
        		UI_DisplayError( UI_ERROR, "  Clocked Sequence Error  ", 
				"         No UFF file open for data storage     " );
				return(-1);
			}
			if( tracker1.wtracker_type == TRACKER_NONE ){
				UI_DisplayError( UI_ERROR, " Tracker Test CS ",
				" No Tracker Type defined in Setup Editor " );
				return(-1);
			}
			if( wnum_user_windows < MAXWINDOWS ) {
				UI_DisplayError( UI_ERROR, "     User Windows Error         ",
				" Not Enough User Windows Defined in Current Setup File " );
				return(-1);
			}
			if( !init_vars() ) {
				UI_DisplayError( UI_ERROR, "     Random Times List Error         ",
				"   D:\\TALI\\RANDOM.TXT Does Not EXIST   " );
				return(-1);
			}

			vSU_DrawBox( user_windows[0].box, BLUE );
			vSU_DrawBox( user_windows[1].box, RED );
			vSU_DrawBox( user_windows[2].box, GREEN );

			sprintf(szprompt_buf,"Water ON = %lu mins; Water OFF = %lu mins; Pulses Each Water ON = %u; Pulse Duration = %u msec (y/n)?",
	        		 duration.dwh2o_on, duration.dwh2o_off, count.nh2o_pulse, duration.wh2o_pulse);
			nUI_Query(szprompt_buf, szuser_resp, 1, 0, 0);
			if( RESPONSE_IS_NO ) {
				while( prompt_user() ) 
					continue;
			}

			duration.wh2o_pulse *= CLOCK_SOURCE;
			duration.dwh2o_on *= BWMINS;
			duration.dwh2o_off *= BWMINS;

			do {
				sprintf(szprompt_buf,"Does Thalner Time on Monitor Read \"00:00:00.01\" (y/n)?");
				nUI_Query(szprompt_buf, szuser_resp, 1, 0, 0);
				vidstart = RESPONSE_IS_YES ? 1 : 0;
			}while( !RESPONSE_IS_YES && !RESPONSE_IS_NO );

			if( vidstart ) {
				if( nVideoStart() ) {
       				UI_DisplayError( UI_ERROR, "  Clocked Sequence Error  ",
						"         Thalner Reset Error                   " );
					return(-1);					
				}
			}
			else {
				UI_DisplayError( UI_NOTICE, " Turn Thalner OFF and ON Now To Reset It ",
						"  Hit Return and Ctrl-F1 to Restart Clocked Sequence  ");
				vCS_SetNextState( IDLE_STATE, TIME_DELAY );
				break;
			}

			SU_BhvFlagPrc("_B");
			wstate = KEYS;

			/* 
			 * User Window 1
			 */
			vst_color( screen->handle, npos_text_color );
			sprintf( szpos_out_buff, "WON = %3d  WOF = %3d  AP = %3d  MP = %3d  LI = %4d",
			         count.nh2o_on, count.nh2o_off, npulse_num, nmanual, list_index);
			v_gtext(screen->handle , user_windows[1].work[0], 
					user_windows[1].work[1], szpos_out_buff);
			/*
			 * User Window 2
			 */
			vst_color( screen->handle, npos_text_color );
			sprintf( szpos_out_buff, PERIODNULL );
			v_gtext(screen->handle, user_windows[2].work[0], 
					user_windows[2].work[1], szpos_out_buff);

			vCS_SetNextState( PROCESS_KEYS_STATE, TIME_DELAY );

    	dis_track = 1;

			break;

		case PREP_ON_STATE:
			dwstart_time = tdr_buff.dwtime_stamp = dwlast_time = dwcurrent_time;
			list_index = CAL_INDEX;
			STORE_EF('W','N');
			itoa(++count.nh2o_on, tdr_buff.sztdr_data[WATER], 10);
			nUffIt((WORD*)&tdr_buff);
			npulse_num = 0;			
			wstate = H2O_ON;

			/* 
			 * User Window 1
			 */
			vst_color( screen->handle, npos_text_color );
			sprintf( szpos_out_buff, "WON = %3d  WOF = %3d  AP = %3d  MP = %3d  LI = %4d",
			         count.nh2o_on, count.nh2o_off, npulse_num, nmanual, list_index);
			v_gtext(screen->handle , user_windows[1].work[0], 
					user_windows[1].work[1], szpos_out_buff);
			/*
			 * User Window 2
			 */
			vst_color( screen->handle, npos_text_color );
			sprintf( szpos_out_buff, PERIOD1 );
			v_gtext(screen->handle, user_windows[2].work[0], 
					user_windows[2].work[1], szpos_out_buff);

			vCS_SetNextState( wstate, TIME_DELAY );
			break;

		case WATER_ON_STATE:
			if( nlast_keystroke ) {
				vCS_SetNextState( PROCESS_KEYS_STATE, TIME_DELAY );
				break;
			}
			if( ELAPSED_TIME < duration.dwh2o_on )
				if( PULSE_NUM && PULSE_TIME )
					vCS_SetNextState( PULSE_STATE, NO_DELAY );
				else
					vCS_SetNextState( wstate, TIME_DELAY );
			else
				vCS_SetNextState( PREP_OFF_STATE, TIME_DELAY );

      if ( dis_track ) {
				vst_color( screen->handle, npos_text_color );
				sprintf(szpos_out_buff, "x:%3d  y:%3d", tracker1.wx1, tracker1.wy1);
				v_gtext(screen->handle, user_windows[0].work[0],user_windows[0].work[1], 
						szpos_out_buff);
				dis_track = 0;
			}
			else
				dis_track = 1;
			
			break;

		case PULSE_STATE:
			(void)nUFF_FlushBuffer(huff_filehandle);
			nCTM05_VarDutyClockOutputInit(3, COUNT_PERIOD_100US, FALSE, 3, duration.wh2o_pulse, 0);
			STORE_EF('A','P');
			nCTM05_VarDutyClockOutputStart(3);
			++npulse_num;
			++list_index;					
			dwlast_time = dwcurrent_time;

			/* 
			 * User Window 1
			 */
			vst_color( screen->handle, npos_text_color );
			sprintf( szpos_out_buff, "WON = %3d  WOF = %3d  AP = %3d  MP = %3d  LI = %4d",
			         count.nh2o_on, count.nh2o_off, npulse_num, nmanual, list_index);
			v_gtext(screen->handle , user_windows[1].work[0], 
					user_windows[1].work[1], szpos_out_buff);
			/*
			 * User Window 2
			 */
			vst_color( screen->handle, npos_text_color );
			if( nlastkey < 0 )
				sprintf( szpos_out_buff, CTRLS );
			else if( wstate == H2O_ON )
				sprintf( szpos_out_buff, PERIOD1 );
			else if( wstate == H2O_OFF )
				sprintf( szpos_out_buff, PERIOD0 );
			else
				sprintf( szpos_out_buff, PERIODNULL );
			v_gtext(screen->handle, user_windows[2].work[0], 
					user_windows[2].work[1], szpos_out_buff);
						
			vCS_SetNextState( wstate, TIME_DELAY );
			break;

		case PREP_OFF_STATE:
			dwstart_time = tdr_buff.dwtime_stamp = dwcurrent_time;
			STORE_EF('W','F');				
			itoa(--count.nh2o_off, tdr_buff.sztdr_data[WATER], 10);
			nUffIt((WORD*)&tdr_buff);			
			wstate = H2O_OFF;							

			/* 
			 * User Window 1
			 */
			vst_color( screen->handle, npos_text_color );
			sprintf( szpos_out_buff, "WON = %3d  WOF = %3d  AP = %3d  MP = %3d  LI = %4d",
			         count.nh2o_on, count.nh2o_off, npulse_num, nmanual, list_index);
			v_gtext(screen->handle , user_windows[1].work[0], 
					user_windows[1].work[1], szpos_out_buff);
			/*
			 * User Window 2
			 */
			vst_color( screen->handle, npos_text_color );
			sprintf( szpos_out_buff, PERIOD0 );
			v_gtext(screen->handle, user_windows[2].work[0], 
					user_windows[2].work[1], szpos_out_buff);

			vCS_SetNextState( wstate, TIME_DELAY );
			break;

		case WATER_OFF_STATE:
			if( nlast_keystroke ) {
				vCS_SetNextState( PROCESS_KEYS_STATE, TIME_DELAY );
				break;
			}
			if( ELAPSED_TIME >= duration.dwh2o_off )
				vCS_SetNextState( PREP_ON_STATE, TIME_DELAY );			
			else
				vCS_SetNextState( wstate, TIME_DELAY );

			if ( dis_track ) {
				vst_color( screen->handle, npos_text_color );
				sprintf(szpos_out_buff, "x:%3d  y:%3d", tracker1.wx1, tracker1.wy1);
				v_gtext(screen->handle, user_windows[0].work[0],user_windows[0].work[1], 
						szpos_out_buff);
				dis_track = 0;
			}
			else
				dis_track = 1;
		
			break;

		case CLEAN_UP_STATE:
			SU_BhvFlagPrc("_E");
			nVideoStop();
			vStopContAD();
			vSU_UFFClose();
			vSU_DrawGSAcqStatus(&gen_status_display, 0);
			vCS_SetNextState( IDLE_STATE, TIME_DELAY );
			break;
			
		case PROCESS_KEYS_STATE:
			switch( nlast_keystroke ) {
				case '&':
				case '$':
					if(nlastkey == -1) {
						wstate = (nlast_keystroke == '$') ? CLEAN_UP : wstate;
						nlastkey = (nlast_keystroke == '&') ? 0 : nlastkey;
					}					
					break;

				case STOP:
					nlastkey = -1;

					/* 
					 * User Window 1
					 */
					vst_color( screen->handle, npos_text_color );
					sprintf( szpos_out_buff, "WON = %3d  WOF = %3d  AP = %3d  MP = %3d  LI = %4d",
			         count.nh2o_on, count.nh2o_off, npulse_num, nmanual, list_index);
					v_gtext(screen->handle , user_windows[1].work[0], 
							user_windows[1].work[1], szpos_out_buff);
					/*
					 * User Window 2
					 */
					vst_color( screen->handle, npos_text_color );
					sprintf( szpos_out_buff, CTRLS );
					v_gtext(screen->handle, user_windows[2].work[0], 
							user_windows[2].work[1], szpos_out_buff);

					break;

				case START_WATER_ON_PERIOD:
				case START_WATER_OFF_PERIOD:
					if(wstate == H2O_ON || wstate == H2O_OFF)
						break;
					wstate = nlast_keystroke == START_WATER_ON_PERIOD ? PREP_ON : PREP_OFF;
					break;

				case BREAK_CYCLE:					
					tdr_buff.dwtime_stamp = dwcurrent_time;
					STORE_EF('B','R');
					itoa(0, tdr_buff.sztdr_data[WATER], 10);
					nUffIt((WORD*)&tdr_buff);
					npulse_num = 0;
					wstate = KEYS;

					/* 
					 * User Window 1
					 */
					vst_color( screen->handle, npos_text_color );
					sprintf( szpos_out_buff, "WON = %3d  WOF = %3d  AP = %3d  MP = %3d  LI = %4d",
			         count.nh2o_on, count.nh2o_off, npulse_num, nmanual, list_index);
					v_gtext(screen->handle , user_windows[1].work[0], 
							user_windows[1].work[1], szpos_out_buff);
					/*
					 * User Window 2
					 */
					vst_color( screen->handle, npos_text_color );
					sprintf( szpos_out_buff, PERIODNULL );
					v_gtext(screen->handle, user_windows[2].work[0], 
							user_windows[2].work[1], szpos_out_buff);

					break;

				case PULSE_DELIVERY:
					nCTM05_VarDutyClockOutputInit(3, COUNT_PERIOD_100US, FALSE, 3, duration.wh2o_pulse, 0);
					SU_BhvFlagPrc("MP");
					nCTM05_VarDutyClockOutputStart(3);
					++nmanual;

					/* 
					 * User Window 1
					 */
					vst_color( screen->handle, npos_text_color );
					sprintf( szpos_out_buff, "WON = %3d  WOF = %3d  AP = %3d  MP = %3d  LI = %4d",
			         count.nh2o_on, count.nh2o_off, npulse_num, nmanual, list_index);
					v_gtext(screen->handle , user_windows[1].work[0], 
							user_windows[1].work[1], szpos_out_buff);
					/*
					 * User Window 2
					 */
					vst_color( screen->handle, npos_text_color );
					if( nlastkey < 0 )
						sprintf( szpos_out_buff, CTRLS );
					else if( wstate == H2O_ON )
						sprintf( szpos_out_buff, PERIOD1 );
					else if( wstate == H2O_OFF )
						sprintf( szpos_out_buff, PERIOD0 );
					else
						sprintf( szpos_out_buff, PERIODNULL );
					v_gtext(screen->handle, user_windows[2].work[0], 
							user_windows[2].work[1], szpos_out_buff);

					break;
			}
			nlast_keystroke = 0;

			if ( dis_track ) {
				vst_color( screen->handle, npos_text_color );
				sprintf(szpos_out_buff, "x:%3d  y:%3d", tracker1.wx1, tracker1.wy1);
				v_gtext(screen->handle, user_windows[0].work[0],user_windows[0].work[1], 
						szpos_out_buff);
				dis_track = 0;
			}
			else
				dis_track = 1;

			vCS_SetNextState(wstate, TIME_DELAY);
			break;
	}
	
	return 0;
	
}

/*=====================================================================*/
/*=====================================================================*/
/*=====================================================================*/
	
int init_vars()
{
	FILE *in;
	register int i;
	char timestring[MAXSTRING];

	if( !(in = fopen("random.txt","rt") ) )  return 0;
	for(i=0; i<LISTSIZE; ++i) {
		do {
			fgets(timestring,MAXSTRING,in);
		}while( !atol(timestring) );
		curval[i] = (DWORD)atol(timestring) * BWMSECS;
	}
	fclose(in);
	
	list_index = npulse_num = nmanual = nlastkey = nlast_keystroke = 0;
	
	count.nh2o_pulse = 100;
	count.nh2o_on = count.nh2o_off = 0;
	duration.wh2o_pulse = 35;	
	duration.dwh2o_on = 15;
	duration.dwh2o_off = 5;

	tdr_buff.ufftype = SU_TDR_REC_UFFTYPE;
	tdr_buff.tdrtype = 0;	
	
	return 1;
}

/* ===================================================================== */
/* ===================================================================== */

int prompt_user()
{
	int i;

/*
 * Prompt for Duration of Water ON Period
 */
	sprintf(szprompt_buf,"Duration of Water ON Period [%lu mins] ([y]/n)?",
			duration.dwh2o_on);
	nUI_Query(szprompt_buf, szuser_resp, 1, 0, 0);
	while(RESPONSE_IS_NO) {
		sprintf(szprompt_buf,"Duration of Water ON Period [mins] ?");
		i = nUI_Query(szprompt_buf, szuser_resp, 2, 0, 0);
		duration.dwh2o_on = (DWORD)atol(szuser_resp);
		sprintf(szprompt_buf, "Duration of Water ON Period = %lu mins ([y]/n)", 
                duration.dwh2o_on);
	}
/*
 * Prompt for Duration of Water OFF Period
 */
 	sprintf(szprompt_buf,"Duration of Water OFF Period [%lu mins] ([y]/n)?",
			duration.dwh2o_off);
	nUI_Query(szprompt_buf, szuser_resp, 1, 0, 0);
 	while(RESPONSE_IS_NO) {
		sprintf(szprompt_buf,"Duration of Water OFF Period [mins] ?");
		i = nUI_Query(szprompt_buf, szuser_resp, 2, 0, 0);
		duration.dwh2o_off = (DWORD)atol(szuser_resp);
		sprintf(szprompt_buf, "Duration of Water OFF Period = %lu mins ([y]/n)", 
                duration.dwh2o_off);
	}
/*
 * Prompt for Number of Pulses During a Water ON Period
 */
 	sprintf(szprompt_buf,"Number of Pulses for Each Water ON Period [%u] ([y]/n)?",
			count.nh2o_pulse);
	nUI_Query(szprompt_buf, szuser_resp, 1, 0, 0);
 	while(RESPONSE_IS_NO) {
		sprintf(szprompt_buf,"Number of Pulses for Each Water ON Period ?");
		i = nUI_Query(szprompt_buf, szuser_resp, 3, 0, 0);
		count.nh2o_pulse = atoi(szuser_resp);
		sprintf(szprompt_buf, "Number of Pulses for Each Water ON Period = %u ([y]/n)", 
                count.nh2o_pulse);
	}
/*
 * Prompt for Water Pulse Duration
 */
 	sprintf(szprompt_buf,"Water Pulse Duration [%u msec] ([y]/n)?",
			duration.wh2o_pulse);
	nUI_Query(szprompt_buf, szuser_resp, 1, 0, 0);
 	while(RESPONSE_IS_NO) {
		sprintf(szprompt_buf,"Water Pulse Duration [msec] ?");
		nUI_Query(szprompt_buf, szuser_resp, 5, 0, 0);
		duration.wh2o_pulse = (WORD)atoi(szuser_resp);
		sprintf(szprompt_buf, "Water Pulse Duration = %u msec ([y]/n)", 
                duration.wh2o_pulse);
	}
/* 
 * Prompt for final confirmation to accept the above inputs
 */
 	do {
		sprintf(szprompt_buf,"Water ON = %lu mins; Water OFF = %lu mins; Pulses Each Water ON = %u; Pulse Duration = %u msec (y/n)?",
	       		 duration.dwh2o_on, duration.dwh2o_off, count.nh2o_pulse, duration.wh2o_pulse);
		nUI_Query(szprompt_buf, szuser_resp, 1, 0, 0);
	}while(!RESPONSE_IS_YES && !RESPONSE_IS_NO);
	
	if(RESPONSE_IS_NO)  
		return(1);
	else
		return(0);
}

/* ====================================================================== */
/* ====================================================================== */
/* ====================================================================== */
/* ====================================================================== */
/* ====================================================================== */

What compiler are you tring to compile it with? And what operating system (version too)? That 15-year-old program was more than likely written with a 16-bit compiler -- especially seeing that it uses old obsolete dos.h header file.

What compiler errors? Or link errors?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.