home *** CD-ROM | disk | FTP | other *** search
/ Computer Life 1995 December / Computer Life December 1995.iso / claris / applicat / cw10bv1 / disk1 / clworks.mst < prev    next >
Encoding:
Text File  |  1993-04-24  |  12.7 KB  |  483 lines

  1. '*      Setup script for ClarisWorks Application Installation
  2. '**************************************************************************
  3.  
  4. '$DEFINE DEBUG  ''Define for script development/debugging
  5.  
  6. '$INCLUDE 'setupapi.inc'
  7. '$INCLUDE 'msdetect.inc'
  8.  
  9. ''Dialog ID's
  10. CONST WELCOME       = 100
  11. CONST ASKQUIT       = 200
  12. CONST DESTPATH        = 300
  13. CONST CLARISPATH    = 350
  14. CONST EXITFAILURE   = 400
  15. CONST EXITQUIT      = 600
  16. CONST EXITSUCCESS   = 700
  17. CONST OPTIONS       = 800
  18. CONST APPHELP        = 900
  19. CONST CUSTOM        = 1000
  20. CONST GETNAMEORGNUM = 1100
  21. CONST TOOBIG        = 6300
  22. CONST BADPATH        = 6400
  23.  
  24. ''Bitmap ID
  25. CONST LOGO = 1
  26.  
  27. GLOBAL DEST$            ''Default destination directory.
  28. GLOBAL CDEST$           ''Destination directory.
  29. GLOBAL CHECKIN$         ''Custom install checkboxes initially
  30. GLOBAL CHECKOUT$        ''Custom install checkboxes on termination
  31. GLOBAL CNAME$            ''Customer name
  32. GLOBAL CORG$            ''Customer organization
  33. GLOBAL CSERNUM$         ''Customer serial number
  34. GLOBAL PERS$            ''Personalization string
  35. GLOBAL CSTM%            '' custom install flag
  36. GLOBAL CEXISTS%            '' claris directory already exists
  37. GLOBAL HOWMUCH&            '' space needed in works dir
  38. GLOBAL HOWMUCHC&        '' space needed in claris dir
  39.  
  40. DECLARE SUB Install
  41. DECLARE FUNCTION MakePath (szDir$, szFile$) AS STRING
  42. DECLARE FUNCTION FixSlash (szName$) AS STRING
  43.  
  44.  
  45. INIT:
  46.     CUIDLL$ = "mscuistf.dll"            ''Custom user interface dll
  47.     HELPPROC$ = "FHelpDlgProc"          ''Help dialog procedure
  48.  
  49.     SetBitmap CUIDLL$, LOGO
  50.     SetTitle "ClarisWorks Setup"
  51.  
  52.     szInf$ = GetSymbolValue("STF_SRCINFPATH")
  53.     IF szInf$ = "" THEN
  54.         szInf$ = GetSymbolValue("STF_CWDDIR") + "SETUP.INF"
  55.     END IF
  56.     ReadInfFile szInf$
  57.  
  58. ''    initialize everything that needs it just once
  59.  
  60.     CSTM% = 0
  61.     CNAME$ = ""
  62.     CORG$ = ""
  63.     CSERNUM$ = "See registration card"
  64.     DEST$ = "C:\CLWORKS"
  65.  
  66.     WindowsDir$ = GetWindowsDir()
  67.     ini$ = MakePath(WindowsDir$, "CLARIS.INI")
  68.     CDEST$ = GetIniKeyString( ini$, "Claris", "Claris Directory" )
  69.     IF CDEST$ = "" THEN
  70.        CEXISTS% = 0
  71.        CDEST$ = MakePath(WindowsDir$, "CLARIS")
  72.     ELSE
  73.         CEXISTS% = 1
  74.     END IF
  75.  
  76.     CHECKIN$ = "CheckItemsIn"
  77.     CHECKOUT$ = "CheckItemsOut"
  78.     FOR i% = 1 TO 6 STEP 1
  79.         AddListItem CHECKIN$, "OFF"
  80.     NEXT i%
  81.     FOR i% = 1 TO 6 STEP 1
  82.         AddListItem CHECKOUT$, "OFF"
  83.     NEXT i%
  84.  
  85.  
  86.     i% = SetSizeCheckMode(scmOnIgnore)      '' could use scmOff; def = scmOnFatal
  87.     WinDrive$ = MID$(GetWindowsDir, 1, 1)
  88.     IF IsDriveValid(WinDrive$) = 0 THEN
  89.         i% = DoMsgBox("Windows drive ('"+WinDrive$+"') is not a valid drive.", "DEBUG", MB_TASKMODAL+MB_ICONHAND+MB_OK)
  90.         GOTO QUIT
  91.     END IF
  92.  
  93.  
  94. WELCOME:
  95.     sz$ = UIStartDlg(CUIDLL$, WELCOME, "FInfoDlgProc", APPHELP, HELPPROC$)
  96.     IF sz$ = "EXIT" THEN
  97.         GOSUB ASKQUIT
  98.         GOTO WELCOME
  99.     ELSE
  100.         UIPop 1
  101.         IF sz$ = "CONTINUE" THEN
  102. ''            this is a full install, so set all checkboxes on
  103.             FOR i% = 1 TO 6 STEP 1
  104.                 ReplaceListItem CHECKOUT$, i%, "ON"
  105.             NEXT i%
  106.             GOTO GETNAME
  107.         END IF
  108.     END IF
  109.  
  110.  
  111. CUSTOM:
  112. ''    always set checkin to what is in checkout, as this may be from a BACK
  113.     FOR i% = 1 TO 6 STEP 1
  114.         sz$ = GetListItem(CHECKOUT$, i%)
  115.         ReplaceListItem CHECKIN$, i%, sz$
  116.     NEXT i%
  117.  
  118.     sz$ = UIStartDlg(CUIDLL$, CUSTOM, "FCheckDlgProc", APPHELP, HELPPROC$)
  119.  
  120.     IF sz$ = "CONTINUE" THEN
  121. ''        CHECKOUT$ does not need to be Got here, it is already updated
  122.         UIPop 1
  123.         CSTM% = 1
  124.         GOTO GETNAME
  125.     ELSEIF sz$ = "REACTIVATE" THEN
  126.         GOTO CUSTOM
  127.     ELSEIF sz$ = "BACK" THEN
  128.         UIPop 1
  129.         GOTO WELCOME
  130.     ELSE
  131.         GOSUB ASKQUIT
  132.         GOTO CUSTOM
  133.     END IF
  134.  
  135.  
  136. GETNAME:
  137.     SetSymbolValue "NameIn", CNAME$
  138.     SetSymbolValue "OrgIn", CORG$
  139.     SetSymbolValue "NumIn", CSERNUM$
  140.  
  141. GETNAME1:
  142.     sz$ = UIStartDlg(CUIDLL$, GETNAMEORGNUM, "FNameOrgNumDlgProc", APPHELP, HELPPROC$)
  143.  
  144.     CNAME$ = GetSymbolValue("NameOut")
  145.     CORG$ = GetSymbolValue("OrgOut")
  146.     CSERNUM$ = GetSymbolValue("NumOut")
  147.  
  148.     IF sz$ = "CONTINUE" THEN
  149.         IF CNAME$ = "" THEN
  150.             GOTO GETNAME
  151.         END IF
  152.         UIPop 1
  153.         GOTO GETPATH
  154.     ELSEIF sz$ = "REACTIVATE" THEN
  155.         GOTO GETNAME1
  156.     ELSEIF sz$ = "BACK" THEN
  157.         UIPop 1
  158.         IF CSTM% = 1 THEN
  159.             GOTO CUSTOM
  160.         ELSE
  161.             GOTO WELCOME
  162.         END IF
  163.     ELSE
  164.         GOSUB ASKQUIT
  165.         GOTO GETNAME
  166.     END IF
  167.  
  168.  
  169. GETPATH:
  170. ''    first, calculate how much space is needed for works directory
  171.     HOWMUCH& = 1400000                                '' base amount
  172.     IF GetListItem(CHECKOUT$, 1) = "ON" THEN        '' samples and tutorial
  173.         HOWMUCH& = HOWMUCH& + 300000
  174.     END IF
  175.     IF GetListItem(CHECKOUT$, 2) = "ON" THEN        '' help
  176.         HOWMUCH& = HOWMUCH& + 400000
  177.     END IF
  178.  
  179.     SetSymbolValue "EditTextIn", DEST$
  180.     SetSymbolValue "EditFocus", "END"
  181. GETPATHL1:
  182.     sz$ = UIStartDlg(CUIDLL$, DESTPATH, "FEditDlgProc", APPHELP, HELPPROC$)
  183.     DEST$ = GetSymbolValue("EditTextOut")
  184.  
  185.     IF sz$ = "CONTINUE" THEN
  186.         DEST$ = FixSlash(DEST$)
  187.         IF IsDirWritable(DEST$) = 0 THEN
  188.             GOSUB BADPATH
  189.             GOTO GETPATHL1
  190.         END IF
  191.         UIPop 1
  192.         drive1$ = MID$(DEST$, 1, 1)
  193.         free& = GetFreeSpaceForDrive(drive1$)
  194.         IF free& < HOWMUCH&       THEN
  195.             GOSUB TOOBIG
  196.             GOTO GETPATHL1
  197.         END IF
  198.     ELSEIF sz$ = "REACTIVATE" THEN
  199.         GOTO GETPATHL1
  200.     ELSEIF sz$ = "BACK" THEN
  201.         UIPop 1
  202.         GOTO GETNAME
  203.     ELSE
  204.         GOSUB ASKQUIT
  205.         GOTO GETPATH
  206.     END IF
  207.  
  208.  
  209. GETCPATH:
  210. ''    first, calculate how much space is needed for claris directory
  211.     HOWMUCHC& = 1120000                                '' base amount
  212.     IF GetListItem(CHECKOUT$, 3) = "ON" THEN        '' word processing
  213.         HOWMUCHC& = HOWMUCHC& + 320000
  214.     END IF
  215.     IF GetListItem(CHECKOUT$, 4) = "ON" THEN        '' excel
  216.         HOWMUCHC& = HOWMUCHC& + 110000
  217.     END IF
  218.     IF GetListItem(CHECKOUT$, 5) = "ON" THEN        '' lotus
  219.         HOWMUCHC& = HOWMUCHC& + 120000
  220.     END IF
  221.     IF GetListItem(CHECKOUT$, 6) = "ON" THEN        '' dbf
  222.         HOWMUCHC& = HOWMUCHC& + 60000
  223.     END IF
  224.  
  225.     IF CSTM% = 0 THEN
  226. ''        on full    install, don't put up this dialog, but do check space
  227.         GOTO ISSPACE
  228.     END IF
  229.  
  230.     IF CEXISTS% = 1 THEN
  231. ''        if claris dir exists, don't put up this dialog, but do check space
  232.         GOTO ISSPACE
  233.     END IF
  234.     SetSymbolValue "EditTextIn", CDEST$
  235.     SetSymbolValue "EditFocus", "END"
  236.  
  237. GETCPATHL1:
  238.     sz$ = UIStartDlg(CUIDLL$, CLARISPATH, "FEditDlgProc", APPHELP, HELPPROC$)
  239.  
  240.     CDEST$ = GetSymbolValue("EditTextOut")
  241.  
  242.     IF sz$ = "CONTINUE" THEN
  243.         CDEST$ = FixSlash(CDEST$)
  244.         IF IsDirWritable(CDEST$) = 0 THEN
  245.             GOSUB BADPATH
  246.             GOTO GETCPATHL1
  247.         END IF
  248.         UIPop 1
  249. ISSPACE:
  250.         drive2$ = MID$(CDEST$, 1, 1)
  251.         free& = GetFreeSpaceForDrive(drive2$)
  252.         IF drive2$ = drive1$ THEN
  253.             free& = free& - HOWMUCH&
  254.         END IF
  255.         IF free& < HOWMUCHC& THEN
  256.             GOSUB TOOBIG
  257.             GOTO GETCPATHL1
  258.         END IF
  259.     ELSEIF sz$ = "REACTIVATE" THEN
  260.         GOTO GETCPATHL1
  261.     ELSEIF sz$ = "BACK" THEN
  262.         UIPop 1
  263.         GOTO GETPATH
  264.     ELSE
  265.         GOSUB ASKQUIT
  266.         GOTO GETCPATH
  267.     END IF
  268.  
  269.  
  270. DOIT:
  271.     Install
  272.  
  273.  
  274. QUIT:
  275.     ON ERROR GOTO ERRQUIT
  276.  
  277.     IF ERR = 0 THEN
  278.         dlg% = EXITSUCCESS
  279.     ELSEIF ERR = STFQUIT THEN
  280.         dlg% = EXITQUIT
  281.     ELSE
  282.         dlg% = EXITFAILURE
  283.     END IF
  284. QUITL1:
  285.     sz$ = UIStartDlg(CUIDLL$, dlg%, "FInfo0DlgProc", 0, "")
  286.     IF sz$ = "REACTIVATE" THEN
  287.         GOTO QUITL1
  288.     END IF
  289.     UIPop 1
  290.     i% = ExitExecRestart
  291.     END
  292.  
  293. ERRQUIT:
  294.     i% = DoMsgBox("Setup sources were corrupted, call Claris Technical Support", "Setup Message", MB_OK+MB_TASKMODAL+MB_ICONHAND)
  295.     END
  296.  
  297.  
  298.  
  299. TOOBIG:
  300.     sz$ = UIStartDlg(CUIDLL$, TOOBIG, "FInfo0DlgProc", 0, "")
  301.     IF sz$ = "REACTIVATE" THEN
  302.         GOTO TOOBIG
  303.     END IF
  304.     UIPop 1
  305.     RETURN
  306.  
  307.  
  308.  
  309. BADPATH:
  310.     sz$ = UIStartDlg(CUIDLL$, BADPATH, "FInfo0DlgProc", 0, "")
  311.     IF sz$ = "REACTIVATE" THEN
  312.         GOTO BADPATH
  313.     END IF
  314.     UIPop 1
  315.     RETURN
  316.  
  317.  
  318.  
  319. ASKQUIT:
  320.     sz$ = UIStartDlg(CUIDLL$, ASKQUIT, "FQuitDlgProc", 0, "")
  321.  
  322.     IF sz$ = "EXIT" THEN
  323.         UIPopAll
  324.         ERROR STFQUIT
  325.     ELSEIF sz$ = "REACTIVATE" THEN
  326.         GOTO ASKQUIT
  327.     ELSE
  328.         UIPop 1
  329.     END IF
  330.     RETURN
  331.  
  332.  
  333.  
  334. '**
  335. '** Purpose:
  336. '**     Builds the copy list and performs all installation operations.
  337. '** Arguments:
  338. '**     none.
  339. '** Returns:
  340. '**     none.
  341. '*************************************************************************
  342. SUB Install STATIC
  343.  
  344.     SrcDir$ = GetSymbolValue("STF_SRCDIR")
  345.     CreateDir DEST$, cmoNone
  346.     SampleDir$ = MakePath(DEST$, "SAMPLES\")
  347.     TutorialDir$ = MakePath(DEST$, "TUTORIAL\")
  348.     WindowsDir$ = GetWindowsDir()
  349.     SysDir$ = GetWindowsSysDir()
  350.     ClarisDir$ = CDEST$
  351.     CreateDir ClarisDir$, cmoNone
  352.  
  353.     AddSectionFilesToCopyList "APPLICATION", SrcDir$, DEST$
  354.  
  355.     wmv% = GetWindowsMinorVersion()
  356.     IF wmv% = 0 THEN
  357.         AddSectionKeyFileToCopyList "WINDEP", "FONTMAP30", SrcDir$, DEST$
  358.     ELSE
  359.         AddSectionKeyFileToCopyList "WINDEP", "FONTMAP31", SrcDir$, DEST$
  360.     END IF
  361.  
  362.     IF GetListItem(CHECKOUT$, 1) = "ON" THEN
  363.         CreateDir SampleDir$, cmoNone
  364.         CreateDir TutorialDir$, cmoNone
  365.         AddSectionFilesToCopyList "SAMPLES", SrcDir$, SampleDir$
  366.         AddSectionFilesToCopyList "TUTORIAL", SrcDir$, TutorialDir$
  367.     END IF
  368.  
  369.     IF GetListItem(CHECKOUT$, 2) = "ON" THEN
  370.         AddSectionFilesToCopyList "HELP", SrcDir$, DEST$
  371.     END IF
  372.  
  373.     IF GetListItem(CHECKOUT$, 3) = "ON" THEN
  374.         AddSectionFilesToCopyList "WP", SrcDir$, ClarisDir$
  375.     END IF
  376.  
  377.     IF GetListItem(CHECKOUT$, 4) = "ON" THEN
  378.         AddSectionFilesToCopyList "EXCEL", SrcDir$, ClarisDir$
  379.     END IF
  380.  
  381.     IF GetListItem(CHECKOUT$, 5) = "ON" THEN
  382.         AddSectionFilesToCopyList "LOTUS", SrcDir$, ClarisDir$
  383.     END IF
  384.  
  385.     IF GetListItem(CHECKOUT$, 6) = "ON" THEN
  386.         AddSectionFilesToCopyList "DBF", SrcDir$, ClarisDir$
  387.     END IF
  388.  
  389.     AddSectionFilesToCopyList "CORE", SrcDir$, ClarisDir$
  390.     AddSectionFilesToCopyList "XTND", SrcDir$, ClarisDir$
  391.     AddSpecialFileToCopyList "REDIST", "COMMDLG", SrcDir$, SysDir$+"COMMDLG.DLL"
  392.     AddSpecialFileToCopyList "REDIST", "SHELL", SrcDir$, SysDir$+"SHELL.DLL"
  393.     AddSpecialFileToCopyList "REDIST", "VER", SrcDir$, SysDir$+"VER.DLL"
  394.     AddSpecialFileToCopyList "REDIST", "TOOLHELP", SrcDir$, SysDir$+"TOOLHELP.DLL"
  395.     AddSpecialFileToCopyList "REDIST", "HELPEXE", SrcDir$, WindowsDir$+"WINHELP.EXE"
  396.     AddSpecialFileToCopyList "REDIST", "HELPHLP", SrcDir$, WindowsDir$+"WINHELP.HLP"
  397.     CopyFilesInCopyList
  398.  
  399.     IF ERR <> 0 THEN
  400.         RETURN
  401.     END IF
  402.  
  403. ''    Files are on disk at this point, any more errors are ignored
  404.  
  405.     AddDos5Help "CLWORKS", "An integrated application for word processing, graphics,"+chr$(10)+" spread sheet, and database.", cmoNone
  406.  
  407. ''      Add personalization stuff to CLWORKS.EXE
  408.     PERS$ = CNAME$ + Chr$(0) + CORG$ + Chr$(0) + CSERNUM$ + Chr$(0)
  409.     StampResource "APPLICATION","THEAPP",DEST$,10,15,PERS$,LEN(PERS$)
  410.  
  411.  
  412.     ini$ = MakePath(WindowsDir$, "CLARIS.INI")
  413.     CreateIniKeyValue ini$, "Claris", "Claris Directory", CDEST$, cmoOverwrite
  414.     CreateIniKeyValue ini$, "ClarisWorks", "Offscreen", "0" , cmoNone
  415.     CreateIniKeyValue ini$, "ClarisWorks", "MainDictionary", ClarisDir$ + "\" +"UKENG.NDX", cmoOverwrite
  416.     CreateIniKeyValue ini$, "ClarisWorks", "UserDictionary", ClarisDir$ + "\" + "USERD.SPL", cmoOverwrite
  417.     CreateIniKeyValue ini$, "ClarisWorks", "Thesaurus", ClarisDir$ + "\" + "KTHES.MTH", cmoOverwrite
  418.     CreateIniKeyValue ini$, "ClarisWorks", "Terminal", "TERMINAL.EXE" , cmoNone
  419.     CreateIniKeyValue ini$, "ClarisWorks", "MaxFonts", "22", cmoNone
  420.     CreateIniKeyValue ini$, "ClarisWorks", "FontCount", "0", cmoNone
  421.  
  422.     ini$ = MakePath(WindowsDir$, "WIN.INI")
  423.     CreateIniKeyValue ini$, "Extensions", "cwk", DEST$ + "\CLWORKS.EXE ^.CWK", cmoOverwrite
  424.     CreateIniKeyValue ini$, "Extensions", "cws", DEST$ + "\CLWORKS.EXE ^.CWS" , cmoOverwrite
  425.     CreateIniKeyValue ini$, "Extensions", "mac", DEST$ + "\CLWORKS.EXE ^.MAC" , cmoOverwrite
  426.  
  427.     progrp$ = MakePath(WindowsDir$, "CLWORKS.GRP")
  428.     isthere% = DoesFileExist(progrp$, femExists)
  429.     RemoveFile progrp$, cmoNone
  430.     CreateProgmanGroup "ClarisWorks", progrp$, cmoNone
  431.     ShowProgmanGroup  "ClarisWorks", 1, cmoNone
  432.     AppPath$ = MakePath(DEST$,"CLWORKS.EXE")
  433.     CreateProgmanItem "ClarisWorks", "ClarisWorks", AppPath$, "", cmoOverwrite
  434.     IF isthere% = 0 THEN
  435.         CreateProgmanItem "ClarisWorks", "Read Me", AppPath$+" "+MakePath(DEST$,"readme.cwk"), AppPath$+",1", cmoOverwrite
  436.     ENDIF
  437.  
  438.     ERR = 0
  439.  
  440. END SUB
  441.  
  442.  
  443.  
  444. '**
  445. '** Purpose:
  446. '**     Appends a file name to the end of a directory path,
  447. '**     inserting a backslash character as needed.
  448. '** Arguments:
  449. '**     szDir$  - full directory path (with optional ending "\")
  450. '**     szFile$ - filename to append to directory
  451. '** Returns:
  452. '**     Resulting fully qualified path name.
  453. '*************************************************************************
  454. FUNCTION MakePath (szDir$, szFile$) STATIC AS STRING
  455.     IF szDir$ = "" THEN
  456.         MakePath = szFile$
  457.     ELSEIF szFile$ = "" THEN
  458.         MakePath = szDir$
  459.     ELSEIF MID$(szDir$, LEN(szDir$), 1) = "\" THEN
  460.         MakePath = szDir$ + szFile$
  461.     ELSE
  462.         MakePath = szDir$ + "\" + szFile$
  463.     END IF
  464. END FUNCTION
  465.  
  466.  
  467.  
  468. '**
  469. '** Purpose:
  470. '**     Insert a \ after the drive if there is not one.
  471. '** Arguments:
  472. '**     szName$  - full path name
  473. '** Returns:
  474. '**     Resulting fully qualified path name.
  475. '*************************************************************************
  476. FUNCTION FixSlash (szName$) STATIC AS STRING
  477.     IF MID$(szName$,3,1) = "\" THEN
  478.         FixSlash = szName$
  479.     ELSE
  480.         FixSlash = MID$(szName$,1,2) + "\" + MID$(szName$,3,LEN(szName$))
  481.     END IF
  482. END FUNCTION
  483.