home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 6 / 06.iso / b / b048 / 1.img / FTSINSTL.MST < prev    next >
Encoding:
Text File  |  1993-04-04  |  14.7 KB  |  574 lines

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