home *** CD-ROM | disk | FTP | other *** search
/ Programming Tool Box / SIMS_2.iso / demo / erwin / erwsetup.mst < prev    next >
Text File  |  1994-12-01  |  13KB  |  455 lines

  1. '**************************************************************************
  2. '*                       ERwin Setup Script
  3. '**************************************************************************
  4. 'Special version for ERwin quick start, with no options of any kind
  5. 'no serial number, name or organization prompt.
  6.  
  7. '$DEFINE DEBUG  ''Define for script development/debugging
  8.  
  9. '$INCLUDE 'setupapi.inc'
  10. '$INCLUDE 'msdetect.inc'
  11.  
  12. ''following were taken from windows.h.  &H means they are Hex
  13. CONST WS_VISIBLE      = &H10000000
  14. CONST WS_BORDER          = &H00800000
  15. CONST WS_CLIPCHILDREN = &H02000000
  16. CONST GWL_STYLE          = -16
  17. CONST SW_SHOWMAXIMIZED= 3
  18.  
  19. DECLARE FUNCTION ShowWindow LIB "user.exe" (hWnd%,iShow%) AS INTEGER
  20. DECLARE FUNCTION SetWindowLong LIB "user.exe" (hWnd%, offset%, style&) AS LONG
  21.  
  22. ''Dialog ID's
  23. CONST WELCOME       = 100
  24. CONST ASKQUIT      = 200
  25. CONST DESTPATH     = 300
  26. CONST EXITFAILURE  = 400
  27. CONST EXITQUIT     = 600
  28. CONST EXITSUCCESS  = 700
  29. CONST OPTIONS      = 800
  30. CONST APPHELP      = 900
  31. CONST CUSTINST     = 6200
  32. CONST TOOBIG       = 6300
  33. CONST BADPATH      = 6400
  34. CONST CDGETNAMEORG = 7500
  35. CONST ERWCUSTOM       = 7900
  36. CONST ERWSERIAL       = 8000
  37. CONST ERWBILL1       = 8100
  38. CONST ERWBILL2       = 8200
  39. CONST ERWBILL3       = 8300
  40. CONST ERWBILL4       = 8400
  41. CONST BLANKSERIAL  = 8500
  42. CONST QUICKSWARN   = 8700
  43.  
  44. ''Bitmap ID
  45. CONST LOGO         = 1
  46.  
  47. ''File Types
  48. CONST APPFILES     = 1
  49. CONST HELPFILES    = 2
  50. CONST SAMPLES      = 3
  51.  
  52. GLOBAL DEST$        ''Default destination directory.
  53. GLOBAL WINDRIVE$    ''Windows drive letter.
  54. GLOBAL WINDIR$        ''Windows system directory
  55. GLOBAL USERNAME$    ''User Name
  56. GLOBAL USERORG$     ''User Organization
  57. GLOBAL SERIALNO$    ''ERwin Serial Number
  58.  
  59. ''CustInst list symbol names
  60. GLOBAL APPNEEDS$    ''Option list costs per drive
  61. GLOBAL HELPNEEDS$
  62. GLOBAL SAMPNEEDS$
  63. GLOBAL EXTRACOSTS$  ''List of extra costs to add per drive
  64. GLOBAL BIGLIST$     ''List of option files cost calc results (boolean)
  65.  
  66. ''Dialog list symbol names
  67. GLOBAL CHECKSTATES$
  68. GLOBAL STATUSTEXT$
  69. GLOBAL DRIVETEXT$
  70.  
  71.  
  72. DECLARE SUB AddOptFilesToCopyList (ftype%)
  73. DECLARE SUB RecalcOptFiles (ftype%)
  74. DECLARE SUB RecalcPath
  75. DECLARE SUB SetDriveStatus
  76. DECLARE FUNCTION MakePath (szDir$, szFile$) AS STRING
  77.  
  78.  
  79.  
  80. INIT:
  81.  
  82.     hWnd% = HwndFrame()
  83.     i1&=SetWindowLong(hWnd%,GWL_STYLE,WS_VISIBLE+WS_BORDER+WS_CLIPCHILDREN)
  84.     j1%=ShowWindow(hWnd%,SW_SHOWMAXIMIZED)
  85.  
  86.     CUIDLL$ = "mscuistf.dll"            ''custom user interface dll
  87.     HELPPROC$ = "FHelpDlgProc"          ''Help dialog procedure
  88.  
  89.     SetBitmap CUIDLL$, LOGO
  90.     SetTitle "ERwin/ERX 2.0 Setup"
  91.  
  92.     szInf$ = GetSymbolValue("STF_SRCINFPATH")
  93.     IF szInf$ = "" THEN
  94.         szInf$ = GetSymbolValue("STF_CWDDIR") + "ERWSETUP.INF"
  95.     END IF
  96.     ReadInfFile szInf$
  97.  
  98.     WINDIR$ = GetWindowsSysDir
  99.     WINDRIVE$ = MID$(GetWindowsDir, 1, 1)
  100.     DEST$ = WINDRIVE$ + ":\ERWQS"
  101.  
  102.     ''CustInst list symbols
  103.     CHECKSTATES$ = "CheckItemsState"
  104.     STATUSTEXT$  = "StatusItemsText"
  105.     DRIVETEXT$   = "DriveStatusText"
  106.     FOR i% = 1 TO 3 STEP 1
  107.         AddListItem CHECKSTATES$, "ON"
  108.     NEXT i%
  109.     FOR i% = 1 TO 3 STEP 1
  110.         AddListItem STATUSTEXT$, ""
  111.     NEXT i%
  112.     FOR i% = 1 TO 7 STEP 1
  113.         AddListItem DRIVETEXT$, ""
  114.     NEXT i%
  115.     ReplaceListItem DRIVETEXT$, 7, DEST$
  116.  
  117.     ''Disk cost list symbols
  118.     APPNEEDS$   = "ERwin/ERX program files"
  119.     HELPNEEDS$  = "Help Files"
  120.     SAMPNEEDS$  = "Sample Diagrams"
  121.     EXTRACOSTS$ = "ExtraCosts"
  122.     BIGLIST$    = "BigList"
  123.     FOR i% = 1 TO 3 STEP 1
  124.         AddListItem BIGLIST$, ""
  125.     NEXT i%
  126.     FOR i% = 1 TO 26 STEP 1
  127.         AddListItem EXTRACOSTS$, "0"
  128.     NEXT i%
  129.  
  130.     ''File Option Variables
  131.     OPT1OPT$ = "1"
  132.     OPT2OPT$ = "1"
  133.  
  134.     RecalcPath
  135.     SetDriveStatus
  136.  
  137. '$IFDEF DEBUG
  138.     i% = SetSizeCheckMode(scmOnIgnore)    '' could use scmOff; def = scmOnFatal
  139. '$ENDIF ''DEBUG
  140.  
  141.  
  142. WELCOME:
  143.     sz$ = UIStartDlg(CUIDLL$, WELCOME, "FInfoDlgProc", APPHELP, HELPPROC$)
  144.     IF sz$ = "CONTINUE" THEN
  145.         UIPop 1
  146.     ELSE
  147.         GOSUB ASKQUIT
  148.         GOTO WELCOME
  149.     END IF
  150.     
  151. STPATH:
  152.  
  153.     GOTO GETPATH
  154. CHEKPATH:
  155.     IF DEST$ = "C:\ERWQS" THEN
  156.         GOTO INSTALL
  157.     ELSE
  158.         sz$ = UIStartDlg(CUIDLL$, QUICKSWARN, "FEditDlgProc", APPHELP, HELPPROC$)
  159.         IF sz$ = "CONTINUE" THEN
  160.             UIPop 1
  161.             GOTO INSTALL
  162.         ELSEIF sz$ = "EXIT" THEN
  163.             GOSUB ASKQUIT
  164.             UIPop 1
  165.             GOTO STPATH
  166.         ELSE
  167.             UIPop 1
  168.             GOTO STPATH
  169.         END IF    
  170.     END IF
  171.  
  172. INSTALL:
  173.     ClearCopyList
  174.     AddOptFilesToCopyList APPFILES
  175.     AddOptFilesToCopyList SAMPLES
  176.  
  177.     CreateDir DEST$, cmoNone
  178.     CopyFilesInCopyList
  179.  
  180.     CreateProgmanGroup "ERwin/QuickStart for PB", "", cmoNone
  181.     ShowProgmanGroup  "ERwin/QuickStart for PB", 1, cmoNone
  182.     CreateProgmanItem "ERwin/QuickStart for PB", "ERwin/QuickStart", MakePath(DEST$,"ERWQSP16.EXE"), "", cmoOverwrite
  183.  
  184.  
  185.  
  186. QUIT:
  187.     ON ERROR GOTO ERRQUIT
  188.  
  189.     IF ERR = 0 THEN
  190.         dlg% = EXITSUCCESS
  191.     ELSEIF ERR = STFQUIT THEN
  192.         dlg% = EXITQUIT
  193.     ELSE
  194.         dlg% = EXITFAILURE
  195.     END IF
  196. QUITL1:
  197.     sz$ = UIStartDlg(CUIDLL$, dlg%, "FInfo0DlgProc", 0, "")
  198.     IF sz$ = "REACTIVATE" THEN
  199.         GOTO QUITL1
  200.     END IF
  201.     UIPop 1
  202.  
  203.     END
  204.  
  205. ERRQUIT:
  206.     i% = DoMsgBox("Setup sources were corrupted, call (609)252-1177!", "Setup Message", MB_OK+MB_TASKMODAL+MB_ICONHAND)
  207.     END
  208.  
  209.  
  210.  
  211. GETPATH:
  212.     SetSymbolValue "EditTextIn", DEST$
  213.     SetSymbolValue "EditFocus", "END"
  214. GETPATHL1:
  215.     sz$ = UIStartDlg(CUIDLL$, DESTPATH, "FEditDlgProc", APPHELP, HELPPROC$)
  216.  
  217.     IF sz$ = "CONTINUE" THEN
  218.         olddest$ = DEST$
  219.         DEST$ = GetSymbolValue("EditTextOut")
  220.  
  221.         ''Validate new path.
  222.         IF IsDirWritable(DEST$) = 0 THEN
  223.             GOSUB BADPATH
  224.             GOTO GETPATHL1
  225.         END IF
  226.         UIPop 1
  227.  
  228.         ''Truncate display if too long.
  229.         IF LEN(DEST$) > 23 THEN
  230.             ReplaceListItem DRIVETEXT$, 7, MID$(DEST$, 1, 23)+"..."
  231.         ELSE
  232.             ReplaceListItem DRIVETEXT$, 7, DEST$
  233.         END IF
  234.  
  235.         ''Recalc if path changed.
  236. ''        IF (olddest$ <> DEST$) AND (olddest$ <> DEST$+"\") AND (olddest$+"\" <> DEST$) THEN
  237. ''           RecalcPath
  238. ''           SetDriveStatus
  239. ''        END IF
  240.  
  241.         olddest$ = ""
  242.         GOTO CHEKPATH
  243.     ELSEIF sz$ = "REACTIVATE" THEN
  244. ''        RecalcPath
  245.         SetDriveStatus
  246.         GOTO GETPATHL1
  247.     ELSEIF sz$ = "EXIT" THEN
  248.         GOSUB ASKQUIT
  249.         GOTO GETPATHL1
  250.     ELSE
  251.         UIPop 1
  252.         GOTO CHEKPATH
  253.     END IF
  254.  
  255.  
  256.  
  257. TOOBIG:
  258.     sz$ = UIStartDlg(CUIDLL$, TOOBIG, "FInfo0DlgProc", 0, "")
  259.     IF sz$ = "REACTIVATE" THEN
  260.         RecalcPath
  261.         SetDriveStatus
  262.         GOTO TOOBIG
  263.     END IF
  264.     UIPop 1
  265.     RETURN
  266.  
  267.  
  268. BADPATH:
  269.     sz$ = UIStartDlg(CUIDLL$, BADPATH, "FInfo0DlgProc", 0, "")
  270.     IF sz$ = "REACTIVATE" THEN
  271. ''        RecalcPath
  272.         SetDriveStatus
  273.         GOTO BADPATH
  274.     END IF
  275.     UIPop 1
  276.     RETURN
  277.  
  278.  
  279. ASKQUIT:
  280.     sz$ = UIStartDlg(CUIDLL$, ASKQUIT, "FQuitDlgProc", 0, "")
  281.  
  282.     IF sz$ = "EXIT" THEN
  283.         UIPopAll
  284.         ERROR STFQUIT
  285.     ELSEIF sz$ = "REACTIVATE" THEN
  286.         GOTO ASKQUIT
  287.     ELSE
  288.         UIPop 1
  289.     END IF
  290.     RETURN
  291.  
  292.  
  293.  
  294. '**
  295. '** Purpose:
  296. '**     Adds the specified option files to the copy list.
  297. '** Arguments:
  298. '**     ftype%  - type of files to add, one of the following:
  299. '**             APPFILES, HELPFILES, SAMPLES
  300. '** Returns:
  301. '**     none.
  302. '*************************************************************************
  303. SUB AddOptFilesToCopyList (ftype%) STATIC
  304.  
  305.     IF GetListItem(CHECKSTATES$, ftype%) = "ON" THEN
  306.         SrcDir$ = GetSymbolValue("STF_SRCDIR")
  307.         IF ftype% = APPFILES THEN
  308.             AddSectionFilesToCopyList "AppFiles", SrcDir$, DEST$
  309. ''      ELSEIF ftype% = HELPFILES THEN
  310. ''            AddSectionKeyFileToCopyList "OptFiles1", OPT1OPT$, SrcDir$, DEST$
  311. ''          AddSectionFilesToCopyList "HelpFiles", SrcDir$, DEST$
  312.         ELSEIF ftype% = SAMPLES THEN
  313. ''            AddSectionKeyFileToCopyList "OptFiles2", OPT2OPT$, SrcDir$, DEST$
  314.             AddSectionFilesToCopyList "Samples", SrcDir$, DEST$
  315.         END IF
  316.         SrcDir$ = ""
  317.     END IF
  318. END SUB
  319.  
  320.  
  321. '**
  322. '** Purpose:
  323. '**     Recalculates disk space for the given option files and sets
  324. '**     the status info symbol "StatusItemsText".
  325. '** Arguments:
  326. '**     ftype% - type of files to add, one of the following:
  327. '**             APPFILES, HELPFILES, SAMPLES
  328. '** Returns:
  329. '**     none.
  330. '*************************************************************************
  331. SUB RecalcOptFiles (ftype%) STATIC
  332.     CursorSave% = ShowWaitCursor()
  333.     ClearCopyList
  334.     AddOptFilesToCopyList ftype%
  335.  
  336.     fExtra% = 0
  337.     IF ftype% = APPFILES THEN
  338.         ListSym$ = APPNEEDS$
  339.         IF GetListItem(CHECKSTATES$, APPFILES) = "ON" THEN
  340.             ''Add extra cost to Windows drive for ini/progman, etc.
  341.             ndrive% = ASC(ucase$(WINDRIVE$)) - ASC("A") + 1
  342.             ReplaceListItem EXTRACOSTS$, ndrive%, "10240"
  343.             fExtra% = 1
  344.         END IF
  345.     ELSEIF ftype% = HELPFILES THEN
  346.         ListSym$ = HELPNEEDS$
  347.     ELSEIF ftype% = SAMPLES THEN
  348.         ListSym$ = SAMPNEEDS$
  349.     END IF
  350.  
  351.     StillNeed& = GetCopyListCost(EXTRACOSTS$, ListSym$, "")
  352.  
  353.     cost& = 0
  354.     FOR i% = 1 TO 26 STEP 1
  355.         cost&  = cost& + VAL(GetListItem(ListSym$, i%))
  356.     NEXT i%
  357.     ReplaceListItem STATUSTEXT$, ftype%, STR$(cost& / 1024) + " K"
  358.  
  359.     IF StillNeed& > 0 THEN
  360.         ReplaceListItem BIGLIST$, ftype%, "YES"
  361.     ELSE
  362.         ReplaceListItem BIGLIST$, ftype%, ""
  363.     END IF
  364.  
  365.     IF fExtra% THEN
  366.         ReplaceListItem EXTRACOSTS$, ndrive%, "0"
  367.     END IF
  368.     RestoreCursor CursorSave%
  369.     ListSym$ = ""
  370. END SUB
  371.  
  372.  
  373. '**
  374. '** Purpose:
  375. '**     Recalculates disk space and sets option status info according
  376. '**     to the current destination path.
  377. '** Arguments:
  378. '**     none.
  379. '** Returns:
  380. '**     none.
  381. '*************************************************************************
  382. SUB RecalcPath STATIC
  383.  
  384.     CursorSave% = ShowWaitCursor()
  385.  
  386.     RecalcOptFiles APPFILES
  387.     RecalcOptFiles HELPFILES
  388.     RecalcOptFiles SAMPLES
  389.  
  390.     RestoreCursor CursorSave%
  391. END SUB
  392.  
  393.  
  394. '**
  395. '** Purpose:
  396. '**     Sets drive status info according to latest disk space calcs.
  397. '** Arguments:
  398. '**     none.
  399. '** Returns:
  400. '**     none.
  401. '*************************************************************************
  402. SUB SetDriveStatus STATIC
  403.  
  404.     drive$ = MID$(DEST$, 1, 1)
  405.     ndrive% = ASC(ucase$(drive$)) - ASC("A") + 1
  406.     cost& = VAL(GetListItem(APPNEEDS$, ndrive%)) + VAL(GetListItem(HELPNEEDS$, ndrive%)) + VAL(GetListItem(SAMPNEEDS$, ndrive%))
  407.     free& = GetFreeSpaceForDrive(drive$)
  408.     ReplaceListItem DRIVETEXT$, 1, drive$ + ":"
  409.     ReplaceListItem DRIVETEXT$, 2, STR$(cost& / 1024) + " K"
  410.     ReplaceListItem DRIVETEXT$, 3, STR$(free& / 1024) + " K"
  411.  
  412.     IF drive$ = WINDRIVE$ THEN
  413.         ReplaceListItem DRIVETEXT$, 4, ""
  414.         ReplaceListItem DRIVETEXT$, 5, ""
  415.         ReplaceListItem DRIVETEXT$, 6, ""
  416.     ELSE
  417.         ndrive% = ASC(ucase$(WINDRIVE$)) - ASC("A") + 1
  418.         cost& = VAL(GetListItem(APPNEEDS$, ndrive%)) + VAL(GetListItem(HELPNEEDS$, ndrive%)) + VAL(GetListItem(SAMPNEEDS$, ndrive%))
  419.         IF cost& = 0 THEN
  420.             ReplaceListItem DRIVETEXT$, 4, ""
  421.             ReplaceListItem DRIVETEXT$, 5, ""
  422.             ReplaceListItem DRIVETEXT$, 6, ""
  423.         ELSE
  424.             free& = GetFreeSpaceForDrive(WINDRIVE$)
  425.             ReplaceListItem DRIVETEXT$, 4, WINDRIVE$ + ":"
  426.             ReplaceListItem DRIVETEXT$, 5, STR$(cost& / 1024) + " K"
  427.             ReplaceListItem DRIVETEXT$, 6, STR$(free& / 1024) + " K"
  428.         END IF
  429.     END IF
  430. END SUB
  431.  
  432.  
  433. '**
  434. '** Purpose:
  435. '**     Appends a file name to the end of a directory path,
  436. '**     inserting a backslash character as needed.
  437. '** Arguments:
  438. '**     szDir$  - full directory path (with optional ending "\")
  439. '**     szFile$ - filename to append to directory
  440. '** Returns:
  441. '**     Resulting fully qualified path name.
  442. '*************************************************************************
  443. FUNCTION MakePath (szDir$, szFile$) STATIC AS STRING
  444.     IF szDir$ = "" THEN
  445.         MakePath = szFile$
  446.     ELSEIF szFile$ = "" THEN
  447.         MakePath = szDir$
  448.     ELSEIF MID$(szDir$, LEN(szDir$), 1) = "\" THEN
  449.         MakePath = szDir$ + szFile$
  450.     ELSE
  451.         MakePath = szDir$ + "\" + szFile$
  452.     END IF
  453. END FUNCTION
  454.  
  455.