home *** CD-ROM | disk | FTP | other *** search
/ PC Musician 2000 / PC_Musician_2000.iso / PCMUSIC / PATCHES / BANKEDIT / SETUP.MST < prev    next >
Encoding:
Text File  |  1997-02-25  |  15.0 KB  |  554 lines

  1. '**************************************************************************
  2. '*                            BANK EDITOR
  3. '**************************************************************************
  4.  
  5. '*$DEFINE DEBUG  ''Define for script development/debugging
  6.  
  7. '$INCLUDE 'setupapi.inc'
  8. '$INCLUDE 'msdetect.inc'
  9.  
  10. ''Dialog ID's
  11. CONST ASKQUIT      = 200
  12. CONST DESTPATH     = 300
  13. CONST EXITFAILURE  = 400
  14. CONST EXITQUIT     = 600
  15. CONST EXITSUCCESS  = 700
  16. CONST OPTIONS      = 800
  17. CONST APPHELP      = 900
  18. CONST CUSTINST     = 6200
  19. CONST TOOBIG       = 6300
  20. CONST BADPATH      = 6400
  21.  
  22. ''Bitmap ID
  23. CONST LOGO         = 1
  24.  
  25. ''File Types
  26. CONST APPFILES     = 1
  27. CONST OPTFILES1    = 2
  28. CONST OPTFILES2    = 3
  29. CONST OPTFILES3    = 4
  30.  
  31.  
  32. GLOBAL DEST$        ''Default destination directory.
  33. GLOBAL WINDRIVE$    ''Windows drive letter.
  34. GLOBAL OPT1OPT$     ''Option selection from OptFiles1 option dialog.
  35. GLOBAL OPT2OPT$     ''Option selection from OptFiles2 option dialog.
  36. GLOBAL OPT3OPT$     ''Option selection from OptFiles3 option dialog.
  37.  
  38. ''CustInst list symbol names
  39. GLOBAL APPNEEDS$    ''Option list costs per drive
  40. GLOBAL OPT1NEEDS$
  41. GLOBAL OPT2NEEDS$
  42. GLOBAL OPT3NEEDS$
  43. GLOBAL EXTRACOSTS$  ''List of extra costs to add per drive
  44. GLOBAL BIGLIST$     ''List of option files cost calc results (boolean)
  45.  
  46. ''Dialog list symbol names
  47. GLOBAL CHECKSTATES$
  48. GLOBAL STATUSTEXT$
  49. GLOBAL DRIVETEXT$
  50.  
  51.  
  52. DECLARE SUB AddOptFilesToCopyList (ftype%)
  53. DECLARE SUB RecalcOptFiles (ftype%)
  54. DECLARE SUB RecalcPath
  55. DECLARE SUB SetDriveStatus
  56. DECLARE FUNCTION MakePath (szDir$, szFile$) AS STRING
  57.  
  58.  
  59.  
  60. INIT:
  61.     CUIDLL$ = "mscuistf.dll"            ''custom user interface dll
  62.     HELPPROC$ = "FHelpDlgProc"          ''Help dialog procedure
  63.  
  64.     SetBitmap CUIDLL$, LOGO
  65.     SetTitle "Bank Editor Setup"
  66.  
  67.     szInf$ = GetSymbolValue("STF_SRCINFPATH")
  68.     IF szInf$ = "" THEN
  69.         szInf$ = GetSymbolValue("STF_CWDDIR") + "SETUP.INF"
  70.     END IF
  71.     ReadInfFile szInf$
  72.  
  73.     WINDRIVE$ = MID$(GetWindowsDir, 1, 1)
  74.     DEST$ = WINDRIVE$ + ":\BANKEDIT"
  75.  
  76.     ''CustInst list symbols
  77.     CHECKSTATES$ = "CheckItemsState"
  78.     STATUSTEXT$  = "StatusItemsText"
  79.     DRIVETEXT$   = "DriveStatusText"
  80.     FOR i% = 1 TO 4 STEP 1
  81.         AddListItem CHECKSTATES$, "ON"
  82.     NEXT i%
  83.     FOR i% = 1 TO 4 STEP 1
  84.         AddListItem STATUSTEXT$, ""
  85.     NEXT i%
  86.     FOR i% = 1 TO 7 STEP 1
  87.         AddListItem DRIVETEXT$, ""
  88.     NEXT i%
  89.     ReplaceListItem DRIVETEXT$, 7, DEST$
  90.  
  91.     ''Disk cost list symbols
  92.     APPNEEDS$   = "AppNeeds"
  93.     OPT1NEEDS$  = "Opt1Needs"
  94.     OPT2NEEDS$  = "Opt2Needs"
  95.     OPT3NEEDS$  = "Opt3Needs"
  96.     EXTRACOSTS$ = "ExtraCosts"
  97.     BIGLIST$    = "BigList"
  98.     FOR i% = 1 TO 4 STEP 1
  99.         AddListItem BIGLIST$, ""
  100.     NEXT i%
  101.     FOR i% = 1 TO 26 STEP 1
  102.         AddListItem EXTRACOSTS$, "0"
  103.     NEXT i%
  104.  
  105.     ''File Option Variables
  106.     OPT1OPT$ = "1"
  107.     OPT2OPT$ = "1"
  108.     OPT3OPT$ = "1"
  109.  
  110.     RecalcPath
  111.     SetDriveStatus
  112.  
  113. '$IFDEF DEBUG
  114.     i% = SetSizeCheckMode(scmOnIgnore)    '' could use scmOff; def = scmOnFatal
  115. '$ENDIF ''DEBUG
  116.  
  117.  
  118.  
  119. CUSTINST:
  120.     sz$ = UIStartDlg(CUIDLL$, CUSTINST, "FCustInstDlgProc", APPHELP, HELPPROC$)
  121.  
  122.     IF sz$ = "CONTINUE" THEN
  123.         ''Install only if it will fit.
  124.         FOR i% = 1 TO 4 STEP 1
  125.             IF GetListItem(BIGLIST$, i%) <> "" THEN
  126.                 GOSUB TOOBIG
  127.                 GOTO CUSTINST
  128.             END IF
  129.         NEXT i%
  130.         UIPop 1
  131.         GOTO INSTALL
  132.     ELSEIF sz$ = "PATH" THEN
  133.         GOTO GETPATH
  134.     ELSEIF sz$ = "CHK1" THEN
  135.         RecalcOptFiles APPFILES
  136.         SetDriveStatus
  137.         GOTO CUSTINST
  138.     ELSEIF sz$ = "CHK2" THEN
  139.         RecalcOptFiles OPTFILES1
  140.         SetDriveStatus
  141.         GOTO CUSTINST
  142.     ELSEIF sz$ = "CHK3" THEN
  143.         RecalcOptFiles OPTFILES2
  144.         SetDriveStatus
  145.         GOTO CUSTINST
  146.     ELSEIF sz$ = "CHK4" THEN
  147.         RecalcOptFiles OPTFILES3
  148.         SetDriveStatus
  149.         GOTO CUSTINST
  150.     ELSEIF sz$ = "BTN2" THEN
  151.         GOTO OPTFILES1
  152.     ELSEIF sz$ = "BTN3" THEN
  153.         GOTO OPTFILES2
  154.     ELSEIF sz$ = "BTN4" THEN
  155.         GOTO OPTFILES3
  156.     ELSEIF sz$ = "REACTIVATE" THEN
  157.         RecalcPath
  158.         SetDriveStatus
  159.         GOTO CUSTINST
  160.     ELSE
  161.         GOSUB ASKQUIT
  162.         GOTO CUSTINST
  163.     END IF
  164.  
  165.  
  166.  
  167. INSTALL:
  168.     ClearCopyList
  169.     AddOptFilesToCopyList APPFILES
  170.     AddOptFilesToCopyList OPTFILES1
  171.     AddOptFilesToCopyList OPTFILES2
  172.     AddOptFilesToCopyList OPTFILES3
  173.     CreateDir DEST$, cmoNone
  174.     CopyFilesInCopyList
  175.  
  176.     IF GetListItem(CHECKSTATES$, APPFILES) = "ON" THEN
  177.         CreateProgmanGroup "Bank Editor", "", cmoNone
  178.         ShowProgmanGroup  "Bank Editor", 1, cmoNone
  179.         CreateProgmanItem "Bank Editor", "Bank Editor", MakePath(DEST$,"bankedit.exe"), "", cmoOverwrite
  180.         CreateProgmanItem "Bank Editor", "Read Me First", MakePath(DEST$,"README.WRI"), "", cmoOverwrite
  181.         CreateProgmanItem "Bank Editor", "License Details", MakePath(DEST$,"LICENSE.TXT"), "", cmoOverwrite
  182.         CreateProgmanItem "Bank Editor", "Features", MakePath(DEST$,"FEATURES.WRI"), "", cmoOverwrite
  183.         CreateProgmanItem "Bank Editor", "Order Form", MakePath(DEST$,"ORDER.WRI"), "", cmoOverwrite
  184.         CreateProgmanItem "Bank Editor", "Upgrade Form", MakePath(DEST$,"UPGRADE.WRI"), "", cmoOverwrite
  185.         CreateProgmanItem "Bank Editor", "Report Form", MakePath(DEST$,"REPORT.WRI"), "", cmoOverwrite
  186.     END IF
  187.  
  188.  
  189. QUIT:
  190.     ON ERROR GOTO ERRQUIT
  191.  
  192.     IF ERR = 0 THEN
  193.         dlg% = EXITSUCCESS
  194.     ELSEIF ERR = STFQUIT THEN
  195.         dlg% = EXITQUIT
  196.     ELSE
  197.         dlg% = EXITFAILURE
  198.     END IF
  199. QUITL1:
  200.     sz$ = UIStartDlg(CUIDLL$, dlg%, "FInfo0DlgProc", 0, "")
  201.     IF sz$ = "REACTIVATE" THEN
  202.         GOTO QUITL1
  203.     END IF
  204.     UIPop 1
  205.  
  206.     END
  207.  
  208. ERRQUIT:
  209.     i% = DoMsgBox("Setup sources were corrupt!", "Setup Message", MB_OK+MB_TASKMODAL+MB_ICONHAND)
  210.     END
  211.  
  212.  
  213.  
  214. GETPATH:
  215.     SetSymbolValue "EditTextIn", DEST$
  216.     SetSymbolValue "EditFocus", "END"
  217. GETPATHL1:
  218.     sz$ = UIStartDlg(CUIDLL$, DESTPATH, "FEditDlgProc", APPHELP, HELPPROC$)
  219.  
  220.     IF sz$ = "CONTINUE" THEN
  221.         olddest$ = DEST$
  222.         DEST$ = GetSymbolValue("EditTextOut")
  223.  
  224.         ''Validate new path.
  225.         IF IsDirWritable(DEST$) = 0 THEN
  226.             GOSUB BADPATH
  227.             GOTO GETPATHL1
  228.         END IF
  229.         UIPop 1
  230.  
  231.         ''Truncate display if too long.
  232.         IF LEN(DEST$) > 23 THEN
  233.             ReplaceListItem DRIVETEXT$, 7, MID$(DEST$, 1, 23)+"..."
  234.         ELSE
  235.             ReplaceListItem DRIVETEXT$, 7, DEST$
  236.         END IF
  237.  
  238.         ''Recalc if path changed.
  239.         IF (olddest$ <> DEST$) AND (olddest$ <> DEST$+"\") AND (olddest$+"\" <> DEST$) THEN
  240.             RecalcPath
  241.             SetDriveStatus
  242.         END IF
  243.  
  244.         olddest$ = ""
  245.         GOTO CUSTINST
  246.     ELSEIF sz$ = "REACTIVATE" THEN
  247.         RecalcPath
  248.         SetDriveStatus
  249.         GOTO GETPATHL1
  250.     ELSEIF sz$ = "EXIT" THEN
  251.         GOSUB ASKQUIT
  252.         GOTO GETPATHL1
  253.     ELSE
  254.         UIPop 1
  255.         GOTO CUSTINST
  256.     END IF
  257.  
  258.  
  259.  
  260. OPTFILES1:
  261.     SetSymbolValue "RadioDefault", OPT1OPT$
  262. OPT1L1:
  263.     sz$ = UIStartDlg(CUIDLL$, OPTIONS, "FRadioDlgProc", APPHELP, HELPPROC$)
  264.     newopt$ = GetSymbolValue("ButtonChecked")
  265.  
  266.     IF sz$ = "CONTINUE" THEN
  267.         UIPop 1
  268.         IF newopt$ <> OPT1OPT$ THEN
  269.             OPT1OPT$ = newopt$
  270.             RecalcOptFiles OPTFILES1
  271.             SetDriveStatus
  272.         END IF
  273.         newopt$ = ""
  274.         GOTO CUSTINST
  275.     ELSEIF sz$ = "REACTIVATE" THEN
  276.         RecalcPath
  277.         SetDriveStatus
  278.         GOTO OPT1L1
  279.     ELSEIF sz$ = "EXIT" THEN
  280.         GOSUB ASKQUIT
  281.         GOTO OPT1L1
  282.     ELSE
  283.         UIPop 1
  284.         newopt$ = ""
  285.         GOTO CUSTINST
  286.     END IF
  287.  
  288.  
  289.  
  290. OPTFILES2:
  291.     SetSymbolValue "RadioDefault", OPT2OPT$
  292. OPT2L1:
  293.     sz$ = UIStartDlg(CUIDLL$, OPTIONS, "FRadioDlgProc", APPHELP, HELPPROC$)
  294.     newopt$ = GetSymbolValue("ButtonChecked")
  295.  
  296.     IF sz$ = "CONTINUE" THEN
  297.         UIPop 1
  298.         IF newopt$ <> OPT2OPT$ THEN
  299.             OPT2OPT$ = newopt$
  300.             RecalcOptFiles OPTFILES2
  301.             SetDriveStatus
  302.         END IF
  303.         newopt$ = ""
  304.         GOTO CUSTINST
  305.     ELSEIF sz$ = "REACTIVATE" THEN
  306.         RecalcPath
  307.         SetDriveStatus
  308.         GOTO OPT2L1
  309.     ELSEIF sz$ = "EXIT" THEN
  310.         GOSUB ASKQUIT
  311.         GOTO OPT2L1
  312.     ELSE
  313.         UIPop 1
  314.         newopt$ = ""
  315.         GOTO CUSTINST
  316.     END IF
  317.  
  318.  
  319.  
  320. OPTFILES3:
  321.     SetSymbolValue "RadioDefault", OPT3OPT$
  322. OPT3L1:
  323.     sz$ = UIStartDlg(CUIDLL$, OPTIONS, "FRadioDlgProc", APPHELP, HELPPROC$)
  324.     newopt$ = GetSymbolValue("ButtonChecked")
  325.  
  326.     IF sz$ = "CONTINUE" THEN
  327.         UIPop 1
  328.         IF newopt$ <> OPT3OPT$ THEN
  329.             OPT3OPT$ = newopt$
  330.             RecalcOptFiles OPTFILES3
  331.             SetDriveStatus
  332.         END IF
  333.         newopt$ = ""
  334.         GOTO CUSTINST
  335.     ELSEIF sz$ = "REACTIVATE" THEN
  336.         RecalcPath
  337.         SetDriveStatus
  338.         GOTO OPT3L1
  339.     ELSEIF sz$ = "EXIT" THEN
  340.         GOSUB ASKQUIT
  341.         GOTO OPT3L1
  342.     ELSE
  343.         UIPop 1
  344.         newopt$ = ""
  345.         GOTO CUSTINST
  346.     END IF
  347.  
  348.  
  349.  
  350. TOOBIG:
  351.     sz$ = UIStartDlg(CUIDLL$, TOOBIG, "FInfo0DlgProc", 0, "")
  352.     IF sz$ = "REACTIVATE" THEN
  353.         RecalcPath
  354.         SetDriveStatus
  355.         GOTO TOOBIG
  356.     END IF
  357.     UIPop 1
  358.     RETURN
  359.  
  360.  
  361.  
  362. BADPATH:
  363.     sz$ = UIStartDlg(CUIDLL$, BADPATH, "FInfo0DlgProc", 0, "")
  364.     IF sz$ = "REACTIVATE" THEN
  365.         RecalcPath
  366.         SetDriveStatus
  367.         GOTO BADPATH
  368.     END IF
  369.     UIPop 1
  370.     RETURN
  371.  
  372.  
  373.  
  374. ASKQUIT:
  375.     sz$ = UIStartDlg(CUIDLL$, ASKQUIT, "FQuitDlgProc", 0, "")
  376.  
  377.     IF sz$ = "EXIT" THEN
  378.         UIPopAll
  379.         ERROR STFQUIT
  380.     ELSEIF sz$ = "REACTIVATE" THEN
  381.         GOTO ASKQUIT
  382.     ELSE
  383.         UIPop 1
  384.     END IF
  385.     RETURN
  386.  
  387.  
  388.  
  389. '**
  390. '** Purpose:
  391. '**     Adds the specified option files to the copy list.
  392. '** Arguments:
  393. '**     ftype%  - type of files to add, one of the following:
  394. '**             APPFILES, OPTFILES1, OPTFILES2, OPTFILES3
  395. '** Returns:
  396. '**     none.
  397. '*************************************************************************
  398. SUB AddOptFilesToCopyList (ftype%) STATIC
  399.  
  400.     IF GetListItem(CHECKSTATES$, ftype%) = "ON" THEN
  401.         SrcDir$ = GetSymbolValue("STF_SRCDIR")
  402.         IF ftype% = APPFILES THEN
  403.             AddSectionFilesToCopyList "AppFiles", SrcDir$, DEST$
  404.             AddSectionFilesToCopyList "WinFiles", SrcDir$, GetWindowsDir
  405.         ELSEIF ftype% = OPTFILES1 THEN
  406.             AddSectionFilesToCopyList "OptFiles1", SrcDir$, DEST$
  407.         ELSEIF ftype% = OPTFILES2 THEN
  408.             AddSectionFilesToCopyList "OptFiles2", SrcDir$, DEST$
  409.         ELSEIF ftype% = OPTFILES3 THEN
  410.             AddSectionFilesToCopyList "OptFiles3", SrcDir$, DEST$
  411.         END IF            
  412.         SrcDir$ = ""
  413.     END IF
  414. END SUB
  415.  
  416.  
  417. '**
  418. '** Purpose:
  419. '**     Recalculates disk space for the given option files and sets
  420. '**     the status info symbol "StatusItemsText".
  421. '** Arguments:
  422. '**     ftype% - type of files to add, one of the following:
  423. '**             APPFILES, OPTFILES1, OPTFILES2
  424. '** Returns:
  425. '**     none.
  426. '*************************************************************************
  427. SUB RecalcOptFiles (ftype%) STATIC
  428.     CursorSave% = ShowWaitCursor()
  429.     ClearCopyList
  430.     AddOptFilesToCopyList ftype%
  431.  
  432.     fExtra% = 0
  433.     IF ftype% = APPFILES THEN
  434.         ListSym$ = APPNEEDS$
  435.         IF GetListItem(CHECKSTATES$, APPFILES) = "ON" THEN
  436.             ''Add extra cost to Windows drive for ini/progman, etc.
  437.             ndrive% = ASC(ucase$(WINDRIVE$)) - ASC("A") + 1
  438.             ReplaceListItem EXTRACOSTS$, ndrive%, "10240"
  439.             fExtra% = 1
  440.         END IF
  441.     ELSEIF ftype% = OPTFILES1 THEN
  442.         ListSym$ = OPT1NEEDS$
  443.     ELSEIF ftype% = OPTFILES2 THEN
  444.         ListSym$ = OPT2NEEDS$
  445.     ELSEIF ftype% = OPTFILES3 THEN
  446.         ListSym$ = OPT3NEEDS$
  447.     END IF
  448.  
  449.     StillNeed& = GetCopyListCost(EXTRACOSTS$, ListSym$, "")
  450.  
  451.     cost& = 0
  452.     FOR i% = 1 TO 26 STEP 1
  453.         cost&  = cost& + VAL(GetListItem(ListSym$, i%))
  454.     NEXT i%
  455.     ReplaceListItem STATUSTEXT$, ftype%, STR$(cost& / 1024) + " K"
  456.  
  457.     IF StillNeed& > 0 THEN
  458.         ReplaceListItem BIGLIST$, ftype%, "YES"
  459.     ELSE
  460.         ReplaceListItem BIGLIST$, ftype%, ""
  461.     END IF
  462.  
  463.     IF fExtra% THEN
  464.         ReplaceListItem EXTRACOSTS$, ndrive%, "0"
  465.     END IF
  466.     RestoreCursor CursorSave%
  467.     ListSym$ = ""
  468. END SUB
  469.  
  470.  
  471. '**
  472. '** Purpose:
  473. '**     Recalculates disk space and sets option status info according
  474. '**     to the current destination path.
  475. '** Arguments:
  476. '**     none.
  477. '** Returns:
  478. '**     none.
  479. '*************************************************************************
  480. SUB RecalcPath STATIC
  481.  
  482.     CursorSave% = ShowWaitCursor()
  483.  
  484.     RecalcOptFiles APPFILES
  485.     RecalcOptFiles OPTFILES1
  486.     RecalcOptFiles OPTFILES2
  487.     RecalcOptFiles OPTFILES3
  488.  
  489.     RestoreCursor CursorSave%
  490. END SUB
  491.  
  492.  
  493. '**
  494. '** Purpose:
  495. '**     Sets drive status info according to latest disk space calcs.
  496. '** Arguments:
  497. '**     none.
  498. '** Returns:
  499. '**     none.
  500. '*************************************************************************
  501. SUB SetDriveStatus STATIC
  502.  
  503.     drive$ = MID$(DEST$, 1, 1)
  504.     ndrive% = ASC(ucase$(drive$)) - ASC("A") + 1
  505.     cost& = VAL(GetListItem(APPNEEDS$, ndrive%)) + VAL(GetListItem(OPT1NEEDS$, ndrive%)) + VAL(GetListItem(OPT2NEEDS$, ndrive%))  + VAL(GetListItem(OPT3NEEDS$, ndrive%))
  506.     free& = GetFreeSpaceForDrive(drive$)
  507.     ReplaceListItem DRIVETEXT$, 1, drive$ + ":"
  508.     ReplaceListItem DRIVETEXT$, 2, STR$(cost& / 1024) + " K"
  509.     ReplaceListItem DRIVETEXT$, 3, STR$(free& / 1024) + " K"
  510.  
  511.     IF drive$ = WINDRIVE$ THEN
  512.         ReplaceListItem DRIVETEXT$, 4, ""
  513.         ReplaceListItem DRIVETEXT$, 5, ""
  514.         ReplaceListItem DRIVETEXT$, 6, ""
  515.     ELSE
  516.         ndrive% = ASC(ucase$(WINDRIVE$)) - ASC("A") + 1
  517.         cost& = VAL(GetListItem(APPNEEDS$, ndrive%)) + VAL(GetListItem(OPT1NEEDS$, ndrive%)) + VAL(GetListItem(OPT2NEEDS$, ndrive%))  + VAL(GetListItem(OPT3NEEDS$, ndrive%))
  518.         IF cost& = 0 THEN
  519.             ReplaceListItem DRIVETEXT$, 4, ""
  520.             ReplaceListItem DRIVETEXT$, 5, ""
  521.             ReplaceListItem DRIVETEXT$, 6, ""
  522.         ELSE
  523.             free& = GetFreeSpaceForDrive(WINDRIVE$)
  524.             ReplaceListItem DRIVETEXT$, 4, WINDRIVE$ + ":"
  525.             ReplaceListItem DRIVETEXT$, 5, STR$(cost& / 1024) + " K"
  526.             ReplaceListItem DRIVETEXT$, 6, STR$(free& / 1024) + " K"
  527.         END IF
  528.     END IF
  529. END SUB
  530.  
  531.  
  532. '**
  533. '** Purpose:
  534. '**     Appends a file name to the end of a directory path,
  535. '**     inserting a backslash character as needed.
  536. '** Arguments:
  537. '**     szDir$  - full directory path (with optional ending "\")
  538. '**     szFile$ - filename to append to directory
  539. '** Returns:
  540. '**     Resulting fully qualified path name.
  541. '*************************************************************************
  542. FUNCTION MakePath (szDir$, szFile$) STATIC AS STRING
  543.     IF szDir$ = "" THEN
  544.         MakePath = szFile$
  545.     ELSEIF szFile$ = "" THEN
  546.         MakePath = szDir$
  547.     ELSEIF MID$(szDir$, LEN(szDir$), 1) = "\" THEN
  548.         MakePath = szDir$ + szFile$
  549.     ELSE
  550.         MakePath = szDir$ + "\" + szFile$
  551.     END IF
  552. END FUNCTION
  553.  
  554.