/*
 * Project: Match-n-Freq
 */

@DefineProject
	@Name = "Match-n-Freq"
        @ShowName(1, "Match-n-Freq (tm) for Match Filter Design",,2,40,15,@RGB(255, 255,0))
        @Version = "3.40"
	@Immediate = 1
	@Verify
	@Terse
	@Requires @HardDisk
	@Subdir = "\\OD-Tools"
	@OutDrive = C
	@Group = "i"
@EndProject

@NumberOfDisks = 1

@DefineVars
  @Integer @Win = @eval( 100 * @WindowsMajor + @WindowsMinor)
  @Integer @Red          = @RGB(255,0,0) //DEFINE COLOR RED
  @Integer @Green        = @RGB(0,255,0) //DEFINE COLOR GREEN
  @Integer @Blue         = @RGB(0,0,255) //DEFINE COLOR BLUE
  @Integer @Black        = @RGB(0,0,0)   //DEFINE COLOR BLACK
  @Integer @RetVal = 0
  @Integer @ErrorFlag = 0
  @Qstring @LineRead = ""
    // We have read the entire file when this 
    // variable equals (-1).
  @Integer @EOF = 0  
  @Integer @Found = @False
  @Qstring @MyDrive = "@OutDrive"
  @Qstring @ODpath = ""
  @Qstring @PM2= ""
  @Qstring @PMlist= ""
  @Qstring @RefLine="MF-03-000110"
       @Integer @NewHandle = 0
       @Integer @Status = 0
       @Integer @Disposition = 0
@EndVars
@BackgroundMode(3,@Blue,@Black)

// prototype all user-defined script functions
@DefineProto
    @Void @Message(@In @Integer @iTypeOfMessage,
	@In @Qstring @qMessageText)

    @Integer @DesktopCreateTopLevel(
	@In @Qstring @ObjectName, 
	@In @Integer @Common)

    @Integer @DesktopCreateItem(
	@In @Qstring @ExecutableFileName,
	@In @Qstring @Description, 
	@In @Qstring @IconFileName,
	@In @Integer @IconIndex)
@EndProto

// this is the message function from example 2 in this lesson
@DefineFunc @Void @Message(
    @In @Integer @iTypeOfMessage, 
    @In @Qstring @qMessageText)

    @If(@iTypeOfMessage == 0)
	@Display
            @Cls
	    Message: @qMessageText
	    @Pause
	@EndDisplay

    @ElseIf(@iTypeOfMessage == 1)
	@Display
	    Warning: @qMessageText
	    @Pause
	@EndDisplay
    
    @Else
	@Display
	    Error: @qMessageText
	    @Pause
	@EndDisplay
	@Abort
    @EndIf
    @Return()
@EndFunc
 
