/*
 *         Databook installation script file for use with 
 *                       TMB-240 and TMB-250
 *                    CardTalk Software 
 */

@DefineProject
	@Name    = "Databook CardTalk Software TMB-240/250"    
	@Subdir         = "\\CardTalk\\"                
	@Version        = "3.10"
	@OutDrive       = C
@EndProject

// Version      Author          Comments
// 3.0          jeg             Original implementation
// 3.01 (3.1?)  prs             Added Windows & Multi-TCIC support
// 3.02         rff             initialized variables, "DB_FFS2",
//                              bump disk req, fix ElseIf in 4-com code
//                              add admonition to read README.1ST
// 3.03         johnk           Make @Version init a 'sed' target.
// 3.10         jeg             Added support for CardTalk Guide and
//                              CardTalk.SYS command line options.
//              jeg             Fixed COMxIRQ above 9 and no /MEMW /IOW case.
//		johnk		Convert to use one driver for both 240&250

// Options used in this install.dat
//      @Option   1 = "WITH Microsoft Flash File System (FFS-2)"
//      @Option   2 = "WITHOUT Microsoft Flash File System (FFS-2)"
//      @Option 101 = "Databook TMB-240 Drive"
//      @Option 102 = "Databook TMB-250 Drive"
//      @Option 201 = "COM 1"
//      @Option 202 = "COM 2"
//      @Option 203 = "COM 3"
//      @Option 204 = "COM 4"
//      @Option 299 = "Auto"
//      @Option 301 = "Card Insertion Annunciator Active"
//      @Option 302 = "Card Insertion Annunciator Not Active"
//      @Option 401 = "Continue installation"
//      @Option 402 = "Reselect Install options"
//      @Option 403 = "Quit Install, return to DOS"
//      @Option 501 = "Don't select an IO and Memory Window"
//      @Option 502 = "Select an IO and Memory Window"
//      @Option 601 = "Express Install"
//      @Option 602 = "Custom Install"
//      @Option 701 = "Install Windows GUI"
//      @Option 702 = "Don't install Windows GUI"


   @DefineVars
	   @QString @Dbook1 = "\xDC\xDC\xDC\xDC\xDC\xDC\xDC\xDC\xDC\xDC\xDC\xDC\xDC\xDC\xDC"
	   @QString @Dbook2 = "\xDB\xDB\xDB\xDB\xDF\xDF\xDF\xDF\xDF\xDF\xDF\xDF\xDF\xDF\xDF"
	   @QString @Dbook3 = "\xDC\xDC\xDC\xDC\x20\x20\x20\x20\x20\x20\x20\x20\x20\xDF\xDF\xDF\xDF"
	   @QString @Dbook4 = "\xDB\xDB\xDB\xDB\xDB\xDB\xDB\xDB\xDB\xDB\xDB\xDB\xDB\xDB\xDB"

	   @Integer @DiskRequired       = 2500000

	   @Qstring @FileBuffer         = ""
	   @Integer @InFile             = 0
	   @Integer @Counter            = 0
	   @Qstring @TempStr            = ""
	   @Qstring @GUIYesNo           = ""
	   @Qstring @HWFound            = ""
	   @Qstring @SWFound            = ""
	   @Qstring @Driver             = ""
	   @Qstring @Name1              = ""

	   @Integer @Temp               = 0
	   @Integer @MultiConfig        = 0

	   @Integer @MemMgrLine         = 9999
	   @Integer @DoubleSpaceLine    = 9999
	   @Integer @ConfigLoc          = 9999

	   @Qstring @MemExclude         = "D000-D7FF"
	   @Qstring @IOWinSTDefault     = "300"
	   @Qstring @IOWinSPDefault     = "31F"
	   @Qstring @MEMWinSTDefault    = "D000"
	   @Qstring @MEMWinSPDefault    = "D7FF"
	   @Qstring @ATAopt             = "170"

	   @Integer @ATALoc             = 0
	   @Integer @IOWLoc             = 0
	   @Integer @MEMWLoc            = 0
	   @Integer @NextPort           = 0
	   @Integer @SerPort            = 0
	   @Integer @SerIRQ             = 0
	   @QString @Address            = ""
	   @QString @TempAddress        = ""
	   @QString @Socket             = ""
	   @Qstring @SerOpts            = ""
	   @Qstring @AnnOpts            = ""
	   @Qstring @IOWOpts            = ""
	   @Qstring @MEMWOpts           = ""
	   @Qstring @IOWinST            = @IOWinSTDefault
	   @Qstring @IOWinSP            = @IOWinSPDefault
	   @Qstring @MemWinST           = @MEMWinSTDefault
	   @Qstring @MemWinSP           = @MEMWinSPDefault
	   
   @EndVars

/*
 * Display the Sign On Message
 */

@Display
	@Cls
	@Dbook1
	@Dbook2
	@Dbook3
	@Dbook3
	@Dbook3         DATABOOK
	@Dbook3       
	@Dbook3       INCORPORATED
	@Dbook3
	@Dbook3
	@Dbook4

	CardTalk Installation Program


	This program installs @Name,
	Version @Version on your computer system.


				  @Pause
@EndDisplay

/*
 * Check The DOS version to be greater or Equal to 3.30
 */

@If (((@OSMajor*100)+@OSMinor) < 330) 
   @Display
		@Cls

	To use @Name
	you need DOS version 3.3 or higher.  The DOS version on
	your system is less than 3.3.

		@Abort
	@EndDisplay
@EndIf                                                                        

/*
 * Check for existing CardTalk Driver and use option line.
 */

