Example code for INSTALL.CMD
----------------------------

	The following three sections of INSTALL.CMD were customized for
installing a program called QueueTracer. This software consists of 3
files: The executable file QTRACE.EXE, an information file README.TXT
and a DLL named QTRACE.DLL. Together, these files occupy less than 50k
drive space. QueueTracer requires at least OS/2 v2.11 to run.

	The installation program needs to copy the executables to a
user-definable drive and directory, check the OS version, create a
separate subdirectory for the DLL file, copy the DLL file, create a
WPS object for quick access and modify CONFIG.SYS.

        Note: All function and variable names defined in INSTALL.CMD
bear an "Ins" prefix to distinguish them from user or system names.
See INSTALL.CMD itself for description of functions and variables.


/* ---------------- REQUIRED USER DATA BEGIN -------------------------------- */
/* -- program information */
InsProgName	= "QueueTracer 1.2"	/* program title */

/* -- program requirements */
InsTargetBytesRequired = 50000		/* free space in bytes required on target drive */
InsTargetOSRequired = 2.11		/* minimum OS/2 version required (Warp v3 = 2.30!)*/

InsStartableFromCMD = 1                 /* is program startable from CMD? */
InsProgramStartCall = "QTRACE"		/* if yes, that's what user has to type */
/* ---------------- REQUIRED USER DATA END ---------------------------------- */


/* ---------------- OPTIONAL USER DATA BEGIN --------------------------------- */
/* -- screen information */
InsScreenHeader.1	= "[44;37m[2J[1B  Installation of "InsProgName
InsScreenHeader.2	= "  "

/* -- general path information */
InsSourcePath	= ""
InsTargetPath   = "C:\QTRACER"		/* fill in default target path here */

/* -- installation options */
InsRestartRequired = 0			/* advise user to restart system afterwards */
                                        /* automatically set by InsConfigClose (see below) */
/* ---------------- OPTIONAL USER DATA END ----------------------------------- */


/* ------------------------------- MAIN PROGRAM ------------------------------ */
InsMainProgram:
        CALL InsWelcomeScreen           /* welcome the user */
        CALL InsPathScreen              /* get source and target path, check OS */

        /* At this point, we have checked and valid source and target paths,
           so we can go for the copying part. The target directory has been
           created if it didn't already exist. */

        /* -- Copying, Part One: The executable and readme files will be
           copied to the target path. As we don't want to check each
           and every InsFileCopy call for success, we make use of
           the InsErrorFlag instead of the return codes. */

        InsErrorFlag = 0        /* reset error flag */

        CALL InsFileCopy InsSourcePath"\QTRACE.EXE", InsTargetPath       /* copy .exe   */
        CALL InsFileCopy InsSourcePath"\README.TXT", InsTargetPath       /* copy readme */

        IF InsErrorFlag <> 0 THEN       /* check if copying went o.k. */
                CALL InsErrorScreen "DISKERROR", "FATAL"        /* it didn't - display
                                                                   a message and abort. */

        /* -- Make Directory: Now, we'll create a separate subdirectory for the .DLL file(s)
           under the target path. A new variable called MyLibDir is defined to hold
           the name of the new subdirectory. */

        MyLibDir = InsTargetPath"\DLL"          /* the subdir specification */
        CALL InsMakeDirectory MyLibDir          /* don't check for errors, as the
                                                   directory might already exist */
 
        /* -- Copying, Part Two: As there is just one file (DLL) to be copied, we can
           directly check the return code of InsFileCopy. */

        IF InsFileCopy(InsSourcePath"\QTRACE.DLL", MyLibDir) = 0 THEN  /* copy dll to subdir */
                CALL InsErrorScreen "DISKERROR", "FATAL"        /* failed - display a message
                                                                   and abort */

        /* -- Making a Workplace Shell Object: With InsCreateProgramObject, this
           isn't half as complicated as it might sound. We don't check for errors
           here, as this isn't a vital part of installation and the system
           might be using a different shell than WPS. If the call was a success,
           InsCompletionScreen (see end of main program) will notify the user.
        */

        CALL InsCreateProgramObject "Queue Tracer^Program", InsTargetPath"\QTRACE.EXE",,
                                    InsTargetPath

        /* -- Adapting CONFIG.SYS: The PATH and LIBPATH variables will
           be changed to include the appropriate directories of our program.
           Additionally, we'll define a QTRACE environment variable. Don't
           worry, a backup of CONFIG.SYS will be created. See the InsConfigXXX
           function definitions for more information. */

        InsErrorFlag = 0                /* use InsErrorFlag */

        CALL InsConfigOpen "CONFIG.QTR"         /* open config.sys, backup to CONFIG.QTR */

        CALL InsConfigAddPath "PATH", InsTargetPath     /* extend PATH statement */
        CALL InsConfigAddPath "LIBPATH", MyLibDir       /* extend LIBPATH statement */
        CALL InsConfigAppend "SET QTRACE=1"             /* define QTRACE variable */

        CALL InsConfigClose                     /* close config.sys */
 
        IF InsErrorFlag <> 0 THEN                       /* check for errors */
                CALL InsErrorScreen "CONFIGERROR", "FATAL"      /* display message, abort */


        /* -- Goodbye: Now, we'll notify the user that installation is complete.
           InsCompletionScreen knows if a program object has been created or
           if CONFIG.SYS has been changed and informs the user accordingly. See
           the definition of this function for more information. */

        CALL InsCompletionScreen

CALL InsExit 0

/* ------------------------------------------------------------------------------------ */



// Klaus A. Brunner        Austria, Europe
// <kbrun@ibm.net>  2:313/9.16@fidonet.org
