/*
|==============================================================================
|
|   This installation script contains the information needed to install
|   the Dynapro NFI OEM Touch Screen Drivers Software onto the target hard disk.
|
|==============================================================================
*/
@DefineProject
	@Name           = "Dynapro NFI OEM Touch Screen Drivers Software"
    @Version        = "3.0.0"
	@Subdir         = "\\TOUCH"
	@OutDrive       = C
@EndProject


/*
|==============================================================================
|
|       The @Display section shows the initial banner screen for the
|       installation procedure.  The copyright notice should appear
|       here.
|               
|==============================================================================
*/
@Display
	@Cls
                    D Y N A P R O

            NFI OEM Touch Screen Controller
                 Installation Utility

         Touch Screen Software version @Version
                for DOS and Windows 3.1


                Copyright 1995-1999, 
              Dynapro Technologies Inc.,
                All rights reserved.
	@Pause
@EndDisplay


/*
|==============================================================================
|
|       The @GetOutDrive section prompts the user to specify
|       which disk to install the software on.  The floppy
|       disk drives A: and B: are disabled from the list of
|       choices.
|               
|==============================================================================
*/
@GetOutDrive
	@Prompt = "Destination Drive"
	@Suppress(A)
	@Suppress(B)

	@Cls
	On which disk drive do you wish to install the
	Touch Screen Software?

@EndOutDrive


/*
|==============================================================================
|
|       This @GetOption section prompts the user for which serial
|       communication port the Dynapro NFI OEM touch screen controller is
|       connected to.  The selection is used as a command line argument
|       for the EMOUSE driver when it is inserted into AUTOEXEC.BAT.
|               
|==============================================================================
*/
@GetOption
	@Prompt = "Communication Port"

	@Cls
	Please select which COM
	port your touch screen
	controller is connected to:


	@Option 101 = " COM1 "
	@Option 102 = " COM2 "
	@Option 103 = " COM3 "
	@Option 104 = " COM4 "

@EndOption


/*
|==============================================================================
|
|       The @DefineDisk section defines which files are installed on
|       the target hard disk.  The @Platform variable is either 1=DOS
|       or 3=Windows.  If we are inside Windows, install all the
|       drivers for Windows as well.  All files are compressed in the
|       NFI.RED library.
|               
|==============================================================================
*/
@DefineVars
    @Dir @DosSubdir = "@OutDrive:@Subdir\\DOS"
    @Dir @WinSubdir = "@OutDrive:@Subdir\\WIN"
@EndVars

@DefineDisk
	@Label = "Touch Screen Drivers"

    @File README.TXT @Out @DosSubDir\README.TXT

	@BeginLib NFI.RED
		@File ECAL.EXE      @Out @DosSubDir\ECAL.EXE
		@File EMOPT.EXE     @Out @DosSubDir\EMOPT.EXE
		@File EMOUSE.COM    @Out @DosSubDir\EMOUSE.COM
		@File ETS.EXE       @Out @DosSubDir\ETS.EXE
        @File SURROUND.EXE  @Out @DosSubDir\SURROUND.EXE
		@File XBNFI.EXE     @Out @DosSubdir\XBNFI.EXE
		@File NSD.EXE       @Out @DosSubdir\NSD.EXE
		@File OSL.EXE       @Out @DosSubdir\OSL.EXE
        @File INSTALL.DAT   @Out @DosSubdir\INSTALL.DAT
        @File UNINSTAL.EXE  @Out @DosSubdir\UNINSTALL.EXE
        @File DISK.ID       @Out @DosSubdir\DISK.ID

	    @If (@Platform == 3)
    		@File TOUCH.INI  @Out @WindowsDrive:@WindowsDir\TOUCH.INI 
    		@File ETS.DLL    @Out @WindowsDrive:@WindowsDir\SYSTEM\ETS.DLL
    		@File EMOUSE.DRV @Out @WindowsDrive:@WindowsDir\SYSTEM\EMOUSE.DRV
    		@File VMD.386    @Out @WindowsDrive:@WindowsDir\SYSTEM\VMD.386
    	    @File QWERTY.EXE @Out @WinSubDir\QWERTY.EXE
        @Endif
	@EndLib
@EndDisk


/*
|==============================================================================
|
|       Delete instances of previous driver files.
|
|==============================================================================
*/
@Delete("@OutDrive:@Subdir\\DOS\\ETS*.EXE")
@Delete("@OutDrive:@Subdir\\DOS\\EMOUSE*.EXE")
@Delete("@OutDrive:@Subdir\\DOS\\SURROUND.EXE")
@Delete("@OutDrive:@Subdir\\DOS\\XB*.EXE")
@Delete("@OutDrive:@Subdir\\DOS\\INSTALL.DAT" )
@Delete("@OutDrive:@Subdir\\DOS\\UNINSTAL.EXE" )

