home *** CD-ROM | disk | FTP | other *** search
/ PC PowerPlay 61 / CDPowerplay61Disc2.iso / OUTLINE / SIAM.MS_ / SIAM.MS
Encoding:
Text File  |  1993-03-16  |  13.8 KB  |  510 lines

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