@DefineFunc @Integer @DesktopCreateTopLevel(
    @In @Qstring @ObjectName, 
    @In @Integer @Common)
 
    // Do a little error check to make sure the group name is valid, 
    // and that the @Common parameter is in the correct range 
    // of zero through one.  Note that we are using the @Message() 
    // function created in Example 2.

    @If(@StrLen("@ObjectName") > 25)
	@Message(2, "The 1st Parameter to @@DesktopCreateTopLevel() 
	should be a string less than 26 chars")
    @EndIf
 
    @If(@Common > 1 || @Common < 0)
	@Message(2, "The 2nd Parameter to @@DesktopCreateTopLevel() 
	should be either a 0 or a 1")
    @EndIf
 
    @If(@Platform == 3)    // Windows 3.XX / 95 / NT
        @If(@Win >= 400)  // Windows 95/98/NT
            // Windows 95, ignore @Common parameter
            @PM2 = "[CreateGroup(@ObjectName)]"
            @RetVal= @ProgramManager( "@PM2")
            @If(@RetVal != 0)
              @Message(2, "The @@ProgramManager() command as called from the 
               function @@DesktopCreateTopLevel() failed to execute properly.
               Note for developer ... @@PM2 = @PM2 & @@Win = @Win")
            @EndIf
        @EndIf
    @EndIf

    @Return(1)
@EndFunc // @DesktopCreateTopLevel()

// Now, we'll create the second function who's purpose is to add a 
// menu item to a Windows 95 "Start | Programs | XXXXX" menu 
// (the "XXXXX" indicates the name of the menu created using the 
// @DesktopCreateTopLevel() function).  This function does a lot of error 
// checking on the parameters to make sure they have reasonable values.

@DefineFunc @Integer @DesktopCreateItem(
    @In @Qstring @ExecutableFileName,
    @In @Qstring @Description, 
    @In @Qstring @IconFileName,
    @In @Integer @IconIndex)

    // there isn't much error checking we can do on the 
    // 1st parameter except to make sure that it was specified
    @If(@StrLen("@ExecutableFileName") <= 0)
        @Message(2, "The 1st Parameter to @@DesktopCreateItem() is required")
    @EndIf

    // make sure @Description isn't too long
    @If(@StrLen("@Description") > 25)
        @Message(2, "The 2nd Parameter to @@DesktopCreateItem() should 
        be a string less than 26 chars")
    @EndIf

    // if the @IconFileName was specified, make sure it exists
    @If(@StrLen("@IconFileName") > 0)
	@If(@Exists("@IconFileName") < 1)
	    @Message(2, "The 3rd parameter to @@DesktopCreateItem(), 
	    \"@IconFileName\" specifies a file that does not exist.")
	@EndIf
    @EndIf

    // there isn't really any error checking we can do 
    // for the @IconIndex var, so we skip it.
 
    // if execution gets here, then all parameters seem reasonable, 
    // so actually call the @ProgramManager() and have it execute the 
    // command.  If the return value from the  @ProgramManager() call 
    // is invalid, then we'll tell the end-user such.

    @PM2="[AddItem(@ExecutableFileName,@Description,@IconFileName,@IconIndex)]"
    @PMlist = "@PMlist@PM2"
    @Return(1)
@EndFunc // @DesktopCreateItem()

@Display
  @Move(11,18)
				     OD-Tools

	Math/Engineering software programs developed with the 
	use of a calculus based language, Fortran Calculus.
  @Pause
@EndDisplay

@Display
  @Move(11,5)
			       Match-n-Freq (tm)

     Finds the pole-zero locations of a transfer function, H(s), 
     for a matched filter.  H(s) equals a users desired Signal 
     (Yout) divided by a users given input Signal (Yin).
     Yout and Yin are functions of frequency.

     Group delay may also be equalized to a constant.
  @Pause
@EndDisplay

@Display
  @Move(11,5)
				    ODEcalc (tm)

     Solves an ODE with bounds (BVP) or initial conditions (IVP).
     ODE may be non-linear, implicit, && any order.  ODEcalc (tm) 
     is an example of rapid software development that is due to
     a Fortran Calculus.
  @Pause
@EndDisplay

@Display
  @Move(13,2)
				Installing 

	  @Name (tm) v. @Version ... a shareware program.
  @Pause
@EndDisplay

@Display
  @Move(6,2)
	  Hardware and software requirements for @Name are:
	  ==============================
		    Computer:  386+ IBM PC/AT with Math Co-processor
     Hard Disc storage:  4 Mb
		 OS Version:  DOS 3.3+
                    Windows:  95/98
  @Pause
@EndDisplay

@GetOutDrive
	@LocalWindow( 7, 34)
	@Suppress A
	@Suppress B
  //    @Suppress( 0, 1)  // Suppressed B drive only ... not A & B, why?
  //    @Suppress( 0,16)  // Suppresses CD-ROMs ( and Zip drives!! )
	@Cls
	     Select the disk drive where you wish to install @Name?
@EndOutDrive

@DlgCtrlSize(0, 8, 5, 9, 25)
// 'GetSubDir' has a bug in Windows 3.1 as of 5/98 ... won't show default name!
// @GetSubdir
//         Next specify the disk destination subdirectory.  The subdirectory
//         is the location on your disk where the @Name (tm) system will
//         be installed.
// 
//         Specify path without the drive letter.
// @EndSubdir

//
//      INSTALL will now prompt the end-user for the different parts of
//      the software they wish to install.
//
@DlgCtrlSize(0,-1,-1,0,0)
@DlgCtrlSize(0, 8, 10, 11, 60)
@If( @Win >= 400 && @Win < 411 && @ErrorFlag == 0)
  @ClearGroup(I)
  @SetGroup(A)
  @GetGroups
    @CheckBox
      Select the parts of @Name (tm) you wish to place on your
      computer system:

      @Set a = "All files"
      @Set o = "@Name (tm) files"
      @Set c = "'Base' files (includes graphics) ... all OD-Tools use these"
      
      //  I = User's Guide, Register info, etc. for NON-qualifying computers
  @EndGroups

  @Display
      @If ('A' [! @Group && 'C' [! @Group && 'O' [! @Group)

		 You didn't select anything to install.

		 Will terminate installation.
	  @Pause
	  @Abort
      @EndIf
  @EndDisplay
@Else
  @ErrorFlag = 1
  @SetGroup(I)
@Endif  // System meets minimum requirements?

@DesktopCreateTopLevel("Calculus Tools", 1)

// @ShowBMP( 0, 20, 20, "Equat5a.bmp", 2)
@DefineDisk
    @Label = "Disk #1"
    @BeginLib MFREQ.ode
                @F 8 @S 42087 @O        match.Hz\MANUAL.rtf
                @F 9 @S 1177 @O         Match.Hz\README.txt
                @F a @S 766 @O          match.Hz\readme.ICO
                @F b @S 4600 @O         Match.Hz\REGISTER.txt
                @F c @S 2066 @O         Match.Hz\VENDOR.txt
                @F d @S 545 @O          match.Hz\List-frq.pif
      @If( 'A' [= @Group || 'O' [= @Group)
                @F 0 @S 3652 @O         Match.Hz\User\EX-CNTL.1
                @F 1 @S 4332 @O         Match.Hz\User\EX-CNTL.2
                @F 2 @S 3955 @O         Match.Hz\User\EX-ZPAIR.1
                @F 3 @S 4005 @O         Match.Hz\User\EX-YZERO.101
                @F 4 @S 4041 @O         Match.Hz\User\EX-YZERO.102
                @F 5 @S 4453 @O         Match.Hz\User\EX-DELAY.101
                @F 6 @S 3952 @O         Match.Hz\User\EX-DELAY.111
                @F 7 @S 3825 @O         Match.Hz\User\EX-DELAY.112
                @F e @S 2992 @O         Match.Hz\DEMO.BAT
                @F f @S 2593 @O         Match.Hz\DEMO2.BAT
                @F g @S 476903 @O       Match.Hz\FREQ.EXE
                @F h @S 86989 @O        Match.Hz\FREQ-win.EXE
                @F i @S 766 @O          Match.Hz\FREQ-win.ICO
                @F j @S 7488 @O         Match.Hz\obj3d.dll
                @F k @S 5114 @O         Match.Hz\RUN-FREQ.BAT
                @F l @S 862 @O          match.Hz\startup.grp
      @EndIf
    @EndLib
    @If( 'A' [= @Group || 'C' [= @Group)
      @BeginLib base.ode
		@F 0 @S 548336 @O       @WinDrive:@WinDir\rlzrun20\rlzrun20.rts
		@F 1 @S 440640 @O       @WinDrive:@WinDir\cable.dll
		@F 2 @S 43270 @O        Trouble\TUNE.EXE
		@F 3 @S 7878 @O         Trouble\WHATMEM.EXE
		@F 4 @S 118302 @O       Trouble\386SETUP.EXE
		@F 5 @S 9769 @O         Sharewar\LICENSE
		@F 6 @S 110460 @O       Sharewar\LIST.DOC
		@F 7 @S 10515 @O        LIST.com
		@F 8 @S 1357 @O         Sharewar\Mailer
		@F 9 @S 9999 @O         Sharewar\Programs
		@F A @S 40432 @O        F77L3.eer
		@F b @S 251614 @O       Graphit.exe
		@F c @S 42714 @O        od-Wrap.exe
		@F d @S 181 @O          List.bat
		@F e @S 766 @O          List.ico
		@F f @S 615 @O          go.bat
		@F g @S 269 @O          go-ODE.bat
		@F H @S 3632 @O         Ask.exe
		@F i @S 81 @O           DOSstart.bat
		@F j @S 653 @O          Kill-CD.bat
		@F k @S 49 @O           Kill-CDw.bat
		@F l @S 1699 @O         Autoexec.bat
		@F m @S 1774 @O         Config-3.SYS
		@F n @S 1084 @O         Config-9.SYS
                @F o @S 311323 @O       od-PLT.EXE
      @EndLib
    @EndIf
@EndDisk

@ODpath = "@OutDrive:@SubDir"
@If( 'A' [= @Group || 'C' [= @Group || 'O' [= @Group)
  @If( @ErrorFlag == 0 )
    @ClearOption( 5)
    @If( @Spawn( "Subst g: c:\\") != 0)
      @SetOption( 5)
    @Else
      @RetVal = @Spawn( "Subst g: /d > nul")
    @EndIf

    @SetAutoexec
      @OverWrite
      @SetReplace("od-tools", "@ODpath")
    @EndAutoexec

    @SetConfig
      @OverWrite
      @Buffers = 30
      @Files = 30
      @If( 5 [= @Option)
	@LastDrive = g
      @Endif
    @EndConfig
  @Endif
@EndIf
  
@SetEnv("od-Tools", "@ODpath")

//  @EraseBMP( 0)
@Finish
  @ChDrive( @StartUpDrive)
  @ChDir( "@StartUpDir")
  @Copy("mFreq*.xml", "@ODpath\\*.*")
  @If( 'A' [= @Group && @ErrorFlag == 0)
    /*
     * For tracking purpose, add Reference number to several files
     */
    @If( @Exists("disk.id") )
      @RetVal = @ReadLine("disk.id", @LineRead)
      @RetVal = @ReadLine(, @LineRead)
      @RetVal = @ReadLine(, @LineRead)
      @RetVal = @ReadLine(, @LineRead)
    @Endif
    @If( "@LineRead" == "" || @RetVal == -1)  // Empty or EOF
      @LineRead = "@RefLine"
    @EndIf
    @Write("@ODpath\\Match.Hz\\VENDOR.txt", "at", "          @LineRead\n")
    @Write("@ODpath\\Match.Hz\\register.txt", "at", "      @LineRead\n")
  @EndIf
  @If ('A' [! @Group && 'C' [! @Group && 'O' [! @Group && @ErrorFlag == 0)
    @CLS
		 Information files installed.

		 Read users guide in their sub-directory.

		 Will terminate installation.
    @Pause
    @Abort
  @EndIf
  @ChDrive( @OutDrive)
  @ChDir( "@SubDir")
  @If( @ErrorFlag == 1 )
     @Cls
     @move( 4, 5)
     Copied information files, only.  Your system did NOT pass INSTALL's
     verification for the following @Name system requirements:

	 ©============================================©
	 ©   Hardware / software requirements that failed are:      ©
	 ©============================================©
                                Non Windows 95/98
     @Pause
  @Else
  /*
   * Modifying the file AutoExec.bat file with the last drive
   * found on this PC station.
   */
    @If( @Exists("AutoExec.bat") )
      @Write("AutoExec.bat", "at", "set RAMdsk=@MyDrive:\n")
    @Endif
  /*
   * Copy README.TXT file into both directories
   */
    @If( 'A' [= @Group || 'O' [= @Group)
      @Copy("@ODpath\\Match.Hz\\README.txt", "@ODpath")
    @Endif
  /*
   * Check to see if 'temp' directory exists for temp. plot files
   */
    @If( @DirExists("@ODpath\\temp") != 1)
      @MkDir("@ODpath\\temp")
    @Endif
  /*
   * Copy Graphit.exe file into both directories
   */
    @If( @Exists("Graphit.exe") )
      @If( 'A' [= @Group || 'O' [= @Group)
	@copy("@ODpath\\f77l3.err", "@ODpath\\Match.Hz")
	@copy("@ODpath\\graphit.exe", "@ODpath\\Match.Hz")
      @Endif
    @Else
      @If( 'A' [= @Group)
	@Cls
	@move( 4, 5)
     
	     ©=====================================©
	     ©  @Name (tm) directory STRUCTURE error!     ©
	     ©=====================================©
     
     Graphit.exe file is missing from @ODpath directory.  This 
     file is necessary to install @Name.  Please re-install 
     Optimal Designs's BASE directory files in your '\OD-Tools'
     directory.
	@Pause                               
	@Abort
      @EndIf
    @EndIf
  /* For Win 95/98 ...
   * Copy DOSstart.bat file to *.ODE for backup and setup new DOSstart.bat
   */
    @If( 'A' [= @Group || 'O' [= @Group)
      @If( @Exists("@WinDrive:@WinDir\\DOSstart.bat") )
        @If( @Exists( "@WinDrive:@WinDir\\DOSstart.ode") < 1) // not exists then
          @copy("@WinDrive:@WinDir\\DOSstart.bat", "@WinDrive:@WinDir\\DOSstart.ode")
        @EndIf
        @delete("@WinDrive:@WinDir\\DOSstart.bat")
        @copy("@ODpath\\DOSstart.bat", "@WinDrive:@WinDir\\DOSstart.bat")
        @copy("@WinDrive:@WinDir\\DOSstart.ODE", "@WinDrive:@WinDir\\kill-CDw.bat")
      @Endif
    //
    // now try out the two functions (from wInstall manual)
    @DesktopCreateItem("@ODpath\\Match.Hz\\List-frq.pif","List Match-n-Freq output","@ODpath\\list.ico", 0)
  @EndIf
  
  @If(@Platform == 3)  // Windows 3.X, Windows 95, or Windows NT
     @If(@Win >= 400)  // Windows 95/98/NT
	@DesktopCreateItem("@ODpath\\Match.Hz\\manual.rtf","Match-n-Freq Manual","@ODpath\\Match.Hz\\readme.ico", 0)
	@Status = @WinRegCreateKeyEx(
		     @HKeyLocalMachine, 
                     "Software\\Optimal Designs Enterprise\\Match-n-Freq", 
                     "Calculus",
		     0,      // no special options
		     4,      // permission to create sub keys
		     @Null, // default security
		     @NewHandle,
		     @Disposition)
     @EndIf
     @If(@Status == 0)       // It worked properly
/*      @CLS
           @If(@Disposition == 1)
		 The key was created successfully.
	   @ElseIf(@Disposition == 2)
		 The pre-existing key was opened successfully.
	   @Else
		 The key was successfully opened, but the value
		 of @Disposition is undocumented.
	   @EndIf

	    @@WinRegCreateKey() return value: @Status
	    @@NewHandle: @NewHandle
	    @@Disposition: @Disposition
	
	    @Pause
*/      // Now associate a text value with this key
        @If(@Win >= 400)  //  Windows 95/98/NT
	   @Status = @WinRegSetValueEx(@NewHandle,
                     "Software\\Optimal Designs Enterprise\\Match-n-Freq", 
		     1, // string type -or- 4 for 32-bit word
                     "@Version",             // String "data"
		     4)                 // size of "data" string + 1
	@EndIf
		
	// Now close key (it is dangerous to leave a key open)
	@Status = @WinRegCloseKey(@NewHandle)
	@If(@Status != 0)
	   @CLS
              Error: The Registry key was NOT closed successfully.
	
	      @Pause
	@EndIf
     @Else    // Some type of error occurred.
	   @CLS
              Error: The Registry key was NOT created successfully.
	
	     @Pause
     @EndIf
  @EndIf
  
  @If( 'A' [= @Group || 'O' [= @Group)
    @DesktopCreateItem("@ODpath\\Match.Hz\\Freq-win.exe", "Match-n-Freq Program", "@ODpath\\Match.Hz\\Freq-win.ico", 0)
  @EndIf
  @RetVal= @ProgramManager( "@PMlist")
  @If(@RetVal != 0)
      @Message(2, "The @@ProgramManager() command as called from the 
	 function @@DesktopCreateItem() failed to execute properly.")
  @EndIf
  @If( @NDP == 0)    //Math co-processor available ?
    @CLS
			=== Warning ===
	   An 80x87 chip is required for @Name (tm) to run.

	   If you do have a 80x87 (Math co-processor) chip,
	   disregard this warning message.

       @Pause
  @EndIf
  @If( @ErrorFlag == 0 )
    @CLS
    Installation is complete.
    
    Please view the README.TXT && MANUAL.RTF files for more 
    information.

    Share @Name (tm) with your friends.

    Register @Name (tm) program, if program is helpful.
    @Pause
    @Reboot("Rebooting your machine.", 0)
  @EndIf
  @ChDrive( @OutDrive)
  @ChDir( "@SubDir")
@EndFinish
/* End-of-file */
