home *** CD-ROM | disk | FTP | other *** search
/ Computer Buyer 1996 June / BUYER_696.iso / business / anytime / atwsetup.ms_ / atwsetup.bin
Text File  |  1995-05-31  |  24KB  |  853 lines

  1. '**************************************************************************
  2. '*                     AnyTime for Windows Setup Script
  3. '**************************************************************************
  4.  
  5. '' Define DEBUG for script debugging
  6.  
  7. '$INCLUDE 'setupapi.inc'
  8. '$INCLUDE 'msdetect.inc'
  9.  
  10. ''Dialog ID's
  11. CONST WELCOME      = 100
  12. CONST ASKVER       = 110
  13. CONST UPGVER       = 120
  14. CONST ASKQUIT      = 200
  15. CONST DESTPATH     = 300
  16. CONST EXITFAILURE  = 400
  17. CONST EXITQUIT     = 600
  18. CONST EXITSUCCESS  = 700
  19. CONST WHICHHOLI    = 810
  20. CONST APPHELP      = 900
  21. CONST SETOWNER     = 1000
  22. CONST INSTALLDRV   = 1200
  23. CONST WAITDLG      = 1400
  24. CONST EXITREBOOT   = 1500
  25. CONST BBD1         = 5050
  26. 'CONST BBD6        = 5000
  27. CONST CUSTINST     = 6200
  28. CONST TOOBIG       = 6300
  29. CONST BADPATH      = 6400
  30.  
  31. '' For message boxes
  32. CONST MB_YESNO=4
  33. CONST IDNO=7
  34. CONST IDYES=6
  35.  
  36. DIM INSTL%(8)       ''EUB
  37. DIM HOLIDAYS$(8)    ''EUB
  38.  
  39. ''Bitmap ID
  40. CONST LOGO         = 1
  41.  
  42. ''File Types
  43. CONST BASEFILES     = 1
  44.  
  45. ''Install directories, etc.
  46. GLOBAL DEST$        ''Default destination directory.
  47. GLOBAL WINDRIVE$    ''Windows drive letter.
  48. GLOBAL CUIDLL$      ''CUI DLL
  49. GLOBAL WINDIR$      ''Windows directory
  50. GLOBAL SYSDIR$      ''System directory
  51. GLOBAL WININI$      ''"win.ini"
  52. GLOBAL SYSINI$      ''GetWindowsDir() + "system.ini"
  53. GLOBAL CDDRV$       ''EUB - CDROM drive root directory
  54. GLOBAL ATWINI$
  55. GLOBAL STAMP$
  56.  
  57. '' User info
  58. GLOBAL OWNER$       '' Product registered owner
  59. GLOBAL SERIALNUM$   '' Was WORKPLACE$ :Company or such
  60. GLOBAL GROUP$
  61.  
  62. ''Install item lists
  63. GLOBAL BASE$        ''List of base files
  64. GLOBAL BASEINST$    ''List of base files to install (subset of BASE$)
  65.  
  66. ''Custom Install list symbol names
  67. GLOBAL BASENEEDS$   ''Option list costs per drive
  68. GLOBAL EXTRACOSTS$  ''List of extra costs to add per drive
  69.  
  70. ''Custom Install dialog list symbol names
  71. GLOBAL CHECKSTATES$ ''List of check box values
  72. GLOBAL STATUSTEXT$  ''List of values to initialize status items
  73. GLOBAL DRIVETEXT$   ''Drive space info, etc.
  74.  
  75. '' Customize product
  76. GLOBAL CUSTOMIZE%
  77.  
  78. GLOBAL STAMPLEN   ''EUB
  79. GLOBAL ATWFOUND%
  80. GLOBAL CUSTINSTALL%
  81.  
  82. '' Which type of install to perform, by default
  83. GLOBAL DEFINSTOPT$
  84.  
  85. ''Progman titles
  86. GLOBAL ATWAPP$      ''Name of ATW app
  87.  
  88.  
  89. ''Win.ini [AnyTime for Windows] install code
  90. GLOBAL INSTDIR$
  91.  
  92. ''Space requirements
  93. GLOBAL FITS%        '' > 0 if everything fits
  94.  
  95. DECLARE SUB RecalcOptFiles (ftype%)
  96. DECLARE FUNCTION MakePath (szDir$, szFile$) AS STRING
  97. DECLARE FUNCTION GetWindowsVersionCorrectly& ()
  98. DECLARE FUNCTION MakeVer& (x as integer, y as integer)
  99. DECLARE FUNCTION StringInList (s$, y$) AS INTEGER
  100. DECLARE SUB RemoveSectionFiles (dest$, sect$)
  101. DECLARE SUB RemDirectory (d$)
  102. DECLARE SUB SendProgmanCommand LIB "CUI.DLL" (s$)
  103.  
  104. '' These are defined in atw.inc (product-specific)
  105. DECLARE SUB SetProductTitles
  106. DECLARE FUNCTION InfFile() AS STRING
  107. DECLARE FUNCTION MakeInstDir(D$) AS STRING
  108. DECLARE SUB AddInfSectionNames (BASE$, BASEINST$)
  109. DECLARE SUB RecalcPath
  110. DECLARE SUB AddOptFilesToCopyList (ftype%)
  111. DECLARE SUB SetDriveStatus
  112. DECLARE SUB AddOptFiles
  113. DECLARE SUB ConfigureApps
  114. DECLARE SUB AddBillboards
  115. DECLARE SUB DoUninstall
  116.  
  117. '' the function that reads the SN.DAT file and stamps the .DLL
  118. Declare Function StampSNDAT Lib "RSTAMP.DLL" (lpDLL$,lpSNDAT$,nResID%) As Integer
  119. Declare Function StampCurrentTimeDate Lib "RSTAMP.DLL" (lpzFile$,nResID%) As Integer
  120. Declare Function SetHandleCount Lib "Kernel.DLL" (cHandles%) As Integer
  121. Declare Function ShowWindow Lib "USER.EXE" (WHnd%,STATE%) As Integer
  122. dkw% = SetHandleCount (60)
  123. dkw% = ShowWindow (MAINWIN%, STATE%)
  124. '' Include product-specific function definitions
  125. '$INCLUDE 'specific.inc'
  126.  
  127.  
  128.  
  129. '' This is where it all begins!
  130.  
  131. INIT:
  132.  
  133.     CUIDLL$ = "cui.dll"
  134.     CUSTOMIZE% = -1
  135.     DEFINSTOPT$ = "2"       '' "1" = 1st radiobutton selection, "2"=2nd, "3"=3rd
  136.     CDDRV$ = GetSymbolValue("STF_SRCDIR")   ''EUB - Intallation drive root directory
  137.  
  138.     SetProductTitles
  139.     STATE%=3
  140.     MAINWIN%=HwndFrame()
  141.     dkw%=ShowWindow (MAINWIN%, STATE%)
  142.     HELPPROC$ = "FHelpDlgProc"      ''Help dialog procedure
  143.  
  144.     SetBitmap CUIDLL$, LOGO
  145.  
  146.  
  147. '' We don't do Windows 3.0...
  148.  
  149.     If GetWindowsVersionCorrectly() < MakeVer(3, 10) Then
  150.     i% = DoMsgBox("This product requires Windows version 3.10 or greater", ATWAPP$, MB_OK)
  151.     GOTO DONEFINIFIN
  152.     End If
  153.  
  154.  
  155.  
  156.  
  157. ''Find location of INF file and create a default dest. dir
  158.  
  159.     szInf$ = GetSymbolValue("STF_SRCINFPATH")
  160.     IF szInf$ = "" THEN
  161.         szInf$ = GetSymbolValue("STF_CWDDIR") + InfFile()
  162.     END IF
  163.  
  164.     '' Load the INF file
  165.     ReadInfFile szInf$
  166.  
  167.     '' Construct default strings
  168.     WINDIR$ = GetWindowsDir()
  169.     SYSDIR$ = GetWindowsSysDir()
  170.     WININI$ = "win.ini"
  171.     SYSINI$ = MakePath(WINDIR$, "system.ini")
  172.     GROUP$ = "AnyTime for Windows"
  173.  
  174.     '' Construct the default install path
  175.     WINDRIVE$ = MID$(WINDIR$, 1, 1)
  176.     DEST$ = MakeInstDir(WINDRIVE$)
  177.  
  178.     '' Setup install symbols
  179. ''  BASE$ = "Base Files"
  180.     BASE$ = "Files"
  181.     BASEINST$ = "Base Files Inst"
  182.  
  183.     SetSymbolValue BASE$, ""
  184.  
  185.     ''Set up symbols for the initial install dialog
  186.     RADIODEFAULT$ = "Radio Default"
  187.  
  188.     ''Set up symbols for the custom install dialog
  189.     CHECKSTATES$ = "CheckItemsState"
  190.     STATUSTEXT$  = "StatusItemsText"
  191.     DRIVETEXT$   = "DriveStatusText"
  192.  
  193.     AddListItem CHECKSTATES$, "ON"
  194.     FOR i% = 2 TO 8 STEP 1
  195.         AddListItem CHECKSTATES$, "OFF"
  196.     NEXT i%
  197.  
  198.     FOR i% = 1 TO 8 STEP 1
  199.         AddListItem STATUSTEXT$, ""
  200.     NEXT i%
  201.     FOR i% = 1 TO 7 STEP 1
  202.         AddListItem DRIVETEXT$, ""
  203.     NEXT i%
  204.     ReplaceListItem DRIVETEXT$, 7, DEST$
  205.  
  206.     ''Disk cost list symbols
  207.     BASENEEDS$   = "BaseNeeds"
  208.  
  209. ''--------Initialize flags
  210.     CUSTINSTALL% = 1
  211.  
  212.   ''  INSTL%(1) = 1           ''U.S. Holidays
  213.     FOR i% = 1 TO 8 STEP 1
  214.         INSTL%(i%) = 0      ''holiday files 0=don't installed; 1=install
  215.     NEXT i%
  216.  
  217.     HOLIDAYS$(1) = "Holidays"
  218.     HOLIDAYS$(2) = "UK"
  219.     HOLIDAYS$(3) = "Canada"
  220.     HOLIDAYS$(4) = "France"
  221.     HOLIDAYS$(5) = "Italy"
  222.     HOLIDAYS$(6) = "Spain"
  223.     HOLIDAYS$(7) = "German"
  224.     HOLIDAYS$(8) = "Benelux"
  225. ''------------------------
  226.  
  227.     ''Configure lists of installable files
  228.     AddInfSectionNames BASE$, BASEINST$
  229.  
  230. '$IFDEF DEBUG
  231.     i% = SetSizeCheckMode(scmOnIgnore)    '' could use scmOff; def = scmOnFatal
  232. '$ENDIF ''DEBUG
  233.  
  234.  
  235. '' Display Welcome dialog
  236. WELCOME:
  237.  
  238.     sz$ = UIStartDlg(CUIDLL$, WELCOME, "FInfoDlgProc", APPHELP, HELPPROC$)
  239.  
  240.     IF sz$ = "EXIT" THEN
  241.         GOSUB ASKQUIT
  242.     ELSEIF sz$ = "CONTINUE" THEN
  243.         UIPop 1
  244.         GOTO CUSTOMIZE
  245.     END IF
  246.     GOTO WELCOME
  247.  
  248.  
  249. '' Customize the copy of the product
  250. CUSTOMIZE:
  251.     IF NOT CUSTOMIZE% THEN
  252.         GOTO DOINST
  253.     END IF
  254.  
  255.     sz$ = UIStartDlg(CUIDLL$, SETOWNER, "FNameOrgDlgProc", 0, "")
  256.  
  257.     IF sz$ = "EXIT" THEN
  258.         UIPop 1
  259.         GOSUB ASKQUIT
  260.         GOTO CUSTOMIZE
  261.     ELSEIF sz$ = "CONTINUE" THEN
  262.         OWNER$ = GetSymbolValue("NameOut")
  263.         IF OWNER$ = "" THEN
  264.             i% = DoMsgBox("Please enter your name before continuing.", "AnyTime for Windows Install", MB_OK)
  265.             GOTO CUSTOMIZE
  266.         END IF
  267.         SERIALNUM$ = "00000000000000000000"
  268.         SNDAT$ = MakePath(CDDRV$,"SN.DAT")
  269.         IF DoesFileExist(SNDAT$,femExists) THEN
  270.             OPEN MakePath(CDDRV$,"SN.DAT") FOR INPUT AS #1
  271.             LINE INPUT #1,SERIALNUM$
  272.             CLOSE #1
  273. ''          i% = DoMsgBox("Serialnum="+SERIALNUM$, "Debugging", MB_OK)
  274.         ELSE
  275.             i% = DoMsgBox("Can't find "+SNDAT$, "AnyTime for Windows Install", MB_OK)
  276.         END IF
  277.  
  278. ''----Need to check for length of input, perhaps pad with blanks, etc.
  279.         IF LEN(OWNER$) >=30 THEN
  280.             OWNER$ = MID$(OWNER$,1,30) + CHR$(0)
  281.         ELSE
  282.             OWNER$ = OWNER$ + CHR$(0)
  283.         END IF
  284.         SERIALNUM$ = MID$(SERIALNUM$,1,12) + CHR$(0)
  285.         STAMP$ = CHR$(LEN(OWNER$)) + OWNER$ + CHR$(LEN(SERIALNUM$)) + SERIALNUM$
  286.         STAMPLEN = LEN(STAMP$)
  287. ''      i% = DoMsgBox("STAMPLEN="+STR$(STAMPLEN), "Debugging", MB_OK)
  288.         UIPop 1
  289.         GOTO GETDEFINSTPATH
  290.     ELSEIF sz$ = "BACK" THEN
  291.         UIPop 1
  292.         GOTO WELCOME
  293.     END IF
  294.     GOTO CUSTOMIZE
  295.  
  296.  
  297. '' See which install user wants
  298. WHICHINST:
  299.     sz$ = UIStartDlg(CUIDLL$, WHICHHOLI, "FCustInstDlgProc", 0, "")  ''EUB
  300.     IF sz$ = "CONTINUE" THEN
  301.             UIPop 1
  302.             IF CUSTINSTALL% THEN
  303.                 GOTO CUSTINST
  304.             ELSE
  305.                 GOTO INSTALL
  306.             END IF
  307.     ELSEIF sz$ = "EXIT" THEN
  308.             UIPop 1
  309.             GOSUB ASKQUIT
  310.     ELSEIF sz$ = "BACK" THEN
  311.             UIPop 1
  312.             GOTO GETDEFINSTPATH
  313.     ELSEIF sz$ = "CHK1" THEN
  314.             CUSTINSTALL% = 1 - CUSTINSTALL%
  315.     END IF
  316.     GOTO WHICHINST
  317.  
  318.  
  319. DOINST:
  320.  
  321. GETDEFINSTPATH:
  322.     GOSUB GETPATH
  323.     ATWINI$ = MakePath(DEST$, "ANYTIME.INI")    ''EUB
  324.  
  325.     IF sz$ = "CONTINUE" THEN
  326.     ''Install only if it will fit.
  327.         IF FITS% > 0 THEN
  328.             GOSUB TOOBIG
  329.             GOTO GETDEFINSTPATH
  330.         END IF
  331.  
  332.         UIPop 1
  333.         GOTO WHICHINST
  334.  
  335.     ELSEIF sz$ = "BACK" THEN
  336.         GOTO CUSTOMIZE
  337.     END IF
  338.     GOTO GETDEFINSTPATH
  339.  
  340.  
  341. ''Perform a custom installation (let user choose files, etc)
  342. CUSTINST:
  343. ''  RecalcPath
  344. ''  SetDriveStatus
  345.  
  346. CUSTINSTDLG:
  347.     sz$ = UIStartDlg(CUIDLL$, CUSTINST, "FCustInstDlgProc", 0, "")  ''EUB
  348.  
  349.     HOLI% = 0
  350.  
  351.     IF sz$ = "CONTINUE" THEN
  352.     ''Install only if it will fit.
  353.         IF FITS% > 0 THEN
  354.             GOSUB TOOBIG
  355.             GOTO CUSTINSTDLG
  356.         END IF
  357.         UIPop 1
  358.         GOTO INSTALL
  359.     ELSEIF sz$ = "CHK1" THEN
  360.         HOLI% = 1
  361. ''--------------------------------
  362.     ELSEIF sz$ = "CHK2" THEN
  363.         HOLI% = 2
  364.     ELSEIF sz$ = "CHK3" THEN
  365.         HOLI% = 3
  366.     ELSEIF sz$ = "CHK4" THEN
  367.         HOLI% = 4
  368.     ELSEIF sz$ = "CHK5" THEN
  369.         HOLI% = 5
  370.     ELSEIF sz$ = "CHK6" THEN
  371.         HOLI% = 6
  372.     ELSEIF sz$ = "CHK7" THEN
  373.         HOLI% = 7
  374.     ELSEIF sz$ = "CHK8" THEN
  375.         HOLI% = 8
  376. ''--------------------------------
  377.     ELSEIF sz$ = "EXIT" THEN
  378.         IF CUSTINSTALL% THEN
  379.             UIPop 1
  380.         END IF
  381.         GOSUB ASKQUIT
  382.         GOTO CUSTINST
  383.     ELSEIF sz$ = "BACK" THEN
  384.         UIPop 1
  385.         GOTO WHICHINST
  386.     END IF
  387.  
  388.     IF HOLI% > 0 THEN
  389.         INSTL%(HOLI%) = 1-INSTL%(HOLI%)
  390. ''--- j% = DoMsgBox("INSTL%(" + STR$(HOLI%)+")="+STR$(INSTL%(HOLI%)), "Debugging", MB_OK)
  391.     END IF
  392.  
  393.     GOTO CUSTINSTDLG
  394.  
  395.  
  396. INSTALL:
  397.     RecalcPath
  398.     SetDriveStatus
  399.  
  400.     SetRestartDir DEST$
  401.     ClearCopyList
  402.  
  403. ''NOTE: CHECKSTATES$ 1 (i.e. BASEFILES=1) is used for installing
  404. '' ANYTIME files.  However, it is also used for the first holiday
  405. '' option box, which when unchecked by the user is interpreted by
  406. '' routine AddOptFiles to bypass the installations of the ANYTIME
  407. '' files.  So, the state is reset here to ON.
  408.     ReplaceListItem CHECKSTATES$,BASEFILES,"ON"     ''EUB-reset to ON
  409.  
  410.     AddOptFiles
  411.  
  412.     AddBillboards
  413.  
  414. BACKLASH:
  415.     IF (MID$(DEST$, (LEN(DEST$)), 1)) = "\" THEN
  416.             DEST$ = MID$(DEST$, 1, (LEN(DEST$)-1))
  417.         GOTO BACKLASH
  418.     END IF
  419.  
  420.  
  421.     CreateDir DEST$, cmoNone
  422.  
  423.     UIPopAll
  424.  
  425.     ''Do the copyn'
  426.     SetCopyGaugePosition 10, 135
  427.     CopyFilesInCopyList
  428.  
  429.     ''Back up SYSTEM.INI and WIN.INI
  430.     CopyFile MakePath(WINDIR$, WININI$), MakePath(WINDIR$, "WIN.BAK"), cmoOverwrite, 0
  431.     CopyFile SYSINI$, MakePath(WINDIR$, "SYSTEM.BAK"), cmoOverwrite, 0
  432.  
  433.     '' Configure the installed applications
  434.  
  435.  
  436.         SERIALNUM$ = "00000000000000000000"
  437.         SNDAT$ = MakePath(CDDRV$,"SN.DAT")
  438.         IF DoesFileExist(SNDAT$,femExists) THEN
  439.             OPEN MakePath(CDDRV$,"SN.DAT") FOR INPUT AS #1
  440.             LINE INPUT #1,SERIALNUM$
  441.             CLOSE #1
  442.             StampLine2$ = "Please record this number on your Registration Card and in your "+ATWAPP$+" Manual."
  443. ''            i% = DoMsgBox("Your "+ATWAPP$+" Serial Number is "+SERIALNUM$+".  "+StampLine2$, ATWAPP$+" Install", MB_OK)
  444.         ELSE
  445.             i% = DoMsgBox("Can't find "+SNDAT$, "AnyTime for Windows Install", MB_OK)
  446.         END IF
  447.  
  448.  
  449.  
  450. ''    IF DoesFileExist(ATWINI$,femExists) THEN
  451. ''--    CopyFile ATWINI$, MakePath(DEST$, "ANYINI.OLD"), cmoOverwrite, 0
  452. ''        RemoveFile ATWINI$, cmoNone
  453. ''    END IF
  454.  
  455.       NC% = 1
  456.       FOR i% = 1 to 8 STEP 1
  457.           IF INSTL%(i%) = 1 THEN       ''1=TRUE: Set ANYTIME.INI entry
  458.             N$ = MID$( STR$(NC%), 2, LEN( STR$(NC%) ) -1 )
  459.             FKEY$ = "FILE"+N$
  460.             HFILE$ = HOLIDAYS$(i%)+".atw"
  461.             CreateIniKeyValue ATWINI$, "AttachedFiles", FKEY$, DEST$+"\"+HFILE$, cmoOverwrite
  462.             NC% = NC% + 1
  463.         END IF
  464.     NEXT i%
  465.  
  466.     '' All boxes were uncheckecked & file was not created: Create defaults
  467.     IF NC% = 0 THEN
  468.             CreateIniKeyValue ATWINI$, "AttachedFiles", "", "", cmoOverwrite
  469.     END IF
  470.  
  471.  
  472.     IF DoesFileExist (ATWINI$,femExist)=1 THEN
  473.         CopyFile ATWINI$, MakePath(DEST$, "ANYTIME.BAK"), cmoOverwrite, 0
  474.  
  475.        CopyFile (MakePath(DEST$,"ANYTIME.INI")),GetWindowsDir+"ANYTIME.INI", cmoNone, 0
  476.        RemoveFile MakePath(DEST$,"ANYTIME.INI"), cmoNone
  477. ''     DelFileStat%=1
  478.  
  479.     END IF
  480.  
  481.  
  482.     IF VER&=1 THEN
  483.  
  484.     DelFileStat%=0
  485.     IF DoesFileExist (MakePath(DEST$,"D7P0.CDF"),femExist)=1 THEN
  486.        RemoveFile MakePath(DEST$,"D7P0.CDF"), cmoNone
  487.        DelFileStat%=1
  488.     ELSE
  489.     ENDIF
  490.  
  491.     IF DoesFileExist (MakePath(DEST$,"D7L0.CDF"),femExist)=1 THEN
  492.        RemoveFile MakePath(DEST$,"D7L0.CDF"), cmoNone
  493.        DelFileStat%=1
  494.     ELSE
  495.     ENDIF
  496.  
  497.     IF DoesFileExist (MakePath(DEST$,"TD7P0.CDF"),femExist)=1 THEN
  498.        RemoveFile MakePath(DEST$,"TD7P0.CDF"), cmoNone
  499.        DelFileStat%=1
  500.     ELSE
  501.     ENDIF
  502.  
  503.     IF DoesFileExist (MakePath(DEST$,"TD7L0.CDF"),femExist)=1 THEN
  504.        RemoveFile MakePath(DEST$,"TD7L0.CDF"), cmoNone
  505.        DelFileStat%=1
  506.     ELSE
  507.     ENDIF
  508.  
  509.     IF DoesFileExist (MakePath(DEST$,"M14L0.CDF"),femExist)=1 THEN
  510.        RemoveFile MakePath(DEST$,"M14L0.CDF"), cmoNone
  511.        DelFileStat%=1
  512.     ELSE
  513.     ENDIF
  514.  
  515.     IF DoesFileExist (MakePath(DEST$,"M14P0.CDF"),femExist)=1 THEN
  516.        RemoveFile MakePath(DEST$,"M14P0.CDF"), cmoNone
  517.        DelFileStat%=1
  518.     ELSE
  519.     ENDIF
  520.  
  521.     IF DoesFileExist (MakePath(DEST$,"M14P1.CDF"),femExist)=1 THEN
  522.        RemoveFile MakePath(DEST$,"M14P1.CDF"), cmoNone
  523.        DelFileStat%=1
  524.     ELSE
  525.     ENDIF
  526.  
  527.     IF DoesFileExist (MakePath(DEST$,"M14P2.CDF"),femExist)=1 THEN
  528.        RemoveFile MakePath(DEST$,"M14P2.CDF"), cmoNone
  529.        DelFileStat%=1
  530.     ELSE
  531.     ENDIF
  532.  
  533.     IF DoesFileExist (MakePath(DEST$,"M14L1.CDF"),femExist)=1 THEN
  534.        RemoveFile MakePath(DEST$,"M14L1.CDF"), cmoNone
  535.        DelFileStat%=1
  536.     ELSE
  537.     ENDIF
  538.  
  539.     IF DoesFileExist (MakePath(DEST$,"M41L0.CDF"),femExist)=1 THEN
  540.        RemoveFile MakePath(DEST$,"M41L0.CDF"), cmoNone
  541.        DelFileStat%=1
  542.     ELSE
  543.     ENDIF
  544.  
  545.     IF DoesFileExist (MakePath(DEST$,"M41L1.CDF"),femExist)=1 THEN
  546.        RemoveFile MakePath(DEST$,"M41L1.CDF"), cmoNone
  547.        DelFileStat%=1
  548.     ELSE
  549.     ENDIF
  550.  
  551.     IF DoesFileExist (MakePath(DEST$,"TM41L0.CDF"),femExist)=1 THEN
  552.        RemoveFile MakePath(DEST$,"TM41L0.CDF"), cmoNone
  553.        DelFileStat%=1
  554.     ELSE
  555.     ENDIF
  556.  
  557.     IF DoesFileExist (MakePath(DEST$,"TM41L1.CDF"),femExist)=1 THEN
  558.        RemoveFile MakePath(DEST$,"TM41L1.CDF"), cmoNone
  559.        DelFileStat%=1
  560.     ELSE
  561.     ENDIF
  562.  
  563.     IF DelFileStat%=1 THEN
  564.         MESS1$="New versions of the Event Multi-Day Planner, 12-Month Calendar, and 6-Month Glance layouts have been installed."
  565.        i% = DoMsgBox(MESS1$+" The options for these layouts have been reset to their default settings.", ATWAPP$, MB_OK)
  566.     ELSE
  567.     END IF
  568.  
  569.     END IF
  570.  
  571.     ConfigureApps
  572.  
  573.  
  574. QUIT:
  575.     ON ERROR GOTO ERRQUIT
  576.  
  577.     IF ERR = 0 THEN
  578.         dlg% = EXITREBOOT
  579.     ELSEIF ERR = STFQUIT THEN
  580.         dlg% = EXITQUIT
  581.     ELSE
  582.  
  583. '$IFNDEF DEBUG
  584.     RESUME NEXT
  585. '$ELSE
  586.     dlg% = EXITFAILURE
  587. '$ENDIF
  588.  
  589.     END IF
  590.  
  591. QUITL1:
  592.     sz$ = UIStartDlg(CUIDLL$, dlg%, "FInfo0DlgProc", 0, "")
  593.     UIPop 1
  594.  
  595. DONEFINIFIN:
  596.     END
  597.  
  598. ERRQUIT:
  599.     i% = DoMsgBox("An error occured during installation.  Please call Individual Software Customer Service at (800) 331-3313.", "Setup Error", MB_OK+MB_TASKMODAL+MB_ICONHAND)
  600.     END
  601.  
  602.  
  603.  
  604. GETPATH:
  605.     SetSymbolValue "EditTextIn", DEST$
  606.     SetSymbolValue "EditFocus", "END"
  607. GETPATHL1:
  608.     sz$ = UIStartDlg(CUIDLL$, DESTPATH, "FEditDlgProc", APPHELP, HELPPROC$)
  609.  
  610.     IF sz$ = "CONTINUE" THEN
  611.  
  612.         olddest$ = DEST$
  613.         DEST$ = GetSymbolValue("EditTextOut")
  614.  
  615.         ''Validate new path.
  616.         VALPATH:
  617.         IF (MID$(DEST$, (LEN(DEST$)), 1)) = "\" THEN
  618.             DEST$ = MID$(DEST$, 1, (LEN(DEST$)-1))
  619.             GOTO VALPATH
  620.         END IF
  621.  
  622. ''      IF IsDirWritable(CDDRV$) <> 1 THEN
  623. ''          i% = DoMsgBox("Install has detected that the AnyTime diskette is write-protected.", APP$, MB_OK)
  624. ''          i% = DoMsgBox("Please remove the write-protection and select OK.", APP$, MB_OK)
  625. ''          GOTO VALPATH
  626. ''      END IF
  627.  
  628.  
  629.         IF (MID$(DEST$, 2, 1)) <> ":" THEN
  630.             i% = DoMsgBox("This is not a valid path. Please enter a different path.", APP$, MB_OK)
  631.             GOTO GETPATHL1
  632.         END IF
  633.  
  634.  
  635.         IF (MID$(DEST$, 3, 1)) <> "\" THEN
  636.             i% = DoMsgBox("This is not a valid path. Please enter a different path.", APP$, MB_OK)
  637.             GOTO GETPATHL1
  638.         END IF
  639.  
  640.  
  641.         Ver&=0
  642.  
  643.         IF DoesFileExist (MakePath(DEST$,"ATWRES.DLL"),femExist)=1 THEN
  644.            OldATWVer$=GetVersionOfFile (MakePath(DEST$,"ATWRES.DLL"))
  645.            VerField1&=GetVersionNthField (OldATWVer$,1)*1000
  646.            VerField2&=GetVersionNthField (OldATWVer$,2)*100
  647.            VerField3&=GetVersionNthField (OldATWVer$,3)*10
  648.            VerField4&=GetVersionNthField (OldATWVer$,4)
  649.  
  650.             OldATWVerVal&=VerField1& + VerField2& + VerField3& + VerField4&
  651.  
  652. ''          i% = DoMsgBox("Old Version = " + OldATWVer$, APP$, MB_OK)
  653. ''          i% = DoMsgBox("Old Version Val = " + STR$(OldATWVerVal&), APP$, MB_OK)
  654. ''          i% = DoMsgBox("Old Version Val = " + STR$(NewATWVerVal&), APP$, MB_OK)
  655.  
  656.             IF OldATWVerVal&>NewATWVerVal& Then
  657.                 Ver&=1
  658.  
  659.             ELSEIF OldATWVerVal&=NewATWVerVal& Then
  660.                 Ver&=2
  661.  
  662.             ELSEIF OldATWVerVal&<NewATWVerVal& Then
  663.                 Ver&=3
  664.  
  665.             END IF
  666.         END IF
  667.  
  668.             IF Ver&=1 THEN
  669.                 sz$ = UIStartDlg(CUIDLL$, ASKVER, "FInfoDlgProc", APPHELP, HELPPROC$)
  670.  
  671.                 IF sz$ = "EXIT" THEN
  672.                     GOSUB ASKQUIT
  673.                 ELSEIF sz$ = "BACK" THEN
  674.                     UIPop 1
  675.                     GOTO GETPATHL1
  676.                 END IF
  677.  
  678.             ELSEIF Ver&=3 THEN
  679.                 sz$ = UIStartDlg(CUIDLL$, UPGVER, "FInfoDlgProc", APPHELP, HELPPROC$)
  680.  
  681.                 IF sz$ = "EXIT" THEN
  682.                     GOSUB ASKQUIT
  683.                 ELSEIF sz$ = "BACK" THEN
  684.                     UIPop 1
  685.                     GOTO GETPATHL1
  686.                 END IF
  687.  
  688.             END IF
  689.  
  690.  
  691.  
  692.  
  693.         IF NETINSTALL%=0 THEN
  694.           IF IsDriveNetwork(MID$(DEST$, 1, 1)) > 0 THEN
  695.               i% = DoMsgBox("This single user version will not install on or run from a network drive.", APP$, MB_OK)
  696.               i% = DoMsgBox("Please select a local hard disk or contact Individual Software Customer Service at (800) 822-3522.", APP$, MB_OK)
  697.               GOTO GETPATHL1
  698.           END IF
  699.         END IF
  700.  
  701.         IF IsDriveRemovable(DEST$) > 0 THEN
  702.             i% = DoMsgBox("This program must be installed to a hard drive. Please enter a different drive.", APP$, MB_OK)
  703.             GOTO GETPATHL1
  704.         END IF
  705.  
  706.         IF DEST$+"\"=GetWindowsSysDir THEN
  707.             i% = DoMsgBox("This program can not be installed into the Windows System directory. Please enter a different path.", APP$, MB_OK)
  708.             GOTO GETPATHL1
  709.         END IF
  710.  
  711.         IF DEST$+"\"=GetWindowsDir THEN
  712.             i% = DoMsgBox("This program can not be installed into the Windows directory. Please enter a different path.", APP$, MB_OK)
  713.             GOTO GETPATHL1
  714.         END IF
  715.  
  716.         UIPop 1
  717.  
  718.  
  719.         ''Truncate display if too long.
  720.         IF LEN(DEST$) > 23 THEN
  721.             ReplaceListItem DRIVETEXT$, 7, MID$(DEST$, 1, 23)+"..."
  722.         ELSE
  723.             ReplaceListItem DRIVETEXT$, 7, DEST$
  724.         END IF
  725.  
  726.         ''Recalc if path changed.
  727.         IF (olddest$ <> DEST$) AND (olddest$ <> DEST$+"\") AND (olddest$+"\" <> DEST$) THEN
  728.             RecalcPath
  729.             SetDriveStatus
  730.         END IF
  731.  
  732.         olddest$ = ""
  733.  
  734.         RETURN
  735.     ELSEIF sz$ = "EXIT" THEN
  736.         UIPop 1
  737.         GOSUB ASKQUIT
  738.         GOTO GETPATHL1
  739.     ELSEIF sz$ = "BACK" THEN
  740.         UIPop 1
  741.         RETURN
  742.     END IF
  743.     GOTO GETPATHL1
  744.  
  745.  
  746. TOOBIG:
  747.     sz$ = UIStartDlg(CUIDLL$, TOOBIG, "FInfo0DlgProc", 0, "")
  748.     UIPop 1
  749.     RETURN
  750.  
  751.  
  752.  
  753. BADPATH:
  754.     sz$ = UIStartDlg(CUIDLL$, BADPATH, "FInfo0DlgProc", 0, "")
  755.     UIPop 1
  756.     RETURN
  757.  
  758.  
  759. ASKQUIT:
  760.     sz$ = UIStartDlg(CUIDLL$, ASKQUIT, "FQuitDlgProc", 0, "")
  761.  
  762.     IF sz$ = "EXIT" THEN
  763.         UIPopAll
  764.         ERROR STFQUIT
  765.     ELSE
  766.         UIPop 1
  767.     END IF
  768.     RETURN
  769.  
  770.  
  771. ''Recalculate space based on install options...
  772. SUB RecalcOptFiles (ftype%) STATIC
  773.  
  774.     CursorSave% = ShowWaitCursor()
  775.  
  776.     sz$ = UIStartDlg(CUIDLL$, WAITDLG, "FModelessDlgProc", APPHELP, HELPPROC$)
  777.  
  778.     SLEEP 1
  779.  
  780.     ClearCopyList
  781.  
  782.     UIPop 1
  783.  
  784.     ReplaceListItem STATUSTEXT$, ftype%, STR$(cost& / 1024) + " K"
  785.     RestoreCursor CursorSave%
  786.  
  787.     ListSym$ = ""
  788. END SUB
  789.  
  790.  
  791. ''Make path from dir and szFile; add \  as needed
  792. FUNCTION MakePath (szDir$, szFile$) STATIC AS STRING
  793.     IF szDir$ = "" THEN
  794.         MakePath = szFile$
  795.     ELSEIF szFile$ = "" THEN
  796.         MakePath = szDir$
  797.     ELSEIF MID$(szDir$, LEN(szDir$), 1) = "\" THEN
  798.         MakePath = szDir$ + szFile$
  799.     ELSE
  800.         MakePath = szDir$ + "\" + szFile$
  801.     END IF
  802. END FUNCTION
  803.  
  804.  
  805. '' Return true if the given string is in the symbol's list
  806. FUNCTION StringInList (s$, y$) STATIC AS INTEGER
  807.     l% = GetListLength(y$)
  808.     FOR i% = 1 TO l
  809.     IF s$ = GetListItem(y$, i%) THEN
  810.         StringInList = -1
  811.         GOTO DONE
  812.     END IF
  813.     NEXT i%
  814.     StringInList = 0
  815. DONE:
  816. END FUNCTION
  817.  
  818.  
  819. ''Get Windows version
  820. FUNCTION GetWindowsVersionCorrectly& () STATIC
  821.     GetWindowsVersionCorrectly = GetWindowsMajorVersion() * 256 + GetWindowsMinorVersion()
  822. END FUNCTION
  823.  
  824.  
  825. '' Turn x, y into a major.minor version long
  826. FUNCTION MakeVer& (x as integer, y as integer) STATIC
  827.     MakeVer = x * 256 + y
  828. END FUNCTION
  829.  
  830.  
  831. '' Remove all files in the given .INF section
  832. SUB RemoveSectionFiles (dest$, sect$) STATIC
  833.     foo$ = "foo"
  834.     MakeListFromSectionFilename foo$, sect$
  835.     l% = GetListLength(foo$)
  836.     FOR i% = 1 TO l% STEP 1
  837.         RemoveFile MakePath(dest$, GetListItem(foo$, i%)), cmoForce
  838.     NEXT i%
  839.     foo$ = ""
  840. END SUB
  841.  
  842.  
  843. '' Remove directory and all files in it, if it exists
  844. SUB RemDirectory(d$) STATIC
  845.     IF Exists(MakePath(d$, "NUL")) THEN
  846.         Kill MakePath(d$, "*.*")
  847.         RmDir d$
  848.     END IF
  849. END SUB
  850.  
  851.  
  852.  
  853.