/***************************************************************************
$Log:   K:/ins/gf/vcs/instdos.dav  $
   
      Rev 1.35   22 Jul 1994 09:07:14   Russ
   		Changed test of length of CSID string to make
   		sure 20 characters can be entered.
   		ToddW

      Rev 1.34   06 Jun 1994 14:23:34   Russ
                   Changed logic used when doing board detection and creation
                   of Gammalink configuration and startup files.  Changes were
                   also made to BLD_DC.C module.

                   ToddW

      Rev 1.33   23 May 1994 13:45:24   Russ
                   Added another state to @BoardDection variable:

                   0 = no board detection.
                   1 = board detection and only bin/dispatcher installed
                   2 = board detection and utilities or all files being installed.

                   This is used to determine if a coverpage should be installed

                   ToddW


      Rev 1.32   23 May 1994 08:39:18   Russ
   		Fixed bug GL-000341.  Changed spelling of incorrectly
   		spelled label.
   		ToddW

      Rev 1.31   13 May 1994 08:13:12   Russ
                   Added a test for CSID <= 20 characters.
                   Changed more text (per Morgans request).
                   Added check for valid creation of subdirectory.
                   Added TIFFHDR to files to be de-compressed.

                   ToddW

      Rev 1.30   09 May 1994 10:37:10   Russ
   		Changed displayed text to be consistent.  This was done in
   		conjunction with Morgan.
   		ToddW

      Rev 1.29   03 May 1994 10:18:44   Russ
                   Fixed the following bugs:

                   GL-000296
                   GL-000297
                   GL-000300
                   GL-000302
                   GL-000305

                   ToddW

      Rev 1.28   27 Apr 1994 13:27:36   Russ
                   fixed bug GL-000281: GFAX.CVR file missing

                   1.  Added block to get user name and voice phone nubmer
                       during installation.

                   2.  Added block to allow for backup of an existing GFAX.CVR
                       file

                   3.  Changed parameters in call to BLD_DC.EXE as required

                   ToddW

      Rev 1.27   25 Apr 1994 11:49:08   Russ
   Fixed bugs GL-000275,GL-000276,GL-000278.
   Removed all underscores from labels (required for future compatibility with
   Knowledge Dynamics install products).
   ToddW

      Rev 1.26   18 Apr 1994 09:07:54   Russ
                   Changed parameters to call to BLD_DC when no board detection
                   is NOT being performed.  ToddW

      Rev 1.25   18 Apr 1994 07:32:16   Russ
                   Changed some spelling errors.
                   ToddW

      Rev 1.24   15 Apr 1994 16:37:58   Russ
                   Removed code to create GF and GFQM startup files.  This was
                   required becuase of a bug in the Knowledge Dynamics install
                   script language under OS/2.

                   Added BoardDetection parameter to call to BLD_DC.EXE.  The code
                   to create startup files was moved to this level.
                   ToddW


      Rev 1.23   14 Apr 1994 14:58:08   Russ
                   Fixed the following bugs:

                   GL-000244 - No default CSID
                   GL-000245 - default to install all files
                   GL-000246 - default to dial and answer mode

                   GL-000252 - added REGCARD, HELPTECH.DOC, and  BUGREPRT
                               to README.TXT.

                   GL-000253 - changed send/receive language to dial/answer
                               language (to conform with previous versions).

                   GL-000257 - Able to continue with install without
                               entering a CSID

                   GL-000257 - Able to continue with install without
                               entering a COUNTRY code

                   GL-000265 - Check for existence of GFQM and GF
                               before overwriting.

                   GL-000247 - Gammafax should be GammaFax
                   GL-000261 - Blank line at top of GF and GFQM startup files.
                   GL-000248 - Creation of GF and GFQM startup files.
                   GL-000249 - FAXM.PHB will be installed.
                   GL-000260 - Problems creating GFAX.$DC when CSID or COUNTRY
                               is not entered.

                   GL-000262 - GFSCREEN.DA$ was not installed.
                   GL-000243 - After was misspelled.


      Rev 1.22   12 Apr 1994 16:55:48   Russ
   		Changed text which used send/receive to dial/answer
   		to conform with previous Gammalink versions.  ToddW

      Rev 1.21   11 Apr 1994 15:34:44   Russ
   		Added code to create GF.BAT and GFQM.BAT using
   		the @Write command.  ToddW

      Rev 1.20   11 Apr 1994 09:16:16   Russ
   		changed default options for:
   		1.  Files to install
   		2.  Shutdown state of the boards
   	
   		Bug GL-000246,GL-000245,GL-000244, and GL-000247
   		are fixed with this revision.  ToddW

      Rev 1.19   30 Mar 1994 14:37:20   Russ
                Added GCL.EXE to files to be installed
                ToddW

      Rev 1.18   30 Mar 1994 10:13:04   Russ
   		changed how variable GfaxEnv is initialized (Doens't use
   		environment variable).  ToddW

      Rev 1.17   29 Mar 1994 07:59:52   Russ
   		removed setting of GfaxEnv string variable
   		ToddW

      Rev 1.16   28 Mar 1994 17:34:26   Russ
   		added GfaxEnv parameter to @execute command used
   		for Gammalink Board Detection.  ToddW

      Rev 1.15   28 Mar 1994 13:23:18   Russ
   		added GFSETUP.EXE to files to be installed
   		ToddW

      Rev 1.14   28 Mar 1994 11:22:02   Russ
   		added READ.ME to files to be installed
   		ToddW

      Rev 1.13   28 Mar 1994 10:11:28   Russ
   		Changed some text in the initial installation greeting
   		ToddW

      Rev 1.12   28 Mar 1994 10:07:56   Russ
   		correctly changed all reference to README.TXT to
   		READ.ME. ToddW

      Rev 1.11   28 Mar 1994 09:09:04   Russ
   		added TIFF files to list of files to be installed
   		changed post-installation file from README.TXT to
   		READ.ME.  ToddW

      Rev 1.10   25 Mar 1994 18:29:50   RussJ
   		added GFQRESET and GFCPTST to install script
   		Toddw

      Rev 1.9   24 Mar 1994 10:33:34   RUSS
   	changed installation description that
   	is displayed during start of install

      Rev 1.8   18 Mar 1994 08:27:34   Russ
   		Changed name of DISPATCHER from GFDCP.EXE to GFDCP1.EXE
   		to match the name of the dispatcher that is created
   		during a build.

   		During the installation process, the file is written to
   		GFDCP.EXE

      Rev 1.7   03 Mar 1994 11:07:16   Russ
   		added @ShutDownState parameter to call of BLD_DC.EXE
   		at the end of the install script

      Rev 1.6   03 Mar 1994 09:36:00   Russ
   		changed all referneces to @spawn to @Execute since
   		the OS/2 version doesn't support @spawn at this time

      Rev 1.5   02 Mar 1994 16:42:04   Russ
   		add ability to choose if Gammalink board detection should be done

      Rev 1.4   02 Mar 1994 14:45:58   Russ
     added support for requesting COUNTRY code

      Rev 1.3   02 Mar 1994 13:16:22   Russ

   added block to get CSID from user

      Rev 1.2   02 Mar 1994 11:29:12   Russ
   added block of code to optionally back up GFAX.$DC
   added block of code to generate GFQM.BAT and GF.BAT
   added block of code to optionally turn of Gammalink board detection


this file contains the script commands to install the GammaFax CP software
and the Utilities using the Knowledge Dynamics INSTALL language. Major
features include:

1.  Ability to selectively install the bin/dispatcher or the utilites.
2.  Perform Board Detection and creation of GFAX.$DC
3.  Create GFQM.BAT and GF.BAT

**************************************************************************/


