home *** CD-ROM | disk | FTP | other *** search
/ On Hand / On_Hand_From_Softbank_1994_Release_2_Disc_1_1994.iso / 00004 / s / trial / disk1 / myob.ms_ / myob.bin
Text File  |  1992-06-16  |  21KB  |  664 lines

  1. '**************************************************************************
  2. '*                       M.Y.O.B. Setup Script
  3. '*
  4. '*  Revised 05/15/1992 by BMT
  5. '*
  6. '**************************************************************************
  7.  
  8. ''$DEFINE DEBUG  ''Define for script development/debugging
  9.  
  10. '$INCLUDE 'myob.inc'        '' Routines extracted from setupapi.inc and msdetect.inc
  11.  
  12. DECLARE SUB MaximizeWindow LIB "mscuistf.dll" (hwnd%)
  13.  
  14.  
  15. ''Dialog ID's
  16. CONST ASKQUIT       = 200
  17. CONST DESTPATH      = 300
  18. CONST GROUPNAME     = 350
  19. CONST REGISTER      = 360
  20. CONST EXITFAILURE   = 400
  21. CONST EXITQUIT      = 600
  22. CONST EXITSUCCESS   = 700
  23. CONST OPTIONS       = 800
  24. CONST APPHELP       = 900
  25. CONST CHECK         = 2500
  26. CONST MODLESS       = 5000
  27. CONST CUSTINST      = 6200
  28. CONST TOOBIG        = 6300
  29. CONST BADPATH       = 6400
  30.  
  31. ''Bitmap ID
  32. CONST LOGO          = 1
  33.  
  34. ''File Types
  35. CONST APPFILES      = 1
  36. CONST SAMPDATA      = 2
  37. CONST REDESTRIB     = 3
  38. CONST WINHELP       = 5
  39. CONST INSTALL       = 5
  40.  
  41. GLOBAL SECTREDESTRIB$   ''Name of redestributables section
  42.  
  43. GLOBAL DEST$        ''Default destination directory.
  44. GLOBAL GROUP$       ''Default program manager group
  45. GLOBAL SYSDIR$      ''Windows system directory (with the backslash)
  46. GLOBAL WINDIR$      ''Windows directory (with the backslash)
  47. GLOBAL WINDRIVE$    ''Windows drive letter.
  48. GLOBAL OPT1OPT$     ''Option selection from OptFiles1 option dialog.
  49.  
  50. ''CustInst list symbol names
  51. GLOBAL NUMAPPFILES$ '' Number of application installation files
  52. GLOBAL NUMWINHELPFILES$ '' Number of WINHELP.EXE-specific files
  53. GLOBAL NUMREDESTFILES$  '' Number of redestributable files
  54. GLOBAL NUMSAMPDATA$ '' Number of sample data files
  55.  
  56. GLOBAL APPSIZE$     ''Total space needed for application files
  57. GLOBAL APPNEEDS$    ''Total space needed for selected application files
  58. GLOBAL SAMPNEEDS$   ''Total space needed for selected sample data files
  59. GLOBAL SAMPSIZE$    ''Total space needed for each selected sample data files
  60. GLOBAL REDESTSIZE$  ''Total space needed for system files
  61. GLOBAL REDESTNEEDS$ ''Total space needed for selected system files
  62. GLOBAL WINHELPSIZE$ ''Total space needed for windows help
  63. GLOBAL WINHELPNEEDS$    ''Total space needed for selected windows
  64. GLOBAL EXTRACOSTS$  ''List of extra costs to add per drive
  65. GLOBAL BIGLIST$     ''List of option files cost calc results (boolean)
  66.  
  67. ''Dialog list symbol names
  68. GLOBAL CHECKSTATES$
  69. GLOBAL CHECKITEMS$
  70. GLOBAL STATUSTEXT$
  71. GLOBAL DRIVETEXT$
  72.  
  73. '' Miscellanoues
  74. GLOBAL  WinVer%
  75.  
  76. DECLARE SUB AddOptFilesToCopyList (ftype%)
  77. DECLARE SUB RecalcOptFiles (ftype%)
  78. DECLARE SUB RecalcPath
  79. DECLARE SUB SetDriveStatus
  80. DECLARE FUNCTION MakePath (szDir$, szFile$) AS STRING
  81. DECLARE FUNCTION ExistingFileSize(Section$, Directory$) AS LONG
  82.  
  83.  
  84. INIT:
  85.     CUIDLL$ = "mscuistf.dll"            ''custom user interface dll
  86.     HELPPROC$ = "FHelpDlgProc"          ''Help dialog procedure
  87.     hwnd% = HwndFrame()
  88.     MaximizeWindow hwnd%
  89.     SetBitmap CUIDLL$, LOGO
  90.     SetTitle "M.Y.O.B. Demo Setup"
  91.     SetCopyGaugePosition -1, 2   '' Centered horizontally, but near top vertically
  92.     WinVer% = GetWindowsMajorVersion() * 10 + GetWindowsMinorVersion()
  93.  
  94.     szInf$ = GetSymbolValue("STF_SRCINFPATH")
  95.     IF szInf$ = "" THEN
  96.         szInf$ = GetSymbolValue("STF_CWDDIR") + "SETUP.INF"
  97.     END IF
  98.     ReadInfFile szInf$
  99.  
  100.     WINDIR$ = GetWindowsDir
  101.     WINDRIVE$   = MID$(WINDIR$, 1, 1)
  102.     DEST$   = WINDRIVE$ + ":\MYOBDEMO"
  103.     SYSDIR$ = GetWindowsSysDir()
  104.     GROUP$  = "Teleware"
  105.  
  106.     ''Section names
  107.     SECTREDESTRIB$ = "REDESTRIB"
  108.  
  109.     ''Get disk costs
  110.     NUMAPPFILES$    = "NumAppFiles"
  111.     NUMWINHELPFILES$= "NumWinHelpFiles"
  112.     NUMREDESTFILES$ = "NumRedestFiles"
  113.     NUMSAMPDATA$    = "NumSampData"
  114.  
  115.     ''CustInst list symbols
  116.     CHECKSTATES$   = "CheckItemsState"
  117.     CHECKITEMS$    = "CheckItems"
  118.     STATUSTEXT$    = "StatusItemsText"
  119.     DRIVETEXT$     = "DriveStatusText"
  120.     FOR i% = 1 TO 10 STEP 1
  121.         AddListItem CHECKSTATES$, "ON"
  122.     NEXT i%
  123.  
  124.     MakeListFromSectionKeys NUMSAMPDATA$, "SAMPDATA"
  125.     Num% = GetListLength(NUMSAMPDATA$)
  126.     FOR i% = 1 TO Num% STEP 1
  127.         AddListItem CHECKITEMS$, "ON"
  128.     NEXT i%
  129.     FOR i% = 1 TO 2 STEP 1
  130.         AddListItem STATUSTEXT$, ""
  131.     NEXT i%
  132.     FOR i% = 1 TO 11 STEP 1
  133.         AddListItem DRIVETEXT$, ""
  134.     NEXT i%
  135.     ReplaceListItem DRIVETEXT$, 7, DEST$
  136.     ReplaceListItem DRIVETEXT$, 11, GROUP$
  137.  
  138.  
  139.     ''Disk cost list symbols
  140.     APPNEEDS$       = "AppNeeds"
  141.     APPSIZE$        = "AppSize"
  142.     SAMPNEEDS$      = "SampNeeds"
  143.     SAMPSIZE$       = "SampSize"
  144.     WINHELPNEEDS$   = "WinHelpNeeds"
  145.     WINHELPSIZE$    = "WinHelpSize$"
  146.     REDESTNEEDS$    = "RedestNeeds"
  147.     REDESTSIZE$     = "RestSize"
  148.     EXTRACOSTS$     = "ExtraCosts"
  149.     BIGLIST$        = "BigList"
  150.  
  151.  
  152.     l& = 0
  153.     MakeListFromSectionKeys NUMAPPFILES$, "APPFILES"
  154.     Num% = GetListLength(NUMAPPFILES$)
  155.     FOR i% = 1 TO Num% STEP 1
  156.         l& = l& + GetSectionKeySize("APPFILES", chr$(48 + i%))
  157.     NEXT i%
  158.     AddListItem APPNEEDS$, str$(l&)
  159.     AddListItem APPSIZE$, str$(l&)
  160.  
  161.     l& = 0
  162.     MakeListFromSectionKeys NUMWINHELPFILES$, "WINHELPFILES"
  163.     Num% = GetListLength(NUMWINHELPFILES$)
  164.     FOR i% = 1 TO Num% STEP 1
  165.         l& = l& + GetSectionKeySize("WINHELPFILES", chr$(48 + i%))
  166.     NEXT i%
  167.     AddListItem WINHELPNEEDS$, str$(l&)
  168.     AddListItem WINHELPSIZE$, str$(l&)
  169.  
  170.     MakeListFromSectionKeys NUMSAMPDATA$, "SAMPDATA"
  171.     Num% = GetListLength(NUMSAMPDATA$)
  172.     cost& = 0
  173.     FOR i% = 1 TO Num% STEP 1
  174.     l& = GetSectionKeySize("SAMPDATA", chr$(48 + i%))
  175.     AddListItem SAMPSIZE$, str$(l&)
  176.     cost& = cost& + l&
  177.     NEXT i%
  178.     AddListItem SAMPNEEDS$, str$(cost&)
  179.  
  180.     l& = 0
  181.     MakeListFromSectionKeys NUMREDESTFILES$, SECTREDESTRIB$
  182.     Num% = GetListLength(NUMREDESTFILES$)
  183.     FOR i% = 1 TO Num% STEP 1
  184.     l& = l& + GetSectionKeySize(SECTREDESTRIB$, chr$(48 + i%))
  185.     NEXT i%
  186.     AddListItem REDESTNEEDS$, str$(l&)
  187.     AddListItem REDESTSIZE$, str$(l&)
  188.  
  189.     FOR i% = 1 TO 3 STEP 1
  190.     AddListItem BIGLIST$, ""
  191.     NEXT i%
  192.     FOR i% = 1 TO 26 STEP 1
  193.     AddListItem EXTRACOSTS$, "0"
  194.     NEXT i%
  195.  
  196.     ''File Option Variables
  197.     OPT1OPT$ = "1"
  198.  
  199.     RecalcPath
  200.     SetDriveStatus
  201.  
  202.  
  203. CUSTINST:
  204.     sz$ = UIStartDlg(CUIDLL$, CUSTINST, "FCustInstDlgProc", APPHELP, HELPPROC$)
  205.  
  206.     IF sz$ = "CONTINUE" THEN
  207.         ''Install only if it will fit.
  208.         FOR i% = 1 TO 3 STEP 1
  209.             IF GetListItem(BIGLIST$, i%) <> "" THEN
  210.             GOSUB TOOBIG
  211.             GOTO CUSTINST
  212.             END IF
  213.         NEXT i%
  214.         UIPop 1
  215.         GOTO INSTALL
  216.     ELSEIF sz$ = "PATH" THEN
  217.         GOTO GETPATH
  218.     ELSEIF sz$ = "GROUP" THEN
  219.         GOTO GETGROUP
  220.     ELSEIF sz$ = "CHK1" THEN
  221.         RecalcOptFiles APPFILES
  222.         SetDriveStatus
  223.         GOTO CUSTINST
  224.     ELSEIF sz$ = "CHK2" THEN
  225.         RecalcOptFiles SAMPDATA
  226.         SetDriveStatus
  227.         GOTO CUSTINST
  228.     ELSEIF sz$ = "BTN2" THEN
  229.         GOTO OPTFILES1
  230.     ELSEIF sz$ = "REACTIVATE" THEN
  231.         RecalcPath
  232.         SetDriveStatus
  233.         GOTO CUSTINST
  234.     ELSE
  235.         GOSUB ASKQUIT
  236.         GOTO CUSTINST
  237.     END IF
  238.  
  239.  
  240.  
  241. INSTALL:
  242.     ClearCopyList
  243.     AddOptFilesToCopyList REDESTRIB
  244.     AddOptFilesToCopyList WINHELP
  245.     AddOptFilesToCopyList APPFILES
  246.     AddOptFilesToCopyList SAMPDATA
  247.     CD$ = GetSymbolValue("STF_CWDDIR")
  248.     CreateDir DEST$, cmoNone
  249.     SetRestartDir(DEST$)
  250.     ClearBillboardList
  251.     AddToBillboardList "MSCUISTF.DLL", MODLESS, "FModelessDlgProc", 100
  252.     CopyFilesInCopyList
  253.     ClearBillboardList
  254.  
  255.     IF GetListItem(CHECKSTATES$, APPFILES) = "ON" AND LEN(GROUP$) <> 0 THEN
  256.         CreateProgmanGroup GROUP$, "", cmoNone
  257.         ShowProgmanGroup  GROUP$, 1, cmoNone
  258.     CreateProgmanItem GROUP$, "M.Y.O.B. Demo", MakePath(DEST$, "MYOB.EXE"), "", cmoOverwrite
  259.     END IF
  260.  
  261. RESTARTWIN:
  262.     if RestartListEmpty() = 0 then
  263.         if WinVer% >= 31 then
  264.         i% = DoMsgBox("Windows system files need to be updated.  This requires that Windows be shut down.  Press OK to continue or Cancel to abort.", "M.Y.O.B. Demo Setup", MB_OKCANCEL+MB_TASKMODAL+MB_ICONINFORMATION)
  265.             if i% = IDOK then
  266.                 i% = ExitExecRestart()
  267.             elseif i% = IDCANCEL then
  268.                 GOSUB ASKQUIT
  269.                 GOTO RESTARTWIN
  270.             end if
  271.         else
  272.         i% = DoMsgBox("Windows system files need to be updated.  To do this, exit windows and execute the batch file _MSSETUP.BAT located in " + CD$, "M.Y.O.B. Demo Setup", MB_OK+MB_TASKMODAL+MB_ICONINFORMATION)
  273.         end if
  274.     endif
  275.  
  276.  
  277. QUIT:
  278.     ON ERROR GOTO ERRQUIT
  279.  
  280.     IF ERR = 0 THEN
  281.         dlg% = EXITSUCCESS
  282.     ELSEIF ERR = STFQUIT THEN
  283.         dlg% = EXITQUIT
  284.     ELSE
  285.         dlg% = EXITFAILURE
  286.     END IF
  287. QUITL1:
  288.     sz$ = UIStartDlg(CUIDLL$, dlg%, "FInfo0DlgProc", 0, "")
  289.     IF sz$ = "REACTIVATE" THEN
  290.         GOTO QUITL1
  291.     END IF
  292.     UIPop 1
  293.     IF dlg% = EXITSUCCESS THEN
  294.         sz$ = UIStartDlg(CUIDLL$, REGISTER, "FInfo0DlgProc", 0, "")
  295.         UIPop 1
  296.     ENDIF
  297.     END
  298.  
  299. ERRQUIT:
  300.     i% = DoMsgBox("Setup sources were corrupted, call M.Y.O.B. customer support.", "Setup Message", MB_OK+MB_TASKMODAL+MB_ICONHAND)
  301.     END
  302.  
  303.  
  304. GETGROUP:
  305.     SetSymbolValue "EditTextIn", GROUP$
  306.     SetSymbolValue "EditFocus", "END"
  307. GETGROUPL1:
  308.     sz$ = UIStartDlg(CUIDLL$, GROUPNAME, "FEditDlgProc", APPHELP, HELPPROC$)
  309.  
  310.     IF sz$ = "CONTINUE" THEN
  311.         GROUP$ = GetSymbolValue("EditTextOut")
  312.         ReplaceListItem DRIVETEXT$, 11, GROUP$
  313.         UIPop 1
  314.         GOTO CUSTINST
  315.     ELSEIF sz$ = "REACTIVATE" THEN
  316.         RecalcPath
  317.         SetDriveStatus
  318.         GOTO GETGROUPL1
  319.     ELSEIF sz$ = "EXIT" THEN
  320.         GOSUB ASKQUIT
  321.         GOTO GETGROUPL1
  322.     ELSE
  323.         UIPop 1
  324.         GOTO CUSTINST
  325.     END IF
  326.  
  327. GETPATH:
  328.     SetSymbolValue "EditTextIn", DEST$
  329.     SetSymbolValue "EditFocus", "END"
  330. GETPATHL1:
  331.     sz$ = UIStartDlg(CUIDLL$, DESTPATH, "FEditDlgProc", APPHELP, HELPPROC$)
  332.  
  333.     IF sz$ = "CONTINUE" THEN
  334.         olddest$ = DEST$
  335.         DEST$ = GetSymbolValue("EditTextOut")
  336.  
  337.         ''Validate new path.
  338.         IF IsDirWritable(DEST$) = 0 THEN
  339.             GOSUB BADPATH
  340.             GOTO GETPATHL1
  341.         END IF
  342.         UIPop 1
  343.  
  344.         ''Truncate display if too long.
  345.         IF LEN(DEST$) > 23 THEN
  346.             ReplaceListItem DRIVETEXT$, 7, MID$(DEST$, 1, 23)+"..."
  347.         ELSE
  348.             ReplaceListItem DRIVETEXT$, 7, DEST$
  349.         END IF
  350.  
  351.         ''Recalc if path changed.
  352.         IF (olddest$ <> DEST$) AND (olddest$ <> DEST$+"\") AND (olddest$+"\" <> DEST$) THEN
  353.             RecalcPath
  354.             SetDriveStatus
  355.         END IF
  356.  
  357.         olddest$ = ""
  358.         GOTO CUSTINST
  359.     ELSEIF sz$ = "REACTIVATE" THEN
  360.         RecalcPath
  361.         SetDriveStatus
  362.         GOTO GETPATHL1
  363.     ELSEIF sz$ = "EXIT" THEN
  364.         GOSUB ASKQUIT
  365.         GOTO GETPATHL1
  366.     ELSE
  367.         UIPop 1
  368.         GOTO CUSTINST
  369.     END IF
  370.  
  371.  
  372.  
  373. OPTFILES1:
  374. '    SetSymbolValue CHECKSTATES$, OPT1OPT$
  375. OPT1L1:
  376.     sz$ = UIStartDlg(CUIDLL$, CHECK, "FCheckDlgProc", APPHELP, HELPPROC$)
  377.  
  378.     IF sz$ = "CONTINUE" THEN
  379.         UIPop 1
  380.         RecalcOptFiles SAMPDATA
  381.         SetDriveStatus
  382.         GOTO CUSTINST
  383.     ELSEIF sz$ = "REACTIVATE" THEN
  384.         RecalcPath
  385.         SetDriveStatus
  386.         GOTO OPT1L1
  387.     ELSEIF sz$ = "EXIT" THEN
  388.         GOSUB ASKQUIT
  389.         GOTO OPT1L1
  390.     ELSE
  391.         UIPop 1
  392.         newopt$ = ""
  393.         GOTO CUSTINST
  394.     END IF
  395.  
  396.  
  397.  
  398. TOOBIG:
  399.     sz$ = UIStartDlg(CUIDLL$, TOOBIG, "FInfo0DlgProc", 0, "")
  400.     IF sz$ = "REACTIVATE" THEN
  401.         RecalcPath
  402.         SetDriveStatus
  403.         GOTO TOOBIG
  404.     END IF
  405.     UIPop 1
  406.     RETURN
  407.  
  408.  
  409.  
  410. BADPATH:
  411.     sz$ = UIStartDlg(CUIDLL$, BADPATH, "FInfo0DlgProc", 0, "")
  412.     IF sz$ = "REACTIVATE" THEN
  413.         RecalcPath
  414.         SetDriveStatus
  415.         GOTO BADPATH
  416.     END IF
  417.     UIPop 1
  418.     RETURN
  419.  
  420.  
  421.  
  422. ASKQUIT:
  423.     sz$ = UIStartDlg(CUIDLL$, ASKQUIT, "FQuitDlgProc", 0, "")
  424.  
  425.     IF sz$ = "EXIT" THEN
  426.         UIPopAll
  427.         ERROR STFQUIT
  428.     ELSEIF sz$ = "REACTIVATE" THEN
  429.         GOTO ASKQUIT
  430.     ELSE
  431.         UIPop 1
  432.     END IF
  433.     RETURN
  434.  
  435.  
  436.  
  437. '**
  438. '** Purpose:
  439. '**     Adds the specified option files to the copy list.
  440. '** Arguments:
  441. '**     ftype%  - type of files to add, one of the following:
  442. '**             APPFILES, OPTFILES1
  443. '** Returns:
  444. '**     none.
  445. '*************************************************************************
  446. SUB AddOptFilesToCopyList (ftype%) STATIC
  447.     CheckType% = ftype%
  448.     if ftype% = REDESTRIB or ftype% = WINHELP then
  449.         CheckType = APPFILES
  450.     end if
  451.     IF GetListItem(CHECKSTATES$, CheckType%) = "ON" THEN
  452.         SrcDir$ = GetSymbolValue("STF_SRCDIR")
  453.         IF ftype% = APPFILES THEN
  454.             AddSectionFilesToCopyList "APPFILES", SrcDir$, DEST$
  455.             AddSectionFilesToCopyList "WINHELPFILES", SrcDir$, WINDIR$
  456.         ELSEIF ftype% = REDESTRIB THEN
  457.             for i% = 1 to GetListLength(NUMREDESTFILES$)
  458.                 AddSpecialFileToCopyList SECTREDESTRIB$, chr$(48 + i%), SrcDir$, SYSDIR$ + GetSectionKeyFilename(SECTREDESTRIB$, chr$(48 + i%))
  459.             next
  460.         ELSEIF ftype% = SAMPDATA THEN
  461.             FOR i% = 1 TO GetListLength(NUMSAMPDATA$) STEP 1
  462.                 if GetListItem(CHECKITEMS$, i%) = "ON" then
  463.                     AddSectionKeyFileToCopyList "SAMPDATA", chr$(48 + i%), SrcDir$, DEST$
  464.                 endif
  465.             NEXT i%
  466.         END IF
  467.         SrcDir$ = ""
  468.     END IF
  469. END SUB
  470.  
  471.  
  472. '**
  473. '** Purpose:
  474. '**     Recalculates disk space for the given option files and sets
  475. '**     the status info symbol "StatusItemsText".
  476. '** Arguments:
  477. '**     ftype% - type of files to add
  478. '**             APPFILES, SAMPDATA
  479. '** Returns:
  480. '**     none.
  481. '*************************************************************************
  482. SUB RecalcOptFiles (ftype%) STATIC
  483.     CursorSave% = ShowWaitCursor()
  484.     ClearCopyList
  485.     AddOptFilesToCopyList ftype%
  486.  
  487.     fExtra% = 0
  488.     cost& = 0
  489.     IF ftype% = APPFILES THEN
  490.         IF GetListItem(CHECKSTATES$, APPFILES) = "ON" THEN
  491.             ''Add extra cost to Windows drive for ini/progman, etc.
  492.             ndrive% = ASC(ucase$(WINDRIVE$)) - ASC("A") + 1
  493.             ReplaceListItem EXTRACOSTS$, ndrive%, "10240"
  494.             fExtra% = 1
  495.             cost& = val(GetListItem(REDESTSIZE$, 1)) - ExistingFileSize(SECTREDESTRIB$, SYSDIR$)
  496.             ReplaceListItem REDESTNEEDS$, 1, str$(cost&)
  497.             cost& = val(GetListItem(WINHELPSIZE$, 1)) - ExistingFileSize("WINHELPFILES", WINDIR$)
  498.             ReplaceListItem WINHELPNEEDS$, 1, str$(cost&)
  499.             cost& = val(GetListItem(APPSIZE$, 1)) - ExistingFileSize("APPFILES", DEST$)
  500.         ELSE
  501.             ReplaceListItem REDESTNEEDS$, 1, "0"
  502.             ReplaceListItem WINHELPNEEDS$, 1, "0"
  503.         END IF
  504.         ReplaceListItem APPNEEDS$, 1, str$(cost&)
  505.     ELSEIF ftype% = SAMPDATA THEN
  506.         cost& = 0
  507.         IF GetListItem(CHECKSTATES$, SAMPDATA) = "ON" THEN
  508.             ListLength% = GetListLength(NUMSAMPDATA$)
  509.             FOR i% = 1 TO ListLength% STEP 1
  510.                 if GetListItem(CHECKITEMS$, i%) = "ON" then
  511.                     cost&  = cost& + VAL(GetListItem(SAMPSIZE$, i%))
  512.                     FileName$ = GetSectionKeyFilename("SAMPDATA", ltrim$(str$(i%)))
  513.                     DestinationFile$ = MakePath(DEST$, FileName$)
  514.                     ExistFlag% = DoesFileExist(DestinationFile$, femExists)
  515.                     IF ExistFlag% = 1 THEN
  516.                         cost& = cost& + GetSizeOfFile(DestinationFile$)
  517.                     END IF
  518.                 endif
  519.             NEXT i%
  520.         ELSE
  521.             cost& = 0
  522.         END IF
  523.         ReplaceListItem SAMPNEEDS$, 1, str$(cost&)
  524.         if (cost& = 0) then
  525.             ReplaceListItem CHECKSTATES$, SAMPDATA, "OFF"
  526.         else
  527.             ReplaceListItem CHECKSTATES$, SAMPDATA, "ON"
  528.         endif
  529.     END IF
  530.  
  531.     ReplaceListItem STATUSTEXT$, ftype%, STR$(cost& / 1024) + " K"
  532.  
  533.     IF fExtra% THEN
  534.         ReplaceListItem EXTRACOSTS$, ndrive%, "0"
  535.     END IF
  536.     RestoreCursor CursorSave%
  537.     ListSym$ = ""
  538. END SUB
  539.  
  540.  
  541. '**
  542. '** Purpose:
  543. '**     Recalculates disk space and sets option status info according
  544. '**     to the current destination path.
  545. '** Arguments:
  546. '**     none.
  547. '** Returns:
  548. '**     none.
  549. '*************************************************************************
  550. SUB RecalcPath STATIC
  551.     CursorSave% = ShowWaitCursor()
  552.  
  553.     RecalcOptFiles APPFILES '' Also handles redestributables
  554.     RecalcOptFiles SAMPDATA
  555.  
  556.     RestoreCursor CursorSave%
  557. END SUB
  558.  
  559.  
  560. '**
  561. '** Purpose:
  562. '**     Sets drive status info according to latest disk space calcs.
  563. '** Arguments:
  564. '**     none.
  565. '** Returns:
  566. '**     none.
  567. '*************************************************************************
  568. SUB SetDriveStatus STATIC
  569.     drive$ = MID$(DEST$, 1, 1)
  570.     ndrive% = ASC(ucase$(drive$)) - ASC("A") + 1
  571.     free& = GetFreeSpaceForDrive(drive$)
  572.     freedrive& = free&
  573.     ReplaceListItem DRIVETEXT$, 1, drive$ + ":"
  574.     ReplaceListItem DRIVETEXT$, 3, STR$(free& / 1024) + " K"
  575.  
  576.     IF drive$ = WINDRIVE$ THEN
  577.         cost& = VAL(GetListItem(APPNEEDS$, 1)) + VAL(GetListItem(WINHELPNEEDS$, 1)) + VAL(GetListItem(REDESTNEEDS$, 1)) + VAL(GetListItem(SAMPNEEDS$, 1))
  578.         ReplaceListItem DRIVETEXT$, 4, ""
  579.         ReplaceListItem DRIVETEXT$, 5, ""
  580.         ReplaceListItem DRIVETEXT$, 6, ""
  581.         IF ((free& - cost&) < 0) THEN
  582.             ReplaceListItem BIGLIST$, 1, "YES"
  583.         ELSE
  584.             ReplaceListItem BIGLIST$, 1, ""
  585.         END IF
  586.     ELSE
  587.         ndrive% = ASC(ucase$(WINDRIVE$)) - ASC("A") + 1
  588.         cost& =  VAL(GetListItem(WINHELPNEEDS$, 1)) + VAL(GetListItem(REDESTNEEDS$, 1))
  589.         IF cost& = 0 THEN
  590.             ReplaceListItem DRIVETEXT$, 4, ""
  591.             ReplaceListItem DRIVETEXT$, 5, ""
  592.             ReplaceListItem DRIVETEXT$, 6, ""
  593.         ELSE
  594.             free& = GetFreeSpaceForDrive(WINDRIVE$)
  595.             ReplaceListItem DRIVETEXT$, 4, WINDRIVE$ + ":"
  596.             ReplaceListItem DRIVETEXT$, 5, STR$(cost& / 1024) + " K"
  597.             ReplaceListItem DRIVETEXT$, 6, STR$(free& / 1024) + " K"
  598.             IF ((free& - cost&) < 0) THEN
  599.                 ReplaceListItem BIGLIST$, 2, "YES"
  600.             ELSE
  601.                 ReplaceListItem BIGLIST$, 1, ""
  602.             END IF
  603.         END IF
  604.         cost& = VAL(GetListItem(APPNEEDS$, 1)) + VAL(GetListItem(SAMPNEEDS$, 1))
  605.         IF ((freedrive& - cost&) < 0) THEN
  606.             ReplaceListItem BIGLIST$, 1, "YES"
  607.         ELSE
  608.             ReplaceListItem BIGLIST$, 1, ""
  609.         END IF
  610.     END IF
  611.  
  612.     ReplaceListItem DRIVETEXT$, 2, STR$(cost& / 1024) + " K"
  613. END SUB
  614.  
  615.  
  616. '**
  617. '** Purpose:
  618. '**     Appends a file name to the end of a directory path,
  619. '**     inserting a backslash character as needed.
  620. '** Arguments:
  621. '**     szDir$  - full directory path (with optional ending "\")
  622. '**     szFile$ - filename to append to directory
  623. '** Returns:
  624. '**     Resulting fully qualified path name.
  625. '*************************************************************************
  626. FUNCTION MakePath (szDir$, szFile$) STATIC AS STRING
  627.     IF szDir$ = "" THEN
  628.         MakePath = szFile$
  629.     ELSEIF szFile$ = "" THEN
  630.         MakePath = szDir$
  631.     ELSEIF MID$(szDir$, LEN(szDir$), 1) = "\" THEN
  632.         MakePath = szDir$ + szFile$
  633.     ELSE
  634.         MakePath = szDir$ + "\" + szFile$
  635.     END IF
  636. END FUNCTION
  637.  
  638.  
  639. '**
  640. '** Purpose:
  641. '**     Calculate the size of the files that already exist within a section.
  642. '** Arguments:
  643. '**     Section$   - Name of section within .INF file
  644. '**     Directory$ - directory on users hard disk to search
  645. '** Returns:
  646. '**     The size of the files that exist.
  647. '*************************************************************************
  648. FUNCTION ExistingFileSize(Section$, Directory$) STATIC AS LONG
  649.     total& = 0
  650.     TempSym$ = "TempSym"
  651.     MakeListFromSectionKeys TempSym$, Section$
  652.     Num% = GetListLength(TempSym$)
  653.     for i% = 1 to Num%
  654.         key% = val(GetListItem(TempSym$, i%))
  655.         FileName$ = GetSectionKeyFilename(Section$, ltrim$(str$(i%)))
  656.         DestinationFile$ = MakePath(Directory$, FileName$)
  657.         flag% = DoesFileExist(DestinationFile$, femExists)
  658.         IF flag% = 1 THEN
  659.             total& = total& + GetSizeOfFile(DestinationFile$)
  660.         END IF
  661.     next
  662.     ExistingFileSize& = total&
  663. END FUNCTION
  664.