@Delete( "@OutDrive:@Subdir\\WIN\\*.*" )

@Delete( "@WindowsDrive:@WindowsDir\\SYSTEM\\ETS.DLL" )
@Delete( "@WindowsDrive:@WindowsDir\\SYSTEM\\ETSL.DLL" )
@Delete( "@WindowsDrive:@WindowsDir\\SYSTEM\\EMOUSE.DRV ")
@Delete( "@WindowsDrive:@WindowsDir\\SYSTEM\\EMOUSEL.DRV ")
@Delete( "@WindowsDrive:@WindowsDir\\SYSTEM\\VMD.386" )
@Delete( "@WindowsDrive:@WindowsDir\\TOUCH.INI" )


/*
|==============================================================================
|
|       Modify the CONFIG.SYS file to load all required drivers.
|
|==============================================================================
*/
@DefineVars
    @QString @ConfLine = ""
    @QString @ConfUprLine = ""
    @QString @ConfXbiStr = "DEVICE=@DosSubDir\\XBNFI.EXE"
    @QString @ConfEtsStr = "DEVICE=@DosSubDir\\ETS.EXE /BUTTONS=1"
    @Integer @ConfDone = 0
    @Integer @ConfChange = 1
    @Integer @ConfModified = 0
    @Integer @ConfExtCount = 0

    /* Use the next two lines to create a unique temporary file name    */

    @Integer @ConfTime = @SystemDate
    @QString @ConfFile = "@StrTail("@StrUpr("@ConfTime")",8).TMP"
@EndVars

@Display
   I will now analyze your CONFIG.SYS to determine if any
   changes must be made to it.  Please wait.
   @Pause
@EndDisplay

@If(!@Exists("@BootDrive:\\config.sys"))

    @Write( "@BootDrive:\\config.sys", "wt", "@ConfXbiStr\n" )
    @Write( , , "@ConfEtsStr\n" )

@Else
    /* Get the first line of the Config.sys     */

    @ConfDone = @Readln( "@BootDrive:\\config.sys", "@@ConfLine" )
    @Write( "@BootDrive:\\@ConfFile", "wt", "" )

    /* Read the Config.sys to the EOF   */
CONFLOOP:

    @If( @ConfDone == ( -1 ) )
    	@GoTo CONFSKIP
    @EndIf

    /*
    	If it is the beginning of the multiboot section,
	    reset the XBI and ETS Modified flag to zero.
    */
    @If( "@StrHead( "@ConfLine", 1 )" == "[" )
    	@ConfModified = 0
    @EndIf

    @ConfUprLine = "@StrUpr( "@ConfLine" )"

    /*
	    Remove all line references to older/other driver products.
    */
    @If( ( @StrFind( "@ConfUprLine", "XBDTF.EXE" )  >= 0 ) ||
		 ( @StrFind( "@ConfUprLine", "XBARC.EXE" )  >= 0 ) ||
		 ( @StrFind( "@ConfUprLine", "XBDTC.EXE" )  >= 0 ) ||
		 ( @StrFind( "@ConfUprLine", "XBSC3.EXE" )  >= 0 ) ||
		 ( @StrFind( "@ConfUprLine", "XBPC2.EXE" )  >= 0 ) ||
		 ( @StrFind( "@ConfUprLine", "XBDSI.EXE" )  >= 0 ) ||
		 ( @StrFind( "@ConfUprLine", "XBDTFB.EXE" ) >= 0 ) ||
		 ( @StrFind( "@ConfUprLine", "XBDTF3.EXE" ) >= 0 ) ||
		 ( @StrFind( "@ConfUprLine", "XBDTF5.EXE" ) >= 0 ) ||
		 ( @StrFind( "@ConfUprLine", "XBDTFS.EXE" ) >= 0 ) ||
		 ( @StrFind( "@ConfUprLine", "ETSL.EXE" )   >= 0 ) )

		@GoTo CONFNEXT
    @EndIf

    @If( @StrFind( "@ConfUprLine", "XBNFI.EXE" ) >= 0 )

    	@If( ! @ConfModified )
    	    @Write( , , "@ConfXbiStr\n" )
    	    @Write( , , "@ConfEtsStr\n" )
    	    @ConfModified = 1
    	    @ConfChange = 0
    	@Else
    	    @GoTo CONFNEXT
    	@EndIf

    @Elseif( @StrFind( "@StrUpr( "@ConfUprLine" )", "ETS.EXE" ) >= 0 )

    	@If( ! @ConfModified )
    	    @Write( , , "@ConfXbiStr\n" )
    	    @Write( , , "@ConfEtsStr\n" )
    	    @ConfModified = 1
    	    @ConfChange = 0
    	@Else
    	    @GoTo CONFNEXT
    	@EndIf

    @Else
    	@Write( , "at", "@ConfLine\n" )
    @EndIf