@DefineProject
 @Requires @HardDisk
 @Name="GammaFax Version 5.2 Software for DOS"
 @Version = "5.2"
 @OutDrive = C
 @Subdir = "\\fax\\"
@EndProject


@DefineVars
 @Drive @GFaxDrive = @OutDrive
 @Integer @DOS = 0
 @Integer @OS2 = 1
 @Integer @BoardDetection = 0   /* board detection off by default */
 @Integer @OperatingSystem = @DOS
 @Qstring @GFQM                 /* startup file used to start Dispatcher */
 @Qstring @GF                   /* startup file used to start menu program */
 @Qstring @GfaxEnv              /* Gammalink Environmet variable */
 @Qstring @csid = " "           /* csid value */
 @Qstring @userid = " "         /* userid value */
 @Qstring @VoicePhone = " "     /* voice phone number */

 @Dir @GfaxDir = @Subdir
 @Qstring @Target =  "@OutDrive:@SubDir"
 @Qstring @GfaxConfig          /* current GFAX.$DC */
 @Qstring @GfaxConfigBackup = "gfax.001"   /* backup of a previous gfax.$dc */
 @Qstring @GfaxGF              /* current GF.BAT */
 @Qstring @GfaxCVR             /* current GFAX.CVR (coverpage file) */
 @Qstring @GfaxGFQM            /* current GFQM.BAT */
 @Qstring @GfaxGFQMBackup      /* backup of current GFQM.BAT */
 @Qstring @GfaxGFBackup        /* backup of current GF.BAT */
 @Qstring @GfaxCVRBackup       /* backup of GFAX.CVR */

 @Integer @NumChannels       /* number of installed channels */
 @Integer @GfaxSize = 2000k  /* amount of space required for full install */
 @Integer @CountryCode = 1   /* country code (default = USA) */
 @Integer @ShutDownState = 0  /* default shutdown state */
 @Integer @Detect = 1
 @Integer @StartupFiles = 2
 @Integer @CoverPage = 4
 @Integer @AllFiles = 8

 @Integer @StartupFilesD = 3
 @Integer @CoverPageD = 5
 @Integer @AllFilesD = 9