@If ("@CTCfgTail" != "")
	@ATALoc = @StrFind(@StrUpper(@CTCfgTail), "/ATA")
	@If (@ATALoc != -1)
		@ATAopt = @StrMid(@CTCfgTail, (@ATALoc + 5), 3)
	@Endif
@Endif

@If ("@CTCfgTail" != "")
	@IOWLoc = @StrFind(@StrUpper(@CTCfgTail), "/IOW")
	@If (@IOWLoc != -1)
		@IOWinSTDefault = @StrMid(@CTCfgTail, (@IOWLoc + 5), 3)
		@IOWinSPDefault = @StrMid(@CTCfgTail, (@IOWLoc + 9), 3)
	@Endif
@Endif

@If ("@CTCfgTail" != "")
	@MEMWLoc = @StrFind(@StrUpper(@CTCfgTail), "/MEMW")
	@If (@MEMWLoc != -1)
		@MEMWinSTDefault = @StrMid(@CTCfgTail, (@MEMWLoc + 6), 4)
		@MEMWinSPDefault = @StrMid(@CTCfgTail, (@MEMWLoc + 11), 4)
	@Endif
@Endif

/*
 * Allow the user to select Custom/Express install, but only
 * if we can identify the hardware in the system as a single
 * known controller.
 */
@If (@NumHWPorts != 1)
	@GoTo UnknownHardware
@Endif

@TempStr = @StrToken("@hwPortSockCnt", 0)
@If ("@TempStr" == "1")
	@SetOption(101)
	@Name1    = "Databook CardTalk Software TMB-240"    
@ElseIf ( "@TempStr" == "2")
//	@SetOption(102)
//	@Name1    = "Databook CardTalk Software TMB-250"    
	@SetOption(101)
	@Name1    = "Databook CardTalk Software TMB-240"    
@Else
	@GoTo UnknownHardware
@EndIf
@Address = @StrToken(@HWportlist, 0)

@GetOption
	@Cls
	@LocalWindow(17,35)
	Installation of @Name:

	Two types of installation programs are available for your 
	convenience: Express and Custom Install.

	Express Install automatically chooses factory defaults and 
	updates your CONFIG.SYS and AUTOEXEC.BAT files. With this option
	there may be up to a 1 minute delay before the next screen appears
	while Install is determining your system configuration.

  Custom Install allows you to modify default parameters and gives 
  you the options of loading the Microsoft Flash File System.
//   Custom Install allows you to modify default parameters.
//   




	Use the UP/DOWN arrow keys to highlight your choice. Then press
	the [ENTER] key to continue.
	@Option 601 = "Express Install"
	@Option 602 = "Custom Install"

@EndOption