CONFNEXT:

	@ConfDone = @Readln(, "@@ConfLine")
	@GoTo CONFLOOP

CONFSKIP:

    /* get backup file extension for the CONFIG.SYS file    */

    @If( @Exists( "@BootDrive:\\CONFIG.@ConfExtCount" ) )
    	@ConfExtCount = ( @ConfExtCount + 1 )
	    @Goto CONFSKIP
    @EndIf

    /*
    	If the commands are not found in CONFIG.SYS, append the
	    commands to the end of the CONFIG.SYS file.
    */
    @If( @ConfChange )
    	@Write( , , "@ConfXbiStr\n" )
	    @Write( , , "@ConfEtsStr\n" )
    	@ConfChange = 0
    @EndIf

    /*  Backup CONFIG.SYS and rename TMP file to CONFIG.SYS.    */

    @Rename( "@BootDrive:\\CONFIG.SYS", "Config.@ConfExtCount" )
    @Rename( "@BootDrive:\\@ConfFile", "CONFIG.SYS" )

@EndIf


/*
|==============================================================================
|
|       Modified AUTOEXEC.BAT to load all required drivers.
|
|==============================================================================
*/
@DefineVars
    @QString @AutoLine = ""
    @QString @AutoUprLine = ""

	@If (101 [= @Option)
		@QString @Port = "/COM1"
	@ElseIf (102 [= @Option)
		@QString @Port = "/COM2"
	@ElseIf (103 [= @Option)
		@QString @Port = "/COM3"
	@ElseIf (104 [= @Option)
		@QString @Port = "/COM4"
	@Else
		@QString @Port = "/COM1"
	@EndIf

    @QString @AutoMseStr = "@OutDrive:@DosSubDir\\EMOUSE.COM @Port"
    @QString @AutoNsdStr = "@OutDrive:@DosSubDir\\NSD.EXE /INITIALIZE @Port"
    @QString @AutoCalStr = "@OutDrive:@DosSubDir\\ECAL.EXE"
    @Integer @AutoDone = 0
    @Integer @AutoChange = 1
    @Integer @AutoExtCount = 0
    @Integer @AutoWin = 0

    /* Use the next two lines to create a unique temporary file name.   */

    @Integer @AutoTime = @SystemDate
    @QString @AutoFile = "@StrTail("@StrUpr("@AutoTime")",8).TMP"
@EndVars

@Display
   I will now analyze your AUTOEXEC.BAT to determine if any
   changes must be made to it.  Please wait.

   @Pause
@EndDisplay

@If(!@Exists("@BootDrive:\\autoexec.bat"))

    @Write( "@BootDrive:\\autoexec.bat", "wt", "@AutoMseStr\n" )
    @Write( , , "SET PATH=@OutDrive:@DosSubDir\n" )
    @Copy( "@BootDrive:\\autoexec.bat", "@BootDrive:\\autoexec.nfi" )
    @Write( , , "@AutoNsdStr\n" )
    @Write( , , "@AutoCalStr\n" )
    @Write( , , "COPY autoexec.nfi autoexec.bat /y" )

@Else
    /*  Get the first line of the Autoexec.bat  */

    @AutoDone = @Readln( "@BootDrive:\\autoexec.bat", "@@AutoLine" )
    @Write( "@BootDrive:\\@AutoFile", "wt", "" )

    /* Read the Autoexec.bat to the EOF */

AUTOLOOP:

    @If( @AutoDone == ( -1 ) )
    	@GoTo AUTOSKIP
    @EndIf

    @AutoUprLine = "@StrUpr( "@AutoLine" )"

    /*
    	Remove all line references to older/other driver products.
    */
    @If( ( @StrFind( "@AutoUprLine", "XBDTF" )   >= 0 ) ||
		 ( @StrFind( "@AutoUprLine", "XBARC" )   >= 0 ) ||
		 ( @StrFind( "@AutoUprLine", "XBDTC" )   >= 0 ) ||
		 ( @StrFind( "@AutoUprLine", "XBSC3" )   >= 0 ) ||
		 ( @StrFind( "@AutoUprLine", "XBPC2" )   >= 0 ) ||
		 ( @StrFind( "@AutoUprLine", "XBDSI" )   >= 0 ) ||
		 ( @StrFind( "@AutoUprLine", "XBDTFB" )  >= 0 ) ||
		 ( @StrFind( "@AutoUprLine", "XBDTF3" )  >= 0 ) ||
		 ( @StrFind( "@AutoUprLine", "XBDTF5" )  >= 0 ) ||
		 ( @StrFind( "@AutoUprLine", "XBDTFS" )  >= 0 ) ||
		 ( @StrFind( "@AutoUprLine", "ETSL" )    >= 0 ) ||
		 ( @StrFind( "@AutoUprLine", "EMOUSEL" ) >= 0 ) )

		@GoTo AUTONEXT
    @EndIf

    @If( @StrFind( "@AutoUprLine", "WIN" ) == 0 )
        @Display
        The WIN statement in your autoexec.bat must occur after
        the EMOUSE statement.  Moving WIN after EMOUSE.
        @Pause
        @EndDisplay

        @If( @AutoChange == 1 )
            @AutoWin = 1
            @StrDel( "@AutoUprLine", 1, 3 )
	    @GoTo AUTONEXT
        @EndIf
    @EndIf

    @If( @StrFind( "@AutoUprLine", "EMOUSE" ) >= 0 )
   		@Write( , , "@AutoMseStr\n" )
		@AutoChange = 0

    @Elseif( ( "@StrToken( "@AutoUprLine", 0, " \t=" )" == "PATH" ) ||
	     ( ( "@StrToken( "@AutoUprLine", 0, " \t=" )" == "SET" ) &&
	       ( "@StrToken( "@AutoUprLine", 1, " \t=" )" == "PATH" ) ) )

    	/*
    	    Check if PATH contains the default directory.
    	    If not, add the default directory to PATH.
    	*/
        @If( @StrFind( "@AutoUprLine", "@OutDrive:@DosSubDir" ) < 0 )

    	    @Write( , "at", "@AutoLine" )

    	    /*  Append a semi-colon to the end of the path if required  */
    	    @If( "@StrTail( "@AutoLine", 1 )" != ";" )
                    @Write( , "at", ";@OutDrive:@DosSubDir\n" )
    	    @Else
                    @Write( , "at", "@OutDrive:@DosSubDir\n" )
    	    @EndIf

    	@Else
    	    @Write( , "at", "@AutoLine\n" )
    	@EndIf

    @Else
    	@Write( , "at", "@AutoLine\n" )
    @EndIf

AUTONEXT:

    @AutoDone = @Readln(, "@@AutoLine")
    @GoTo AUTOLOOP

AUTOSKIP:

    /* get backup file extension for the AUTOEXEC.BAT file  */

    @If( @Exists( "@BootDrive:\\AUTOEXEC.@AutoExtCount" ) )
    	@AutoExtCount = ( @AutoExtCount + 1 )
	    @Goto AUTOSKIP
    @EndIf

    /*
    	If the command is not found in AUTOEXEC.BAT, append the
	    command to the end of the AUTOEXEC.BAT file.
    */
    @If( @AutoChange )
   		@Write( , , "@AutoMseStr\n" )
		@AutoChange = 0
    @EndIf

    @Copy( "@BootDrive:\\@AutoFile", "@BootDrive:\\autoexec.nfi" )

   	@Write( , , "@AutoNsdStr\n" )
   	@Write( , , "@AutoCalStr\n" )
    @Write( , , "COPY autoexec.nfi autoexec.bat /y" )

    @If( @AutoWin == 1 )
        @Write( , , "WIN\n" )
        @Write( "@BootDrive:\\autoexec.nfi", "wt", "WIN\n" )
    @EndIf

    /* Backup AUTOEXEC.BAT and rename TMP file to AUTOEXEC.BAT  */

    @Rename( "@BootDrive:\\AUTOEXEC.BAT", "Autoexec.@AutoExtCount" )
    @Rename( "@BootDrive:\\@AutoFile", "AUTOEXEC.BAT" )

@EndIf


/*
|==============================================================================
|
|       The @Finish section describes how to modify the SYSTEM.INI
|       file to load the drivers for Windows when it starts up.  This
|       is the last operation of the installation procedure.
|               
|==============================================================================
*/
@DefineVars
    @QString @PGroup= "Touch Screen"
    @QString @Icon1 = "@OutDrive:@WinSubDir\\QWERTY.EXE"
    @QString @Buttons="@OutDrive:@DOSSubdir\\SURROUND.DEF"
@EndVars

@Finish
	@If (@Platform == 3)
	@ProgramManager( "[DeleteGroup(@PGroup)]" )
        @ProgramManager( "[CreateGroup(@PGroup)][AddItem(@Icon1)]" )

		@SetINI( "boot", "mouse.drv", "emouse.drv", "system.ini" )
		@SetINI( "386enh", "mouse", "vmd.386", "system.ini" )
		@SetINI( "boot.description", "mouse.drv", "Dynapro NFI OEM Touch Screen Drivers version @Version", "system.ini" )
	@Endif

    /*
        Create a dummy BUTTONS file
    */
    @Write( @Buttons, "wt", " " )

	@Cls
    Please ensure that the hardware settings
    you have chosen do not conflict with any
    other hardware devices that may have been
    installed in your computer.

	Please reboot your computer.
	@Pause

@EndFinish

/* end-of-file */