@EndVars


@Display


                    GammaFax Version 5.2 Software for DOS
                               Installation


   @Pause
@EndDisplay

/**************************************************************************

This section determines which installation groups should be installed.  The
choices are:

            1.  Dispatcher and BIN files only
            2.  Utilities only
            3.  All files

**************************************************************************/

@FlushGroups
@GetGroups
  Select one of the following, and press Enter.

  @Set c = "Install all GammaFax files"
  @Set a = "Install Dispatcher and BIN files only"
  @Set b = "Install Utilites only"
@EndGroups

/************************************************************************
This section will prompt for the target installation drive
*************************************************************************/

GetInstallSubdirectory:

@GetOutDrive
 @Suppress a
 @Suppress b
 @Cls
  Select the drive on which to install the GammaFax software, and
  press Enter.



@EndOutDrive

@if(@DiskFree(@OutDrive) <= @GfaxSize)
   @display
     There is not enough free disk space on drive @OutDrive: to install
     the GammaFax Software.



     @pause
   @EndDisplay
   @Goto GetInstallSubdirectory
@Endif

/**********************************************************************
This section will prompt for the target installation subdirectory
***********************************************************************/

@GetSubdir
 @Cls
   Enter the subdirectory in which to install the GammaFax software, and
   press Enter.

   The target subdirectory must contain 8 characters or less.  A target
   subdirectory with more than 8 characters will be truncated to 8
   characters (i.e \DOS\FAX12345678 will be truncated to \DOS\FAX12345).

@EndSubDir


/***************************************************************************
This section determines if the target subdirectory exists, and if it doesn't
it will be created
****************************************************************************/