@If (601 [= @Option)            // Skip the entering of options
	@SetOption(2)           // Skip loading of FFS2
	@SetOption(299)         // Auto COM selection
	@SetOption(301)         // Annunciator active
	@SetOption(701)         // Install Windows GUI
	@AnnOpts = "/A"
	@Goto CheckDriveSpace
@EndIf


UnknownHardware:
TryAgain:
/*
 * Display product name and version information
 * and installed hardware and software
 */

@If (@NumHWPorts != 0)
	@If (@NumHWPorts == 1)
		@HWFound = "       1 controller at @HWPortList"
	@Else
		// Parse port list to insert commas if needed
		@Temp = 0
		@Address = ""
CommaLoopTop:
		@TempStr = @StrToken(@HWPortList, @Temp)
		@If ("@TempStr" == "")
			@Goto CommaLoopEnd
		@EndIf
		@If("@Address" != "")
			@Address = "@Address, "
		@EndIf
		@Address = "@Address@TempStr"
		@Temp = (@Temp + 1)
		@Goto CommaLoopTop
CommaLoopEnd:

		@HWFound = "       @NumHWPorts controllers at @Address"
	@Endif
	@If ("@ssPStr" != "")
		@HWFound = "@HWFound for @ssPStr"
	@Endif
@Else
	@HWFound = "       No installed PCMCIA hardware"
@EndIf

@SWFound = "       No installed PCMCIA software"
@If (@SSMajor != 0)
	@SWFound = "       Socket Services version @SSMajor.@SSMinor @SSVstr"
@EndIf

@If (@CSMajor != 0)
	@SWFound = "@SWFound\n       Card Services version @CSMajor.@CSMinor @CSVstr"
@Else
	@SWFound = "@SWFound\n"
@EndIf

@If ("@ctVstr" != "")
	@SWFound = "@SWFound\n       CardTalk @CTVstr"
@Else
	@SWFound = "@SWFound\n"
@EndIf

@Display
	@Cls
	Installation of @Name:

	INSTALL has detected:
@HWFound
@SWFound

	PLEASE READ THE "README.1ST" FILE AND "QUICK-START USER'S GUIDE"
	THOROUGHLY BEFORE YOU INSTALL THE TMB-240/250 IN YOUR SYSTEM.

	During a normal installation, INSTALL will correctly update your 
	CONFIG.SYS. However, if you have installed PCMCIA software from
	another manufacturer, you may have to remove the appropriate device
	installation lines from your CONFIG.SYS file manually after running
	INSTALL but before you reboot.

				  @Pause
@EndDisplay

/*
 * Get drive to install CardTalk
 * also entry point if user made wrong selection
 */

@FlushOptions

@GetOutDrive
	@Cls
	Installation of @Name:
	

	Select a drive to install CardTalk.
	






	@LocalWindow(13,38)
	  





	Use the UP/DOWN arrow keys to highlight the appropriate drive
	then press [ENTER] to select.

@EndOutDrive

CheckDriveSpace:

/*
 * Check if drive has enough room
 */

@If (@DiskFree @OutDrive < @DiskRequired) 
	@Display
	@Cls
	The selected output disk drive only has @DiskFree @OutDrive bytes.
	The @Name 
	requires @DiskRequired bytes.
	@Abort
	@EndDisplay
@EndIf

@If (601 [= @Option)            // Skip the entering of options
	@Goto BeginInstall
@EndIf

/*
 * Get subdirectory to install CardTalk
 */

GetSubDir:

//@If ("@ctCfgPath" != "")
//      @TempStr = @StrToken(@ctCfgPath, 1, "\\")
//      @Subdir = "\\@TempStr\\"
//@Endif

@GetSubdir
	@Cls
	Installation of @Name:
	
	INSTALL will place the @Name in 
	the subdirectory below on drive @OutDrive.
@If ("@ctCfgPath" != "")
	INSTALL has detected CardTalk at @ctCfgPath. 
@Else



@Endif





	@LocalWindow(13,48)


	To install to a different subdirectory than suggested above,
	press the [BACKSPACE] key to erase the current name and type
	a new name, up to 8 characters.  Press [ENTER] when done.
@EndSubdir

@If (@StrLen("@SubDir") > 9)
   @Beep
   @Goto GetSubDir
@EndIf

/*
 * Determine drive type to install
 */

@If (@numHWPorts == 0)
	@Socket = "0"
	@TempStr = "INSTALL has not detected any controllers."
@Else
	@Socket = @StrToken(@HWPortSockCnt, 0)
	@If ("@Socket" == "1")
		@TempStr = "INSTALL has detected a controller with 1 socket."
	@Else
		@TempStr = "INSTALL has detected a controller with @Socket sockets."
	@Endif
@Endif

//@GetOption
//	@Cls
//	Installation of @Name:
//	
//	@TempStr
//
//	Select the type of drive that you wish to install. A TMB-240
//	has one PCMCIA socket and a TMB-250 has two PCMCIA sockets. You can
//	determine which one you have by counting the number of card ejectors.
//	
//
//
//
//
//
//
//
//
//	@LocalWindow(17,38)
//@If ("@Socket" == "2")
//	@Option 102 = "Databook TMB-250 Drive"
//	@Option 101 = "Databook TMB-240 Drive"
//@Else
//	@Option 101 = "Databook TMB-240 Drive"
//	@Option 102 = "Databook TMB-250 Drive"
//@Endif
//	Use the UP/DOWN arrow keys to highlight your choice.  Then press
//	the [ENTER] key to continue.
//@EndOption           

// These names change in 2 places!!!
//@If ( 101 [= @Option )
//	@Name1    = "Databook CardTalk Software TMB-240"    
//@Endif
//@If ( 102 [= @Option )
//	@Name1    = "Databook CardTalk Software TMB-250"    
//@Endif
	@Name1    = "Databook CardTalk Software TMB-240"    

/*
 * Determine the base IO port for the drive
 */

GetAddress:

@If (@numHWPorts == 0)
	@Address = "240"
	@TempStr = "The default base address for the TMB-240/250 controller is 240."
@Else
	@If (@numHWPorts == 1)
		@TempStr = "INSTALL has detected a PCMCIA controller at @Address."
	@Else
		@TempStr = "INSTALL has detected PCMCIA controllers at @Address."
	@Endif
@Endif

@TempAddress = @Address
@GetString @TempAddress
   @Cls
	Installation of @Name1:
	
	@TempStr

	If the TMB-240/250 jumpers are set to a different base address, or 
	you have more than one TMB-240/250 in your system, change the
	the value(s) below to match your base address(es).
	Refer to Databook Quick-Start Users Guide Chapter 3 "Setup and 
	Installation" for more information. 





	@LocalWindow(14,48)
	@Prompt = "Enter Controller's Address(es):"

	To edit, press the [BACKSPACE] key to erase the current value(s) and 
	type a new value or values between 100 and 3F0. If entering more than  
	one value, separate them by at least one space, and no more than one
	comma. Press [ENTER] when done.
@EndString

/*
 * Validate the base IO port(s) for the drive
 */
@Temp = 0
ValidateLoopTop:
	@TempStr = @StrToken(@TempAddress, @Temp, ", ")
	@If ("@TempStr" == "")
		@Goto ValidateLoopEnd
	@EndIf

	@If (@StrLen(@TempStr) != 3)
		@Beep
		@Goto GetAddress
	@EndIf
	@If (@StrToInt(@StrMid("@TempStr",2,1)) != 0)
		@Beep
		@Goto GetAddress
	@Endif
	@If (@StrToInt(@StrMid("@TempStr",0,1)) > 3)
		@Beep
		@Goto GetAddress
	@Endif
	@If (@StrToInt(@StrMid("@TempStr",0,1)) < 1)
		@Beep
		@Goto GetAddress
	@Endif
	@Temp = (@Temp + 1)
	@GoTo ValidateLoopTop
ValidateLoopEnd:
@Address = "@TempAddress"

GetATAaddr:
/*
 * Determine if optional ATA address is to be used
 */
@GetString @ATAopt
   @Cls
	Installation of @Name1:
	

	Some computer systems contain a secondary IDE controller
	at I/O address 170, which is the default address used for
	PCMCIA ATA drives. If your system has a secondary IDE
	controller, change the value below to a free I/O address.
	The I/O address 180 is usually available for this purpose;
	refer to your computer's documentation for more information.






	@LocalWindow(16,48)
	@Prompt = "Enter ATA Address:"

	To edit, press the [BACKSPACE] key to erase the current value and 
	Type a new value between 100 and 200.  Press [ENTER] when done.
@EndString
@If (@StrLen(@ATAopt) != 3)
   @Beep
   @Goto GetATAaddr
@EndIf
@If (@StrToInt(@StrMid("@ATAopt",0,1)) > 2)
   @Beep
   @Goto GetATAaddr
@Endif
@If (@StrToInt(@StrMid("@ATAopt",0,1)) < 1)
   @Beep
   @Goto GetATAaddr
@Endif

/*
 * Determine if FFS2 is to be installed
 */

@GetOption
	@Cls
	Installation of @Name1:
	
	
	If you intend to use FLASH cards and the Flash File System you
	should install FFS-2 now. If you want to use FLASH cards but not
	the Flash File System it is not necessary to install FFS-2. IF you
	do not intend to use FLASH cards then you should not install FFS-2.

	FFS-2 will use approximately 50K of conventional memory.
	Installing FFS-2 will reduce the memory available to other programs.



	
	


	@LocalWindow(17,38)
	@Option 2 = "WITHOUT Microsoft Flash File System (FFS-2)"
	@Option 1 = "WITH Microsoft Flash File System (FFS-2)"
							   
	Use the UP/DOWN arrow keys to highlight your choice.  Then press
	the [ENTER] key to continue.
@EndOption

//   @SetOption(2)           // Skip loading of FFS2

/*
 * Determine if annunciator is to be active
 */

@GetOption
	@Cls
	Installation of @Name1:
	

	If you wish to have the CardTalk Card Insertion Annunciator inform
	you about the status of a card upon insertion, you should activate 
	this feature below. The annunciator will produce one, two or
	three beeps as follows:

	1 beep:  CardTalk has recognized and configured the card.

	2 beeps: CardTalk did not recognize the card.

	3 beeps: CardTalk recognized but could not configure the card.
	
	


	@LocalWindow(17,38)
	@Option 301 = "Card Insertion Annunciator Active"
	@Option 302 = "Card Insertion Annunciator Not Active"
							   
	Use the UP/DOWN arrow keys to highlight your choice.  Then press
	the [ENTER] key to continue.
@EndOption

@If ( 301 [= @Option )
	@AnnOpts = "/A"
@Endif

/*
 * Dertermine serial port to assign to serial cards
 */

@If (@ComTotal < 4)
	@Goto GetSerial
@Else                                   // rff -- was @ElseIf
  @Display
	Installation of @Name1:
	
	This machine has all 4 COM ports installed; PCMCIA cards which
	contain serial ports (such as modem cards) will not operate.
	You will have to remove or disable at least one COM port before
	using these types of cards.
	@Pause
  @EndDisplay
@Endif
@Goto EndSerial

GetSerial:

@If (@ComTotal == 0)
	@NextPort = 1
@ElseIf (@ComTotal == 1)
	@NextPort = 2
@ElseIf (@ComTotal == 2)
	@NextPort = 3
@Else
	@NextPort = 4
@Endif

@GetOption
	@Cls
	Installation of @Name1:
	
	This machine has the following COM ports, indicated below, available
	for use by those PCMCIA cards requiring a serial port. You may ask
	CardTalk to reserve a specific port upon card insertion.

	Or you may use the default which lets CardTalk automatically
	select the next available COM port upon card insertion. The next
	available COM port is COM@NextPort, but this will change if you add or delete
	COM ports in the system.
	@LocalWindow(15,38)      
	@Option 299 = "Auto"
@If (@ComTotal < 1 )
	@Option 201 = "COM 1"
@EndIf
@If (@ComTotal < 2 )
	@Option 202 = "COM 2"
@EndIf
@If (@ComTotal < 3)
	@Option 203 = "COM 3"
@EndIf
@If (@ComTotal < 4)
	@Option 204 = "COM 4"
@EndIf
	Use the UP/DOWN arrow keys to highlight your choice.  Then press
	the [ENTER] key to continue.
@EndOption

@If ( 299 [= @Option )
	@Goto EndSerial
@Endif

/*
 * If user selected a fixed serial port the get the IRQ
 */

GetIRQ:

@If ( 201 [= @Option )
	@SerPort = 1
	@SerIRQ = 4
@ElseIf ( 202 [= @Option)
	@SerPort = 2
	@SerIRQ = 3
@ElseIf ( 203 [= @Option)
	@SerPort = 3
	@SerIRQ = 4
@ElseIf ( 204 [= @Option)
	@SerPort = 4
	@SerIRQ = 3
@EndIf

@GetInteger @SerIRQ
	Installation of @Name1:
	
	You can select the interrupt number below used in conjunction with
	COM@SerPort previously selected. You only need to change the interrupt
	number if your system cannot share COM interrupts.

	If you change the interrupt number here you must also change the
	interrupt number that your communications software uses. Review the
	manual for your communications software to change its interrupt.

	The default interrupt request line (IRQ) for COM@SerPort is IRQ @SerIRQ.
	This should be satisfactory in most cases. The most common interrupt
	to select if the default is not suitable is IRQ 5.


	@LocalWindow(16,48)
	@Prompt = "IRQ # "

	If you want to select a different IRQ, press the
	[BACKSPACE] key to erase the default value, then type the 
	new value from 3 to 15. Press [ENTER] when done.
@EndInteger

/*
 * Validate the IRQ number
 */

@If (@StrLen("@SerIRQ") < 0)
   @Beep
   @Goto GetIRQ
@EndIf
@If (@StrLen("@SerIRQ") > 2)
   @Beep
   @Goto GetIRQ
@EndIf
@If (@SerIRQ < 3)
   @Beep
   @Goto GetIRQ
@Endif
@If (@SerIRQ > 15)
   @Beep
   @Goto GetIRQ
@Endif

@TempStr = "IRQ="
@SerOpts = "/SERIAL=@SerPort /COM@SerPort@TempStr@SerIRQ"


EndSerial:

/*
 * Determine if the user wants to select an IO window for Card Services
 */

@GetOption
	@Cls
	Installation of @Name1:
	
	If you are using a network card you should select below a specific IO
	and Memory Window for that card. Then CardTalk can make the window(s)
	available to the card upon insertion. Many network cards require an IO
	Window with a beginning address of @IOWinSTDefault and ending at @IOWinSPDefault and a Memory
	Window from @MEMWinSTDefault to @MEMWinSPDefault. Check the cards documentation to determine
	the exact requirements.

	If you are only using cards such as SRAM, FLASH, MODEM, FAX and ATA
	do not select a specific IO or Memory Window because CardTalk already
	knows which window to select.





	@LocalWindow(17,38)
	@Option 501 = "Don't select an IO and Memory Window"
	@Option 502 = "Select an IO and Memory Window"

	Use the UP/DOWN arrow keys to highlight your choice.  Then press
	the [ENTER] key to continue.
@EndOption           

@If (501 [= @Option)
   @ClearOption(501)
   @IOWOpts = "/IOW"
   @MEMWOpts = "/MEMW"
   @Goto SkipIOMem
@EndIf

/*
 * Determine the IO window starting address for Card Services
 */

GetIOWinST:

@IOWinST = @IOWinSTDefault

@GetString @IOWinST
	@Cls
	Installation of @Name1:

	Selecting an IO Window requires two steps. First select the starting
	address of the window below. Then select the ending address in the
	next screen.

	The correct starting address may be determined by consulting the
	users manual for the card regarding which IO addresses are needed by
	the card and its driver software. Typically a card will support
	several address ranges. After determining a proposed starting address
	you must examine other devices in your system to ensure that this
	address does not conflict.

	The default starting address is @IOWinSTDefault which should be sufficient for
	most cards. The default ending address is @IOWinSPDefault in the next screen.

	@LocalWindow(17,48)
	@Prompt = "Enter the IO Window's Starting Address:"

	To edit, press the [BACKSPACE] key to erase the current value and 
	Type a new value between 100 and 3FF.  Press [ENTER] when done.
@EndString

/*
 * Validate the IO window starting address
 */

@If (@StrLen(@IOWinST) != 3)
   @Beep
   @Goto GetIOWinST
@EndIf
@If (@StrToInt(@StrMid("@IOWinST",0,1)) > 3)
   @Beep
   @Goto GetIOWinST
@Endif
@If (@StrToInt(@StrMid("@IOWinST",0,1)) < 1)
   @Beep
   @Goto GetIOWinST
@Endif

GetIOWinSP:

@IOWinSP = @IOWinSPDefault

@GetString @IOWinSP
	@Cls
	Installation of @Name1:
	
	Now select the IO Window ending address below. The correct ending
	address may be determined by consulting the users manual for the card
	regarding which IO addresses are needed by the card and its driver
	software. Typically a card will support several address ranges. After
	determining a proposed ending address you must examine other devices
	in your system to ensure that this address does not conflict.

	The default ending address is @IOWinSPDefault which should be sufficient for
	most cards. The ending address should be greater than or equal to the
	starting address prevoiusly selected at @IOWinST.


	@LocalWindow(16,48)
	@Prompt = "Enter the IO Window's Ending Address:"


	To edit, press the [BACKSPACE] key to erase the current value and 
	Type a new value between 100 and 3FF.  Press [ENTER] when done.
@EndString

/*
 * Validate the IO window ending address
 */

@If (@StrLen(@IOWinSP) != 3)
   @Beep
   @Goto GetIOWinSP
@EndIf
@If (@StrToInt(@StrMid("@IOWinSP",0,1)) > 3)
   @Beep
   @Goto GetIOWinSP
@Endif
@If (@StrToInt(@StrMid("@IOWinSP",0,1)) < 1)
   @Beep
   @Goto GetIOWinSP
@Endif

GetMEMWinST:

@MEMWinST = @MEMWinSTDefault

@GetString @MEMWinST
	@Cls
	Installation of @Name1:
	
	Selecting an Memory Window requires two steps. First select the
	starting address of the window below. Then select the ending address
	in the next screen.

	The correct starting address may be determined by consulting the
	users manual for the card regarding which Memory addresses are needed
	by the card and its driver software. Typically a card will support
	several address ranges. After determining a proposed starting address
	you must examine other devices in your system to ensure that this
	address does not conflict.

	The default starting address is @MEMWinSTDefault which should be sufficient for
	most cards. The default ending address is @MEMWinSPDefault in the next screen.

	@LocalWindow(17,48)
	@Prompt = "Enter the Mem Window's Starting Address:"

	To edit, press the [BACKSPACE] key to erase the current value and 
	Type a new value between C000 and EFFF.  Press [ENTER] when done.
@EndString

/*
 * Validate the MEM window starting address
 */

@If (@StrLen(@MEMWinST) != 4)
   @Beep
   @Goto GetMEMWinST
@EndIf
//@TmpStr = @StrMid("@MEMWinST",0,1)
@If ("@StrMid("@MEMWinST",0,1)" == "C")
   @Goto GetMEMWinSP
@Endif
@If ("@StrMid("@MEMWinST",0,1)" == "D")
   @Goto GetMEMWinSP
@Endif
@If ("@StrMid("@MEMWinST",0,1)" == "E")
   @Goto GetMEMWinSP
@Endif
   @Beep
   @Goto GetMEMWinST

GetMEMWinSP:

@MEMWinSP = @MEMWinSPDefault

@GetString @MEMWinSP
	@Cls
	Installation of @Name1:
	

	Now select the Memory Window ending address below. The correct ending
	address may be determined by consulting the users manual for the card
	regarding which memory addresses are needed by the card and driver
	software. Typically a card will support several address ranges. After
	determining a proposed ending address you must examine other devices
	in your system to ensure that this address does not conflict.

	The default ending address is @MEMWinSPDefault which should be sufficient for
	most cards. The ending address should be greater than or equal to the
	starting address prevoiusly selected at @MEMWinST.


	@LocalWindow(16,48)
	@Prompt = "Enter the Memory Window's Ending Address:"

	To edit, press the [BACKSPACE] key to erase the current value and 
	Type a new value between @MemWinST and EFFF.  Press [ENTER] when done.
@EndString

/*
 * Validate the MEM window ending address
 */

@If (@StrLen(@MEMWinSP) != 4)
   @Beep
   @Goto GetMEMWinSP
@EndIf
@If ("@StrMid("@MEMWinSP",0,1)" == "C")
   @Goto MEMWinDone
@Endif
@If ("@StrMid("@MEMWinSP",0,1)" == "D")
   @Goto MEMWinDone
@Endif
@If ("@StrMid("@MEMWinSP",0,1)" == "E")
   @Goto MEMWinDone
@Endif
   @Beep
   @Goto GetMEMWinSP

MEMWinDone:

/*
 * Display memory manager notice
 */

@Display
	Installation of @Name1:
	

	If you have a memory manager other than EMM386, 386MAX, QEMM,
	or QEMM386, you will have to manually make changes to CONFIG.SYS
	in order to exclude the memory area @MEMWinST-@MEMWinSP. See your memory
	manager's user's guide for further information.











			     @Pause
@EndDisplay

@TempStr = "-"
@IOWOpts = "/IOW=@IOWinST@TempStr@IOWinSP"
@MEMWOpts = "/MEMW=@MEMWinST@TempStr@MEMWinSP"

SkipIOMem:

@GetOption
	@Cls
	Installation of @Name1:
	
	
	If you have Windows installed on your system, you can install
	a graphics user interface to CardTalk.
	
	

	
	



	
	


	@LocalWindow(17,38)
	@Option 701 = "Install Windows GUI"
	@Option 702 = "Don't install Windows GUI"
							   
	Use the UP/DOWN arrow keys to highlight your choice.  Then press
	the [ENTER] key to continue.
@EndOption


/*
 * Display option selection recap and confirm install
 */

BeginInstall:
DisplayRecap:

//@If (101 [= @Option )
//	@TempStr = "240 Drive"
//@Else
//	@TempStr = "250 Drive"
//@Endif
	@TempStr = "240/250 Drive"


@If ( 1 [= @Option)
	@TempStr = "@TempStr and Microsoft's Flash File System"
@Endif
@If ( 2 [= @Option)
	@TempStr = "@TempStr without Microsoft's Flash File System"
@Endif


@If ( 701 [= @Option)
	@GUIYesNo = "Install the Windows GUI."
@Else
	@GuiYesNo = "Don't install the Windows GUI."
@EndIf

@GetOption
	@Cls
	Installation of @Name1:
	
	You have selected the following options:
	 The Databook TMB-@TempStr. 
	 Destination directory @OutDrive:@Subdir.
	 The drive(s) is(are) installed at I/O address(es) @Address. @If (301 [= @Option )
	 The Card Insertion Annunciator is active. @Else
	 The Card Insertion Annunciator is NOT active. @EndIf @If (@SerPort > 0)
	 Modem cards will appear as COM@SerPort using IRQ@SerIRQ. @Else
	 Modem cards will appear as the next available COM port. @EndIf @If ( 502 [= @Option)
	 The user selectable IO Window is @IOWinST - @IOWinSP. @Else
	 No IO Window selected. @Endif @If ( 502 [= @Option)
	 The user selectable Memory Window is @MEMWinST - @MEMWinSP. @Else
	 No Memory Window selected. @Endif
	 ATA drives will use address @ATAopt.
	 @GUIYesNo

	You may continue and Install will create the subdirectory and copy
	files, or you may reselect install options, or you may quit Install.



	@LocalWindow(18, 38)

	Use the UP/DOWN arrow keys to highlight your choice.  Then press
	the [ENTER] key to continue.
	@Option 401 = "Continue installation"
	@Option 402 = "Reselect Install options"
	@Option 403 = "Quit Install, return to DOS"
@EndOption

@If (401 [= @Option)
   // create the requested subdirectory and continue.
   @ClearOption(401)
   @Goto ContinueInstall
@EndIf

@If (402 [= @Option)
   // jump back to try again label
   @ClearOption(402)
   @Goto TryAgain
@EndIf

@If (403 [= @Option)
   // user freaked and wants to quit
   @ClearOption(403)
   @Exit
@EndIf

/*
 * Install files from disk
 */

ContinueInstall:

@DefineDisk
	@Label = "@Name Disk 1"
	@File README.1ST
	@BeginLib DRIVERS.RED
@EndIf  
//		@FILE   TMB240.SYS    @Option 101
//		@FILE   TMB250.SYS    @Option 102
		@FILE   TMB240.SYS  
		@FILE   CTALKCS.EXE
		@FILE   CARDTALK.SYS
		@FILE   CARDINFO.DBK
		@FILE   CardTalk.386
		@FILE   CardTalk.EXE  @Option 701
		@FILE   CardTalk.GFE  @Option 701
		@FILE   CardTalk.HLP  @OPtion 701
		@FILE   CTALKID.EXE
	@EndLib
	
	@BeginLib TC.RED
		@FILE   *.*                                              
	@EndLib

	@BeginLib WINDB.RED
		@File   *.*             @Option 701
	@EndLib


	@BeginLib FFS2.RED
//              @FILE   DBLFLASH.EXE    @Option 1
		@FILE   MS-FLASH.SYS    @Option 1
		@FILE   MEMCARD.EXE     @Option 1
	@EndLib

		     
@EndDisk


/*
 * Backup CONFIG.SYS and AUTOEXEC.BAT files
 */

@MkDir("@OutDrive:\\@Subdir")
@System("COPY @BootDrive:\\CONFIG.SYS @OutDrive:\\@Subdir > NUL")
@System("COPY @BootDrive:\\AUTOEXEC.BAT @OutDrive:\\@Subdir > NUL")

/*
 * Determine if there is a known memory manager present
 */

// If there's a CONFIG.SYS, then set up to find a memory manager
// and set up new driver with 'exclude' for @CONFIG later
@If (@Exists("@BootDrive:\\CONFIG.SYS"))
  @MemExclude = "@MEMWinST-@MEMWinSP"

  // read file into buffer
  @InFile=@OpenFileRead("@BootDrive:\\CONFIG.SYS")
  @If(@FileSize("@BootDrive:\\CONFIG.SYS") > 500)
	@StrMaxLen(@FileSize("@BootDrive:\\CONFIG.SYS"))
  @EndIf
  @FileBuffer=@ReadFile(@InFile,@FileSize("@BootDrive:\\CONFIG.SYS"))
  @StrMaxLen(500)
  @CloseFile(@InFile)


  // Look through CONFIG.SYS buffer for a '[', and see if it is
  // first non-whitespace on a line- indicates muti-path config.sys
  // We can be fooled if a device driver argument using a [ or
  // a REM'd out menu appears in the CONFIG.SYS before a legitimate
  // menu- we'll get a false negative.


  @Temp = @StrFind(@FileBuffer, "[")
  @If (@Temp == -1)
	@Temp = 3       //avoid INSTALL internal bug
	@GoTo DoneBracket
  @EndIf

BracketLoop:
  @If (@Temp == 0)
	@Temp = 3       //avoid INSTALL internal bug
	@MultiConfig = 1
	@GoTo DoneBracket
  @EndIf


  @Temp = (@Temp - 1)
  @If ("@StrMid(@FileBuffer,@Temp,1)" ==" ")
    @GoTo BracketLoop
  @EndIf
  @If ("@StrMid(@FileBuffer,@Temp,1)" =="\t")
    @GoTo BracketLoop
  @EndIf
  @If ("@StrMid(@FileBuffer,@Temp,1)" =="\n")
    @MultiConfig = 1
  @EndIf
  @If ("@StrMid(@FileBuffer,@Temp,1)" =="\r")
    @MultiConfig = 1
  @EndIf // was non-whitespace

DoneBracket:
  // now we will set up a loop to read each line from the SYS file, and
  // search for a DEVICE=line with the enabler name in it.
  @Counter = 0
  @Driver = ""
ProcessLine:

  @If (@Counter < @StrLineCount(@FileBuffer))
	@Counter=(@Counter + 1)
	@If (@Counter == 1)
	  @TempStr = @StrFirstLine(@FileBuffer)
	@Else
	  @TempStr = @StrNextLine(@FileBuffer)
	@EndIf
	@TempStr = @StrMid(@TempStr, 0, @StrLen("@TempStr") - 1 )

	// Find memory manager
	@If (@StrFind(@StrUpper(@TempStr), "DEVICE") != -1)
	  @If (@StrFind(@StrUpper(@TempStr), "REM") != 0)
	@If (@StrFind(@StrUpper(@TempStr), "EMM386.EXE") != -1)
	  @If (@StrFind(@StrUpper(@TempStr), "X=@MemExclude") == -1)
	   @If (502 [= @Option)
		@Driver = "@TempStr X=@MemExclude"
	   @Endif
		@MemMgrLine = @Counter
	  @EndIf
	@ElseIf (@StrFind(@StrUpper(@TempStr), "QEMM.SYS") != -1)
	  @If ((@StrFind(@StrUpper(@TempStr), "X=@MemExclude") == -1) && (@StrFind(@StrUpper(@TempStr), "EXCLUDE=@MemExclude") == -1))
	   @If (502 [= @Option)
		@Driver = "@TempStr X=@MemExclude"
	   @Endif
		@MemMgrLine = @Counter
	  @EndIf
	@ElseIf (@StrFind(@StrUpper(@TempStr), "QEMM386.SYS") != -1)
	  @If ((@StrFind(@StrUpper(@TempStr), "X=@MemExclude") == -1) && (@StrFind(@StrUpper(@TempStr), "EXCLUDE=@MemExclude") == -1))
	   @If (502 [= @Option)
		@Driver = "@TempStr X=@MemExclude"
	   @Endif
		@MemMgrLine = @Counter
	  @EndIf
	@ElseIf (@StrFind(@StrUpper(@TempStr), "386MAX.SYS") != -1)
	  @If (@StrFind(@StrUpper(@TempStr), "EXCLUDE=@MemExclude") == -1)
	   @If (502 [= @Option)
		@Driver = "@TempStr EXCLUDE=@MemExclude"
	   @Endif
		@MemMgrLine = @Counter
	  @EndIf
	@ElseIf (@StrFind(@StrUpper(@TempStr), "DBLSPACE.BIN") != -1)
	  @DoubleSpaceLine = @Counter
	@Endif
	  @EndIf
	@EndIf

	// keep looping if we haven't found one
	@If (@MemMgrLine != 9999)
//      @If ("@Driver" == "")
	  @GoTo ProcessLine
	@Endif
  @EndIf

  // We've found a driver, or exhausted CONFIG.SYS
  // If found one, remove "DEVICE =" from line for use with @Device later
  @If ("@Driver" != "")
    @Driver = @StrDel( @Driver, 0, @StrFind(@Driver,"=")+1)
StripBlanks:
    @If ( ("@StrHead(@Driver,1)"==" ") || ("@StrHead(@Driver,1)"=="\t") )
      @Driver = @StrDel(@Driver,0, 1)
      @GoTo StripBlanks
    @EndIf
  @Endif

@EndIf

/*
 * Figure out where in CONFIG.SYS to put our stuff
 */
@If (! @CTCfgLine == 0 )
	@ConfigLoc = @CTCfgLine
@ElseIf (! @CSCfgLine == 0 )
	@ConfigLoc = @CSCfgLine
@ElseIf (! @SSCfgLine == 0 )
	@ConfigLoc = @SSCfgLine
@ElseIf (! @MemMgrLine == 9999 )
	@ConfigLoc = (@MemMgrLine + 1)
@ElseIf (! @DoubleSpaceLine == 9999 )
	@ConfigLoc = (@DoubleSpaceLine - 1)
@Else
	@ConfigLoc = 9999
@Endif

/*
 * Reformat ATA options for command line
 */
@If ("@ATAopt" == "170")
	@ATAopt = ""
@Else
	@ATAopt = "/ATA=@ATAopt"
@EndIf

/*
 * Reformat Controller address(es) for command line
 */
@TempAddress = "@Address"
@Address = ""
@Temp = 0
CmdLineLoopTop:
	@TempStr = @StrToken(@TempAddress, @Temp, " ,")
	@If ("@TempStr" == "")
		@GoTo CmdLineLoopEnd
	@EndIf
	@Address = "@Address /io:@TempStr"
	@Temp = (@Temp + 1)
	@Goto CmdLineLoopTop
CmdlineLoopEnd:

@SetAutoexec
	@AskOverwrite
	@Path = "@OutDrive:@Subdir"
@EndAutoexec


@If (@MultiConfig != 0)
@Display


	INSTALL has detected a multi-path CONFIG.SYS file. In most
	cases, INSTALL will properly update CONFIG.SYS to load
	Databook's software. However, you should examine your CONFIG.SYS
	after installation to verify that it was properly modified.

	@Pause
@EndDisplay
@EndIf

@SetConfig
	@AskOverwrite

	@If ("@Driver" != "")
		@Device="@Driver", @MemMgrLine
	@Endif
	
	@If (! "@SSCfgPath" == "")
	@RemDevice = "@SSCfgPath"
	@EndIf

	@If (! "@CSCfgPath" == "")
	@RemDevice = "@CSCfgPath"
	@EndIf

	@If (! "@CTCfgPath" == "")
	@RemDevice = "@CTCfgPath"
	@EndIf

//	@If (101 [= @Option)
//	@DeviceHigh="@OutDrive:\\@Subdir\\TMB240.SYS @ADDRESS", @ConfigLoc
//	@Endif
//	@If (102 [= @Option)
//	@DeviceHigh="@OutDrive:\\@Subdir\\TMB250.SYS @ADDRESS", @ConfigLoc
//	@Endif
	@DeviceHigh="@OutDrive:\\@Subdir\\TMB240.SYS @ADDRESS", @ConfigLoc
	@DeviceHigh="@OutDrive:\\@Subdir\\CTALKCS.EXE", @ConfigLoc
	@DeviceHigh="@OutDrive:\\@Subdir\\CARDTALK.SYS @SerOpts @AnnOpts @IOWOpts @MEMWOpts @ATAopt", @ConfigLoc

	@If (1 [= @Option)
//              @DEVICEHIGH="@OutDrive:\\@Subdir\\DBLFLASH.EXE", @ConfigLoc
		@DEVICEHIGH="@OutDrive:\\@Subdir\\MS-FLASH.SYS", @ConfigLoc
	@Endif


// The following will remove all other existing instances of our drivers
//      @RemDevice="TMB240.SYS"
//      @RemDevice="TMB250.SYS"
//      @RemDevice="CTALKCS.EXE"
//      @RemDevice="CARDTALK.SYS"
//      @RemDevice="DBLFLASH.EXE"

	@If (2 [= @Option)
		@RemDevice="MS-FLASH.SYS"
	@Endif

@EndConfig

@Finish
	@cls
	@ChDrive @OutDrive
	@ChDir "@Subdir"

@If (701 [= @Option)
	INSTALL is about to start the Windows portion of the process.
	@Pause
	@Execute( "WINST" )
@Endif
	@Cls
@EndFinish

/* end-of-file */