@if(@DirExists("@OutDrive:@Subdir"))
  @ClearGroup(n)
  @ClearGroup(y)
  @GetGroups
    @Cls
    @LocalWindow(10,40)

      @OutDrive:@SubDir already exists.



    @Set n = "Continue installation in @OutDrive:@Subdir"
    @Set y = "Choose another subdirectory for installation"



  @EndGroups


  @if ('y' [= @Group)
     @goto GetInstallSubdirectory
  @else

/**********************************************************************
  This block is used to determine if the is an existing GFAX.$DC
  file in the target directory.  If one exists, the user will be
  asked if they would like to save the current GFAX.$DC file to another
  file.  They are then prompted for the new file name
*************************************************************************/

  @GfaxConfig = "@OutDrive:@SubDir\\GFAX.$DC"

  @if(@Exists(@GfaxConfig))

  @ClearGroup(o)
  @ClearGroup(s)
  @GetGroups
    @Cls
    @LocalWindow(10,40)

      @OutDrive:@SubDir\GFAX.$DC already exists.



    @Set o = "overwrite existing GFAX.$DC file"
    @Set s = "save existing GFAX.$DC file"



  @EndGroups


   @if ('s' [= @Group)
     @GfaxConfigBackup = "@Outdrive:@SubDir\\GFAX.001"
     @GetString @GfaxConfigBackup

      Please enter a new name for the current GFAX.$DC


     @EndString


   /* renaming GFAX.$DC to new file */


   @Display
    @cls
    Copying @GfaxConfig to @GfaxConfigBackup
    @Copy(@GfaxConfig,@GfaxConfigBackup)



    @pause
   @EndDisplay

   @endif  /* end of getting of new filename block */
  @endif  /* end of if GFAX.$DC exits */
 @endif  /* end of install directory exists block */



@Else
 @Mkdir("@OutDrive:@SubDir")

 @if(!@DirExists("@OutDrive:@Subdir"))
  @display

    @OutDrive:@Subdir cannot be created.


    @pause

   @EndDisplay
   @goto Get_Install_Subdirectory
 @endif

@endif

/* set value of GFAX subdirectory */

@GfaxEnv = "@OutDrive:@SubDir"


/**************************************************************************
check for GFQM.BAT, GF.BAT and GFAX.CVR files.  Give the user the option
of backing them up
****************************************************************************/

/* CHECKING FOR GFQM.BAT */

  @GfaxGFQM = "@OutDrive:@SubDir\\GFQM.BAT"

  @if(@Exists(@GfaxGFQM))

  @ClearGroup(o)
  @ClearGroup(s)
  @GetGroups
    @Cls
    @LocalWindow(10,40)

      @OutDrive:@SubDir\GFQM.BAT already exists.



    @Set o = "overwrite existing GFQM.BAT file"
    @Set s = "save existing GFQM.BAT file"



  @EndGroups


   @if ('s' [= @Group)
     @GfaxGFQMBackup = "@Outdrive:@SubDir\\GFQM.001"
     @GetString @GfaxGFQMBackup

      Please enter a new name for the current GFQM.BAT


     @EndString


   /* renaming GFQM.BAT to new file */


   @Display
    @cls
    Copying @GfaxGFQM to @GfaxGFQMBackup
    @Copy(@GfaxGFQM,@GfaxGFQMBackup)



    @pause
   @EndDisplay

   @endif  /* end of getting of new filename block */
  @endif  /* end of if GFAX.$DC exits */
 @endif  /* end of install directory exists block */


/* CHECKING FOR GF.BAT */

  @GfaxGF = "@OutDrive:@SubDir\\GF.BAT"

  @if(@Exists(@GfaxGF))

  @ClearGroup(o)
  @ClearGroup(s)
  @GetGroups
    @Cls
    @LocalWindow(10,40)

      @OutDrive:@SubDir\GF.BAT already exists.



    @Set o = "overwrite existing GF.BAT file"
    @Set s = "save existing GF.BAT file"



  @EndGroups


   @if ('s' [= @Group)
     @GfaxGFBackup = "@Outdrive:@SubDir\\GF.001"
     @GetString @GfaxGFBackup

      Please enter a new name for the current GF.BAT


     @EndString


   /* renaming GFQM.BAT to new file */


   @Display
    @cls
    Copying @GfaxGF to @GfaxGFBackup
    @Copy(@GfaxGF,@GfaxGFBackup)



    @pause
   @EndDisplay

   @endif  /* end of getting of new filename block */
  @endif
 @endif


 /* checking for GFAX.CVR file */


  @GfaxCVR = "@OutDrive:@SubDir\\GFAX.CVR"

  @if(@Exists(@GfaxCVR))

  @ClearGroup(o)
  @ClearGroup(s)
  @GetGroups
    @Cls
    @LocalWindow(10,40)

      @OutDrive:@SubDir\GFAX.CVR already exists.



    @Set o = "overwrite existing GFAX.CVR file"
    @Set s = "save existing GFAX.CVR file"



  @EndGroups


   @if ('s' [= @Group)
     @GfaxCVRBackup = "@Outdrive:@SubDir\\GFCVR.001"
     @GetString @GfaxCVRBackup

      Please enter a new name for the current GFAX.CVR


     @EndString


   /* renaming GFAX.CVR to new file */


   @Display
    @cls
    Copying @GfaxCVR to @GfaxCVRBackup
    @Copy(@GfaxCVR,@GfaxCVRBackup)



    @pause
   @EndDisplay

   @endif  /* end of getting of new filename block */
  @endif
 @endif
/**************************************************************************
This section will ask the user if they would like to perform board
detection
***************************************************************************/



@if ( ('a' [= @Group) || ('c' [= @Group) )
  @ClearGroup(n)
  @ClearGroup(y)
  @GetGroups
    @Cls
    @LocalWindow(15,40)

     Do you want to check the host computer for GammaFax fax channels?
     Select one and press Enter.

     If fax channel detection is not done, a default GFAX.$DC file
     won't be created and you will have to create one after
     installation completes.

     Select one, and press Enter.


    @Set y = "Perform fax channel detection"
    @Set n = "Skip fax channel detection"



  @EndGroups


  /* turn board detection off */

  @if ('c' [= @Group)
   @BoardDetection = @AllFiles
   @GfaxEnv = "@OutDrive:@SubDir"
  @endif

  @if ('a' [= @Group)
   @BoardDetection = @StartupFiles
   @GfaxEnv = "@OutDrive:@SubDir"
  @endif

  @if ( 'c' [= @Group  && 'y' [= @Group)
    @BoardDetection = @AllFilesD
   @GfaxEnv = "@OutDrive:@SubDir"
  @endif

  @if ( 'a' [= @Group && 'y' [= @Group)
    @BoardDetection = @StartUpFilesD
   @GfaxEnv = "@OutDrive:@SubDir"
  @endif


@else
   @BoardDetection = @CoverPage
@endif

/***************************************************************************
This section will request the CSID from the user
****************************************************************************/


GetCSID:
@csid = " "
@if (@BoardDetection)

     @GetString @csid

      Each fax channel must be given a valid CSID.  The CSID represents
      your Called Station IDentification and is usually your return fax phone
      number.  The GammaFax software will also allow a string to be used
      as the CSID.

      Enter the CSID and press Enter.  Please enclose your CSID with
      quotation marks (i.e. "408-555-1212" or "Company Name").  The CSID
      must be 20 characters or less.

     @EndString

   /* if no CSID is entered, request it again */

   @if("@csid" ==" " | "@csid" =="")
     @goto GetCSID
    @endif

   /* check length of CSID, it must be 20 characters or less */

   @if(@StrLen("@csid") > 22)

   @Display

   You entered a CSID that was greater than 20 characters.  The CSID must
   be 20 characters or less.


   @pause
   @goto GetCSID
   @Enddisplay
  @endif
 @endif
@endif /* end of if board detection */

/***************************************************************************
This section will request a country code from the user
****************************************************************************/

GetCountry:
 @if (@BoardDetection & @Detect)

  @GetInteger @CountryCode

  Each fax channel must be given a valid country code.  Enter the country
  code, and press Enter.

  All fax channels will be given the same country code.


  @EndInteger

  @if (@CountryCode < 1 | @CountryCode > 400)
    @CountryCode = 1
    @goto GetCountry
  @endif

 @endif

/***************************************************************************
This section will get the default shutdown state of the channels
****************************************************************************/



@if (@BoardDetection & @Detect)

  @ClearGroup(s)
  @ClearGroup(r)
  @ClearGroup(b)
  @GetGroups
    @Cls
    @LocalWindow(10,40)


    Select the mode in which the fax channels will operate, and press Enter.

    @Set t = "Dial and answer"
    @Set r = "Dial only"
    @Set s = "Answer only"



  @EndGroups


  @if ('r' [= @Group)
   @ShutDownState=1
  @endif

  @if ('s' [= @Group)
   @ShutDownState=2
  @endif

  @if ('t' [= @Group)
   @ShutDownState=0
  @endif

@endif /* end of board detection */


/***************************************************************************
This section will get the user name and voice phone number for use in
creating a cover page
****************************************************************************/


@if ( ('b' [= @Group) || ('c' [= @Group) )
GetUserId:
   @GetString @userid

   Enter your name (or company name), and press Enter.  This is the name
   that will appear on the cover page of sent faxes.

   Your name should be enclosed by quotation marks (i.e "Joe Smith").


   @EndString

   /* if no userid is entered, request it again */

   @if("@userid" ==" " | "@userid" =="")
     @goto GetUserId
    @endif


/***************** get voice phone number *******************************/

GetVoicePhone:
   @GetString @VoicePhone

   Enter your phone number, and press Enter.  Your phone number should be
   enclosed by quotation marks (i.e "408-744-1400").

   @EndString


   @if("@VoicePhone" ==" " | "@VoicePhone" =="")
     @goto GetVoicePhone
    @endif


 @endif

/***************************************************************************
This section will create the GF.BAT and GFQM.BAT startup files
****************************************************************************

**** CODE REMOVED DUE TO KNOWLEDGE DYNAMICS INSTALL SCRIPT BUG *****


@GF="@GfaxEnv\\gf.bat"
@GFQM="@GfaxEnv\\gfqm.bat"

@Write("@GFQM","wt","SET GFAX=@GfaxEnv\n")
@Write("@GFQM","at","@GfaxEnv\\gfqreset -p3\n")
@Write("@GFQM","at","@GfaxEnv\\gfdcp -b1\n")


@Write("@GF","wt","SET GFAX=@GfaxEnv\n")
@Write("@GF","at","@GfaxEnv\\faxm -a0\n")



@display
  @Cls
  Created @GFQM and @GF files.


  @pause

@Enddisplay
****************************************************************************/
/***************************************************************************
This section will copy the desired files to the target drive and sudirectory
****************************************************************************/


@DefineDisk
 @Label = "GammaFax Version 5.2 software disk 1"
   @Beginlib GFAX.RED

     /* files that belong in groups a and c */

     @File GFXCX.BIN @Out *.* @Group ac
     @File GFXCP.BIN @Out *.* @Group ac
     @File GFDCP1.EXE @Out gfdcp.exe @Group ac
     @File GFDUNLD1.EXE @Out gfdunld.exe @Group ac


     /* copy utilities */

     @File tiffhdr.exe @Out *.* @Group bc
     @File fax*.* @Out *.* @Group bc
     @File gfqreset.exe @Out *.* @Group bc
     @File gcl.exe @Out *.* @Group bc
     @File gfcptst.exe @Out *.* @Group bc
     @File *.tif @Out *.* @Group bc
     @File readme.txt @Out *.* @Group bc
     @File gfsetup.exe @Out *.* @Group bc
     @File gfscreen.da$ @Out *.* @Group bc


   @EndLib
@EndDisk



@Finish

/*********************************************************************
if the BoardDection flag is on, perform Gammalink board detection
**********************************************************************/

@cls
@if (@BoardDetection & @Detect)




              After fax channel detection has completed, please read the
              post-installation information and instructions in the
              file README.TXT

@pause
@Execute("bld_dc.exe","@CountryCode @ShutDownState @csid @GfaxEnv @BoardDetection @VoicePhone @userid")
@else

 @cls
               You chose to skip GammaFax fax channel detection.  Your
               GammaFax fax channels are not configured correctly.  Please
               use the utility program GFSETUP to generate the GammaFax
               configuration file.

@Execute("bld_dc.exe","0 0 gammalink @GfaxEnv @BoardDetection @VoicePhone @userid")
@endif





                     Installation Complete !!


      Please read the file README.TXT for any post-installation instructions.


  @Pause
@EndFinish
