home *** CD-ROM | disk | FTP | other *** search
/ PCMania 30 / PCMania CD30.iso / disk1 / e30demo.ms_ / e30demo.ms
Encoding:
Text File  |  1993-10-13  |  26.7 KB  |  1,033 lines

  1. '**************************************************************************
  2. '*                              E30DEMO.MST      : Based on MSSetup Toolkit Sample 2
  3. '**************************************************************************
  4.  
  5. ''$DEFINE DEBUG  ''Define for script development/debugging
  6. '$DEFINE DEMO        '' Define for demo file installation
  7.  
  8. '$INCLUDE 'setupapi.inc'
  9. '$INCLUDE 'msdetect.inc'
  10.  
  11. ''Dialog ID's
  12. CONST WELCOME           = 100
  13. CONST ASKQUIT           = 200
  14. CONST DESTPATH          = 300
  15. CONST EXITFAILURE       = 400
  16. CONST EXITQUIT          = 600
  17. CONST EXITSUCCESS       = 700
  18. CONST OPTIONS           = 800
  19. CONST APPHELP           = 900
  20. CONST TT_WARNING        = 2000
  21. CONST PPDRV_WARNING        = 2200
  22. CONST TYP1_WARNING        = 2100
  23. CONST TT_INSTALLMSG        = 2300
  24. CONST FONTPATH          = 4200
  25. CONST SAMPLELIST        = 5200
  26. CONST CUSTINST          = 6200
  27. CONST TOOBIG            = 6300
  28. CONST BADPATH           = 6400
  29. CONST ALREADYUSED        = 7100
  30. CONST CONFIRMINFO       = 7300
  31. CONST GETNAMEORG        = 7500
  32. CONST BADNAME            = 7700
  33. CONST MR_WELCOME        = 8000
  34. CONST MR_CUSTINST         = 8100
  35.  
  36. ''Bitmap ID
  37. CONST LOGO         = 1
  38.  
  39. ''File Types
  40. CONST PROG_FILES        = 1
  41. CONST DVC_FILES                 = 2
  42. CONST SMPL_FILES                = 3
  43. CONST TT_FILES                  = 4
  44. CONST TYP1_FILES                = 5
  45. CONST PPDRV_FILES                = 6
  46.  
  47. GLOBAL DEST$        ''Default destination directory.
  48. GLOBAL WINDRIVE$    ''Windows drive letter.
  49. GLOBAL WINSYS$          '' Windows System Directory
  50. GLOBAL SMPL_OPT$        '' List of Sample files to install
  51. GLOBAL TYP1_DEST$       '' Destination for Type 1 fonts
  52.  
  53. GLOBAL ALL_SMPL_OPT$    '' All Sample Files
  54.  
  55. ''CustInst list symbol names
  56. GLOBAL PROG_NEEDS$    ''Option list costs per drive
  57. GLOBAL DVC_NEEDS$
  58. GLOBAL SMPL_NEEDS$
  59. GLOBAL TT_NEEDS$                
  60. GLOBAL TYP1_NEEDS$
  61. GLOBAL PPDRV_NEEDS$
  62.  
  63. '' GetNameOrg  list symbol names
  64. GLOBAL NAMEORGIN$
  65. GLOBAL NAMEORGOUT$
  66. GLOBAL CONFIRM$
  67. GLOBAL OrigSerial$
  68. GLOBAL AlreadyInstalled%
  69. GLOBAL ItsAMiracle%
  70.  
  71. GLOBAL EXTRACOSTS$  ''List of extra costs to add per drive
  72. GLOBAL BIGLIST$     ''List of option files cost calc results (boolean)
  73.  
  74. ''Dialog list symbol names
  75. GLOBAL CHECKSTATES$
  76. GLOBAL GREYSTATE$
  77. GLOBAL STATUSTEXT$
  78. GLOBAL DRIVETEXT$
  79.  
  80.  
  81. DECLARE SUB AddOptFilesToCopyList (ftype%)
  82. DECLARE SUB RecalcOptFiles (ftype%)
  83. DECLARE SUB RecalcPath
  84. DECLARE SUB SetDriveStatus
  85. DECLARE FUNCTION MakePath (szDir$, szFile$) AS STRING
  86. DECLARE FUNCTION ValidSerialNo( szSerial$ ) AS INTEGER
  87. DECLARE FUNCTION IsWriteProtected( ) AS INTEGER
  88.  
  89. '' Functions in DLL
  90. DECLARE FUNCTION GetCurrentInfo LIB "mscuistf.dll" ( DoDir% ) AS INTEGER
  91. INIT:
  92.  
  93.     CUIDLL$ = "mscuistf.dll"            ''custom user interface dll
  94.     HELPPROC$ = "FHelpDlgProc"          ''Help dialog procedure
  95.     WINDRIVE$ = MID$(GetWindowsDir, 1, 1)
  96.  
  97.     SetBitmap CUIDLL$, LOGO
  98.  
  99. '$IFDEF DEMO
  100.     DEST$ = WINDRIVE$ + ":\E30DEMO"
  101.     SetTitle "Encore 3.0 Demo Setup"
  102. '$ELSE
  103.     DEST$ = WINDRIVE$ + ":\ENCORE30"
  104.     SetTitle "Encore 3.0 Setup"
  105. '$ENDIF
  106.  
  107.     TYP1_DEST$ = WINDRIVE$ + ":\PSFONTS"
  108.  
  109.     szInf$ = GetSymbolValue("STF_SRCINFPATH")
  110.     IF szInf$ = "" THEN
  111.         szInf$ = GetSymbolValue("STF_CWDDIR") + "E3SETUP.INF"
  112.     END IF
  113.     ReadInfFile szInf$
  114.  
  115.     '' Check if we are installing the miracle drivers...
  116.     IF INSTR( UCASE$( szInf$ ), "MIRACLE.INF" ) THEN
  117.         ItsAMiracle% = 1
  118.     ELSE
  119.         ItsAMiracle% = 0
  120.     END IF
  121.  
  122.     ''CustInst list symbols
  123.     CHECKSTATES$ = "CheckItemsState"
  124.     STATUSTEXT$  = "StatusItemsText"
  125.     DRIVETEXT$   = "DriveStatusText"
  126.  
  127.     FOR i% = 1 TO 6 STEP 1
  128.         AddListItem CHECKSTATES$, "ON"
  129.         AddListItem STATUSTEXT$, ""
  130.     NEXT i%
  131.     '' Initially, don't install Type 1 fonts
  132.     ReplaceListItem CHECKSTATES$, 5, ""
  133.  
  134.     FOR i% = 1 TO 8 STEP 1
  135.         AddListItem DRIVETEXT$, ""
  136.     NEXT i%         
  137.  
  138.     ReplaceListItem DRIVETEXT$, 7, DEST$
  139.     ReplaceListItem DRIVETEXT$, 8, TYP1_DEST$
  140.  
  141.     ''Disk cost list symbols
  142.     PROG_NEEDS$   = "ProgNeeds"
  143.     DVC_NEEDS$      = "DvcNeeds"
  144.     SMPL_NEEDS$     = "SmplNeeds"
  145.     TT_NEEDS$       = "TTNeeds"     
  146.     TYP1_NEEDS$     = "Type1Needs"
  147.     PPDRV_NEEDS$    = "PpDrvNeeds"
  148.  
  149.     EXTRACOSTS$ = "ExtraCosts"
  150.     BIGLIST$    = "BigList"
  151.  
  152.     FOR i% = 1 TO 6 STEP 1
  153.         AddListItem BIGLIST$, ""
  154.     NEXT i%
  155.  
  156.     '' NOTE: This might vary depending on the number of files
  157.     FOR i% = 1 TO 26 STEP 1
  158.         AddListItem EXTRACOSTS$, "0"
  159.     NEXT i%
  160.  
  161.  
  162.     ALL_SMPL_OPT$ = "ListItemsIn"
  163.     SMPL_OPT$ = "ListItemsOut"
  164.     MakeListFromSectionKeys  SMPL_OPT$, "SampleFiles"    '' init to ALL Sample Files
  165.  
  166.     '' Symbols for NameOrg
  167.     NAMEORGIN$ = "NameOrgIn"
  168.     NAMEORGOUT$ = "NameOrgOut"
  169.     CONFIRM$ = "ConfirmTextIn"
  170.     FOR i% = 1 TO 3 STEP 1
  171.         AddListItem NAMEORGIN$, ""
  172.         AddListItem NAMEORGOUT$, ""
  173.         AddListItem CONFIRM$, ""
  174.     NEXT i%
  175.     AddListItem NAMEORGIN$, ""      '' Extra place for disk volume name
  176.     '' The Serial Number Stuff
  177.     OrigSerial$ = ""
  178.     AlreadyInstalled% = 0
  179.  
  180.     RecalcPath
  181.     SetDriveStatus
  182.  
  183. '$IFDEF DEBUG
  184.     i% = SetSizeCheckMode(scmOnIgnore)    '' could use scmOff; def = scmOnFatal
  185. '$ENDIF ''DEBUG
  186.  
  187. WELCOME:
  188. '$IFDEF DEMO
  189.     x% = DoMsgBox( "Welcome to Encore 3.0 Demo Setup!", "Encore 3.0 Demo Setup", 0 )
  190.     GOTO CUSTINST
  191. '$ENDIF
  192.     IF ItsAMiracle% THEN
  193.         sz$ = UIStartDlg( CUIDLL$, MR_WELCOME, "FInfoDlgProc", APPHELP, HELPPROC$ )
  194.     ELSE
  195.         sz$ = UIStartDlg( CUIDLL$, WELCOME, "FInfoDlgProc", APPHELP, HELPPROC$ )
  196.     END IF
  197.     
  198.     IF sz$ = "EXIT" THEN 
  199.         GOSUB ASKQUIT
  200.         GOTO WELCOME
  201.     ELSE
  202.         UIPop 1
  203.     END IF
  204.  
  205. ''-------------------------------------------------------------------------
  206. ''    This section gets and/or verifies user info
  207. ''-------------------------------------------------------------------------
  208.  
  209. GETUSERNAME:
  210.     ReplaceListItem NAMEORGIN$, 4, DEST$ 
  211.     '' Don't ask for the directory date just yet.
  212.     ok% = GetCurrentInfo( 0 )
  213.  
  214. '$IFDEF DEBUG
  215.     x% = DoMsgBox( "GetCurrentInfo() returns: " + STR$(ok%), "DEBUG", 1 )
  216.     norg% =  GetListLength( NAMEORGIN$ )
  217.     x% = DoMsgBox( "NAMEORGIN$ Len: " + STR$(norg%), "DEBUG", 1 )
  218.  
  219.     FOR i% = 1 TO norg% STEP 1
  220.         sz$ = GetListItem( NAMEORGIN$, i% )
  221.         x% = DoMsgBox( "NAMEORGIN$ (" + STR$( i% ) + "): " + sz$, "DEBUG", 1 )
  222.     NEXT i%
  223. '$ENDIF ''DEBUG
  224.  
  225.     OrigName$ = GetListItem( NAMEORGIN$, 1 )
  226.  
  227.     IF ok% <> 1 OR MID$( OrigName$, 48, 11 ) = "Uninstalled" THEN
  228.         ReplaceListItem NAMEORGIN$, 1, ""
  229.         ReplaceListItem NAMEORGIN$, 2, ""
  230.         OrigSerial$ = ""
  231.         AlreadyInstalled% = 0
  232.     ELSE
  233.         OrigSerial$ = GetListItem(NAMEORGIN$, 3)
  234.         AlreadyInstalled% = -1
  235.     END IF
  236.  
  237.     '' Clear out the Serial Number
  238.     ReplaceListItem NAMEORGIN$, 3, ""
  239.  
  240.     OrigName$ = ""
  241.  
  242.     IF AlreadyInstalled THEN
  243.         ReplaceListItem CONFIRM$, 1, GetListItem( NAMEORGIN$, 1 )
  244.         ReplaceListItem CONFIRM$, 2, GetListItem( NAMEORGIN$, 2 )
  245.         sz$ = UIStartDlg( CUIDLL$, ALREADYUSED, "FConfirmDlgProc", APPHELP, HELPPROC$ )
  246.         IF sz$ = "CONTINUE" THEN 
  247.             UIPop 1
  248.         ELSEIF sz$ = "EXIT" THEN
  249.             UIPop 1
  250.             GOSUB ASKQUIT
  251.         END IF
  252.         ReplaceListItem CONFIRM$, 1, ""
  253.         ReplaceListItem CONFIRM$, 2, ""
  254.     END IF
  255.  
  256. GETUSERNAMEL1:
  257.     sz$ = UIStartDlg( CUIDLL$, GETNAMEORG, "FNameOrgDlgProc", APPHELP, HELPPROC$ )
  258.  
  259.     IF sz$ = "CONTINUE" THEN
  260.         FOR i% = 1 TO 2 STEP 1
  261.             ReplaceListItem NAMEORGIN$, i%, GetListItem( NAMEORGOUT$, i% ) 
  262.         NEXT i%
  263.     
  264.         '' User must enter SOMEthing        
  265.         IF GetListItem( NAMEORGOUT$, 1 ) = "" THEN
  266.             sz1$ = UIStartDlg( CUIDLL$, BADNAME, "FInfoDlgProc", 0, "" )
  267.             UIPop 1
  268.             GOTO GETUSERNAMEL1
  269.         END IF
  270.  
  271.         Serial$ = UCASE$( GetListItem( NAMEORGOUT$, 3 ) )
  272.         ReplaceListItem NAMEORGIN$, 3, Serial$
  273.  
  274.         IF ValidSerialNo( Serial$ ) = 0 THEN
  275.             GOSUB BADSERIAL
  276.             GOTO GETUSERNAMEL1
  277.         END IF
  278.  
  279.         UIPop 1
  280.  
  281.     ELSEIF sz$ = "BACK" THEN
  282.         UIPop 1
  283.         GOTO WELCOME
  284.     ELSEIF sz$ = "REACTIVATE" THEN
  285.     GOTO GETUSERNAMEL1
  286.     ELSE
  287.         GOSUB ASKQUIT
  288.         GOTO GETUSERNAMEL1
  289.     END IF
  290.  
  291. '' Check to  see that disk isn't write protected
  292.  
  293.     ON ERROR GOTO WRITEPROTERR
  294.  
  295.     IF IsWriteProtected () THEN
  296.         x% = DoMsgBox( "Please make sure that " + GetSymbolValue( "STF_SRCDIR" ) + " is NOT Write Protected.", "Encore Setup", 16 )
  297.         ON ERROR GOTO QUIT
  298.         GOTO GETUSERNAMEL1
  299.     ELSE
  300.         ON ERROR GOTO QUIT
  301.         GOTO CONFIRMINFO
  302.     END IF
  303.  
  304. WRITEPROTERR:
  305.     RESUME NEXT
  306.     
  307. '' Call confirmation dialog here
  308. CONFIRMINFO:
  309.     FOR i% = 1 TO 2 STEP 1
  310.         ReplaceListItem CONFIRM$, i%, GetListItem( NAMEORGOUT$, i% )
  311.     NEXT i%
  312.     ReplaceListItem CONFIRM$, 3, UCASE$( GetListItem( NAMEORGOUT$, i% ) )
  313.  
  314. CONFIRMINFOL1:
  315.     sz$ = UIStartDlg( CUIDLL$, CONFIRMINFO, "FConfirmDlgProc", APPHELP, HELPPROC$ )
  316.     UIPop 1
  317.     IF sz$ <> "CONTINUE" THEN 
  318.         GOTO GETUSERNAMEL1
  319.     END IF
  320.  
  321.     '' Stamp Resources in CUIDLL for future installations
  322.     szName$ = GetListItem( CONFIRM$, 1 )
  323.     szOrg$ = GetListItem( CONFIRM$, 2 )
  324.     szSerial$ = GetListItem( CONFIRM$, 3 )
  325.     szDat$ = CHR$( LEN(szName$) ) + szName$ + CHR$( LEN(szOrg$) ) + szOrg$ + CHR$( LEN(szSerial$) ) + szSerial$
  326.  
  327. '$IFDEF DEBUG
  328.     x% = DoMsgBox( "NameOrgStamp: " + szDat$, "DEBUG", 1 )
  329. '$ENDIF
  330.  
  331.     SrcDir$ = GetSymbolValue("STF_SRCDIR")
  332.     StampResource "Files", "CUIDLL", SrcDir$, 6, &H471, szDat$, LEN( szDat$ )
  333.     SrcDir$ = ""
  334.     szName$ = ""
  335.     szOrg$ = ""
  336.     szSerial$ = ""
  337.     szDat$ = ""
  338.  
  339. ''-------------------------------------------------------
  340. ''    User install options dialog
  341. CUSTINST:
  342.     IF ItsAMiracle% THEN
  343.         sz$ = UIStartDlg(CUIDLL$, MR_CUSTINST, "FCustInstDlgProc", APPHELP, HELPPROC$)
  344.     ELSE
  345.         sz$ = UIStartDlg(CUIDLL$, CUSTINST, "FCustInstDlgProc", APPHELP, HELPPROC$)
  346.     END IF
  347.  
  348.     IF sz$ = "CONTINUE" THEN
  349.         ''Install only if it will fit.
  350.         FOR i% = 1 TO 6 STEP 1
  351.             IF GetListItem(BIGLIST$, i%) <> "" THEN
  352.                 GOSUB TOOBIG
  353.                 GOTO CUSTINST
  354.             END IF
  355.         NEXT i%
  356.         GOTO INSTALL
  357.     ELSEIF sz$ = "PATH" THEN
  358.         GOTO GETPATH
  359.     ELSEIF sz$ = "CHK1" THEN
  360.         RecalcOptFiles PROG_FILES
  361.         SetDriveStatus
  362.         GOTO CUSTINST
  363.     ELSEIF sz$ = "CHK2" THEN
  364.         RecalcOptFiles DVC_FILES
  365.         SetDriveStatus
  366.         GOTO CUSTINST
  367.     ELSEIF sz$ = "CHK3" THEN
  368.         RecalcOptFiles SMPL_FILES
  369.         SetDriveStatus
  370.         GOTO CUSTINST
  371.     ELSEIF sz$ = "CHK4" THEN
  372.         RecalcOptFiles TT_FILES
  373.         SetDriveStatus
  374.         GOTO CUSTINST
  375.     ELSEIF sz$ = "CHK5" THEN
  376.         RecalcOptFiles TYP1_FILES
  377.         SetDriveStatus
  378.         GOTO CUSTINST
  379.     ELSEIF sz$ = "CHK6" THEN
  380.         RecalcOptFiles PPDRV_FILES
  381.         SetDriveStatus
  382.         GOTO CUSTINST
  383.     ELSEIF sz$ = "BTN1" THEN
  384.         GOTO SAMPLEFILES
  385.     ELSEIF sz$ = "BTN2" THEN
  386.         GOTO TYPE1PATH
  387.     ELSEIF sz$ = "REACTIVATE" THEN
  388.         RecalcPath
  389.         SetDriveStatus
  390.         GOTO CUSTINST
  391.     ELSE
  392.         GOSUB ASKQUIT
  393.         GOTO CUSTINST
  394.     END IF
  395.  
  396.  
  397. '' ---------------------------------------------
  398. '' This is the actual installation 
  399. '' ---------------------------------------------
  400. INSTALL:
  401.  
  402.     '' --------------------------------------------------
  403.     '' Warn user about the TrueType fonts
  404.  
  405.     IF GetListItem( CHECKSTATES$, TT_FILES ) = "ON" THEN
  406.         sz$ = UIStartDlg(CUIDLL$, TT_INSTALLMSG, "FInfoDlgProc", APPHELP, HELPPROC$)
  407.         IF sz$ = "BACK" THEN
  408.             UIPop 1
  409.             GOTO CUSTINST
  410.         ELSEIF sz$ = "EXIT" THEN
  411.             UIPop 1
  412.             GOSUB ASKQUIT
  413.             GOTO CUSTINST
  414.         ELSE
  415.             UIPop 1
  416.         END IF
  417.     ELSE
  418.         sz$ = UIStartDlg(CUIDLL$, TT_WARNING, "FInfoDlgProc", APPHELP, HELPPROC$)
  419.         IF sz$ = "BACK" THEN
  420.             UIPop 1
  421.             GOTO CUSTINST
  422.         ELSEIF sz$ = "EXIT" THEN
  423.             UIPop 1
  424.             GOSUB ASKQUIT
  425.             GOTO CUSTINST
  426.         ELSE
  427.             UIPop 1
  428.         END IF
  429.     END IF
  430.  
  431.     '' -------------------------------------------------------------
  432.     '' Warn about PostScript fonts
  433.  
  434.     IF GetListItem( CHECKSTATES$, TYP1_FILES ) = "ON" THEN
  435.         sz$ = UIStartDlg(CUIDLL$, TYP1_WARNING, "FInfoDlgProc", APPHELP, HELPPROC$)
  436.         IF sz$ = "BACK" THEN
  437.             UIPop 1
  438.             GOTO CUSTINST
  439.         ELSEIF sz$ = "EXIT" THEN
  440.             UIPop 1
  441.             GOSUB ASKQUIT
  442.             GOTO CUSTINST
  443.         ELSE
  444.             UIPop 1
  445.         END IF    
  446.     END IF
  447.  
  448. '' ----------------------------------------------------------------
  449. ''    Warn User regarding Miracles
  450.  
  451.     IF ItsAMiracle% THEN 
  452.         IF GetListItem( CHECKSTATES$, PPDRV_FILES ) = "ON" THEN
  453.             sz$ = UIStartDlg(CUIDLL$, PPDRV_WARNING, "FInfoDlgProc", APPHELP, HELPPROC$)
  454.             IF sz$ = "BACK" THEN
  455.                 UIPop 1
  456.                 GOTO CUSTINST
  457.             ELSEIF sz$ = "EXIT" THEN
  458.                 UIPop 1
  459.                 GOSUB ASKQUIT
  460.                 GOTO CUSTINST
  461.             ELSE
  462.                 UIPop 1
  463.             END IF    
  464.         END IF
  465.     END IF
  466.  
  467.  
  468. '' -----------------------------------------
  469. ''    Ready to go...
  470.     UIPop 1            '' Pop off the CUSTINST dialog
  471.  
  472. '$IFDEF DEBUG
  473.     x% = DoMsgBox( "Files are Copied Here", "DEBUG", 1 )
  474. '$ELSE
  475.     ClearCopyList
  476.     AddOptFilesToCopyList PROG_FILES
  477.     AddOptFilesToCopyList DVC_FILES
  478.     AddOptFilesToCopyList SMPL_FILES
  479.     AddOptFilesToCopyList TT_FILES
  480.     AddOptFilesToCopyList TYP1_FILES
  481.  
  482.     IF ItsAMiracle% THEN 
  483.         AddOptFilesToCopyList PPDRV_FILES
  484.     END IF
  485.  
  486.     CreateDir DEST$, cmoNone
  487.     SetRestartDir DEST$
  488.     CopyFilesInCopyList
  489.     
  490.     
  491. '$ENDIF        '' DEBUG
  492.  
  493. '' ----------------------------------
  494. '' Setup the group and program items 
  495. '' ----------------------------------
  496. '$IFDEF DEMO
  497.     GroupName$ = "Encore 3.0 Demo"
  498.     ProgName$ = "Encore 3.0 Demo"
  499. '$ELSE
  500.     GroupName$ = "Encore 3.0"
  501.     ProgName$ = "Encore 3.0"
  502. '$ENDIF
  503.  
  504.     IF GetListItem(CHECKSTATES$, PROG_FILES) = "ON" THEN
  505.  
  506. '$IFDEF DEBUG
  507.         x% = DoMsgBox( "Program Mgr Group and Files Created Here", "DEBUG", 1 )
  508.         GOTO SAMPLE_ITEMS
  509. '$ENDIF
  510.  
  511.         CreateProgmanGroup GroupName$, "", cmoNone
  512.         ShowProgmanGroup  GroupName$, 1, cmoNone
  513.  
  514. '$IFDEF DEMO
  515.         CreateProgmanItem GroupName$, ProgName$, MakePath(DEST$,"e30demo.exe"), "", cmoOverwrite
  516.         CreateProgmanItem GroupName$, "Read Me", MakePath(DEST$,"readme.txt"), "", cmoOverwrite
  517. '$ELSE
  518.         CreateProgmanItem GroupName$, ProgName$, MakePath(DEST$,"encore30.exe"), "", cmoOverwrite
  519.  
  520.         ReplaceListItem NAMEORGIN$, 4, DEST$
  521.         x% = GetCurrentInfo(1)
  522.  
  523.         szName$ = GetListItem( CONFIRM$, 1 )    '' name
  524.         szOrg$ = GetListItem( CONFIRM$, 2 )     '' company
  525.         szSerial$ = GetListItem( CONFIRM$, 3 )      '' serial no
  526.         szDat$ = CHR$( LEN(szName$) ) + szName$ + CHR$( LEN(szOrg$) ) + szOrg$ + CHR$( LEN(szSerial$) ) + szSerial$
  527.         sz$ = GetListItem( NAMEORGIN$, 4 )      '' date/time of install directory
  528.         szDat$ = szDat$ + CHR$( LEN( sz$ ) ) + sz$
  529.  
  530.         StampResource "ProgFiles", "Encore30", DEST$, 6, &H421, szDat$, LEN( szDat$ )
  531.  
  532.         sz$ = ""                        
  533.         szDat$ = ""
  534.         szName$ = ""    
  535.         szOrg$ = ""
  536.         szSerial$ = ""
  537.  
  538.         CreateProgmanItem GroupName$, "Encore Prefs", MakePath(DEST$, "Encore30.ini"), "", cmoOverwrite
  539.  
  540. '$ENDIF
  541.  
  542.     END IF
  543.  
  544. ''--------------------------------------------------------
  545. SAMPLE_ITEMS:
  546.     IF GetListItem(CHECKSTATES$, SMPL_FILES) = "ON" THEN
  547.  
  548. '$IFDEF DEMO
  549.         SampleDest$ = MakePath( DEST$, "e30demo.exe samples\" )
  550. '$ELSE
  551.         SampleDest$ = MakePath( DEST$, "encore30.exe samples\" )
  552. '$ENDIF
  553.  
  554.         NumSamples% = GetListLength( SMPL_OPT$ )
  555.         IF NumSamples% > 0 THEN
  556.             FOR x% = 1 TO NumSamples%
  557.                 sz$ = GetListItem( SMPL_OPT$, x% )
  558.                 szf$ = GetSectionKeyFilename( "SampleFiles", sz$)
  559.  
  560. '$IFDEF DEBUG
  561.                 y% = DoMsgBox( "MakingItem: " + sz$ + CHR$(13) + CHR$(10) + MakePath(SampleDest$, szf$), "DEBUG", 1 )
  562. '$ELSE
  563.                 IF sz$ = "Beethoven Example Notes" THEN
  564.                     CreateProgmanItem GroupName$, sz$, MakePath( DEST$, "samples\" + szf$), "", cmoOverwrite
  565.                 ELSE
  566.                     CreateProgmanItem GroupName$, sz$, MakePath(SampleDest$, szf$), "", cmoOverwrite
  567.                 END IF
  568. '$ENDIF
  569.  
  570.             NEXT x%
  571.             sz$ = ""
  572.             szf$ = ""
  573.         END IF
  574.         SampleDest$ = ""
  575.     END IF
  576.  
  577. '' -----------------------------------------------------------------------------
  578. ''    Miracle MIDISet program
  579.  
  580.     IF ItsAMiracle% THEN
  581.         IF GetListItem(CHECKSTATES$, PPDRV_FILES) = "ON" THEN
  582.  
  583. '$IFDEF DEBUG
  584.             y% = DoMsgBox( "Adding MIDI Setup Item", "DEBUG", 1 )
  585. '$ELSE
  586.             CreateProgmanItem GroupName$, "MIDI Setup", MakePath(DEST$,"midiset.exe"), "", cmoOverwrite
  587. '$ENDIF
  588.  
  589.         END IF 
  590.     END IF
  591.  
  592. QUIT:
  593.     ON ERROR GOTO ERRQUIT
  594.  
  595.     IF ERR = 0 THEN
  596.         dlg% = EXITSUCCESS
  597.     ELSEIF ERR = STFQUIT THEN
  598.         dlg% = EXITQUIT
  599.     ELSE
  600.         dlg% = EXITFAILURE
  601.     END IF
  602.  
  603. QUITL1:
  604.     sz$ = UIStartDlg(CUIDLL$, dlg%, "FInfo0DlgProc", 0, "")
  605.     IF sz$ = "REACTIVATE" THEN
  606.         GOTO QUITL1
  607.     END IF
  608.     UIPop 1
  609.  
  610.     END
  611.  
  612. ERRQUIT:
  613.     i% = DoMsgBox( "Encore 3.0 Setup Error:" + STR$(ERR) + CHR$(13) + CHR$(10) + ERROR$, "Encore Setup Abort", MB_OK+MB_TASKMODAL+MB_ICONHAND )
  614.     END
  615.  
  616. GETPATH:
  617.     SetSymbolValue "EditTextIn", DEST$
  618.     SetSymbolValue "EditFocus", "END"
  619. GETPATHL1:
  620.     sz$ = UIStartDlg(CUIDLL$, DESTPATH, "FEditDlgProc", APPHELP, HELPPROC$)
  621.  
  622.     IF sz$ = "CONTINUE" THEN
  623.         olddest$ = DEST$
  624.         DEST$ = GetSymbolValue("EditTextOut")
  625.  
  626.         ''Validate new path.  Disallow the root dir.
  627.         IF IsDirWritable(DEST$) = 0 OR (LEN(DEST$) = 3 AND MID$(DEST$, 2, 2 ) = ":\" ) THEN
  628.             GOSUB BADPATH
  629.             GOTO GETPATHL1
  630.         END IF
  631.         UIPop 1
  632.  
  633.         ''Truncate display if too long.
  634.         IF LEN(DEST$) > 23 THEN
  635.             ReplaceListItem DRIVETEXT$, 7, MID$(DEST$, 1, 23)+"..."
  636.         ELSE
  637.             ReplaceListItem DRIVETEXT$, 7, DEST$
  638.         END IF
  639.  
  640.         ''Recalc if path changed.
  641.         IF (olddest$ <> DEST$) AND (olddest$ <> DEST$+"\") AND (olddest$+"\" <> DEST$) THEN
  642.             RecalcPath
  643.             SetDriveStatus
  644.         END IF
  645.  
  646.         olddest$ = ""
  647.         GOTO CUSTINST
  648.     ELSEIF sz$ = "REACTIVATE" THEN
  649.         RecalcPath
  650.         SetDriveStatus
  651.         GOTO GETPATHL1
  652.     ELSEIF sz$ = "EXIT" THEN
  653.         GOSUB ASKQUIT
  654.         GOTO GETPATHL1
  655.     ELSE
  656.         UIPop 1
  657.         GOTO CUSTINST
  658.     END IF
  659.  
  660. '' Set the Path for TYPE1 fonts
  661. TYPE1PATH:
  662.     SetSymbolValue "EditTextIn", TYP1_DEST$
  663.     SetSymbolValue "EditFocus", "END"
  664. TYPE1PATHL1:
  665.     sz$ = UIStartDlg(CUIDLL$, FONTPATH, "FEditDlgProc", APPHELP, HELPPROC$)
  666.  
  667.     IF sz$ = "CONTINUE" THEN
  668.         olddest$ = TYP1_DEST$
  669.         TYP1_DEST$ = GetSymbolValue("EditTextOut")
  670.  
  671.         ''Validate new path. Disallow the root dir.
  672.         IF IsDirWritable(TYP1_DEST$) = 0 OR (LEN(DEST$) = 3 AND MID$(DEST$, 2, 2 ) = ":\" ) THEN
  673.             GOSUB BADPATH
  674.             GOTO TYPE1PATHL1
  675.         END IF
  676.         UIPop 1
  677.  
  678.         ''Truncate display if too long.
  679.         IF LEN(TYP1_DEST$) > 23 THEN
  680.             ReplaceListItem DRIVETEXT$, 8, MID$(TYP1_DEST$, 1, 23)+"..."
  681.         ELSE
  682.             ReplaceListItem DRIVETEXT$, 8, TYP1_DEST$
  683.         END IF
  684.  
  685.         ''Recalc if path changed.
  686.         IF (olddest$ <> TYP1_DEST$) AND (olddest$ <> TYP1_DEST$+"\") AND (olddest$+"\" <> TYP1_DEST$) THEN
  687.             RecalcPath
  688.             SetDriveStatus
  689.         END IF
  690.  
  691.         olddest$ = ""
  692.         GOTO CUSTINST
  693.     ELSEIF sz$ = "REACTIVATE" THEN
  694.         RecalcPath
  695.         SetDriveStatus
  696.         GOTO TYPE1PATHL1
  697.     ELSEIF sz$ = "EXIT" THEN
  698.         GOSUB ASKQUIT
  699.         GOTO TYPE1PATHL1
  700.     ELSE
  701.         UIPop 1
  702.         GOTO CUSTINST
  703.     END IF
  704.  
  705. SAMPLEFILES:
  706.     MakeListFromSectionKeys  ALL_SMPL_OPT$, "SampleFiles"
  707.     oldopt$ = GetSymbolValue( SMPL_OPT$ )
  708. SMPLFILESL1:
  709.     sz$ = UIStartDlg( CUIDLL$, SAMPLELIST, "FMultiDlgProc", APPHELP, HELPPROC$ )
  710.     newopt$ = GetSymbolValue( SMPL_OPT$ ) 
  711.  
  712.     if sz$ = "CONTINUE" THEN
  713.         UIPop 1
  714.         IF newopt$ <> oldopt$ THEN
  715.             RecalcOptFiles SMPL_FILES
  716.             SetDriveStatus
  717.         END IF
  718.         newopt$ = ""
  719.         oldopt$ = ""
  720.         GOTO  CUSTINST
  721.     ELSEIF sz$ = "REACTIVATE" THEN
  722.         RecalcPath
  723.         SetDriveStatus
  724.         GOTO SMPLFILESL1
  725.     ELSEIF sz$ = "EXIT" THEN
  726.         GOSUB ASKQUIT
  727.         GOTO SMPLFILESL1
  728.     ELSE
  729.         UIPop 1
  730.         newopt$ = ""
  731.         oldopt$ = ""
  732.         GOTO CUSTINST
  733.     END IF
  734.  
  735.  
  736. TOOBIG:
  737.     sz$ = UIStartDlg(CUIDLL$, TOOBIG, "FInfo0DlgProc", 0, "")
  738.     IF sz$ = "REACTIVATE" THEN
  739.         RecalcPath
  740.         SetDriveStatus
  741.         GOTO TOOBIG
  742.     END IF
  743.     UIPop 1
  744.     RETURN
  745.  
  746.  
  747.  
  748. BADPATH:
  749.     sz$ = UIStartDlg(CUIDLL$, BADPATH, "FInfo0DlgProc", 0, "")
  750.     IF sz$ = "REACTIVATE" THEN
  751.         RecalcPath
  752.         SetDriveStatus
  753.         GOTO BADPATH
  754.     END IF
  755.         UIPop 1
  756.     RETURN
  757.  
  758. BADSERIAL:
  759.     x% = DoMsgBox( "Incorrect Serial Number.  Please Try Again.", "Encore 3.0 Setup", MB_OK+MB_ICONHAND )
  760.     RETURN
  761.  
  762. ASKQUIT:
  763.     sz$ = UIStartDlg(CUIDLL$, ASKQUIT, "FQuitDlgProc", 0, "")
  764.  
  765.     IF sz$ = "EXIT" THEN
  766.         UIPopAll
  767.         ERROR STFQUIT
  768.     ELSEIF sz$ = "REACTIVATE" THEN
  769.         GOTO ASKQUIT
  770.     ELSE
  771.         UIPop 1
  772.     END IF
  773.  
  774.     RETURN
  775.  
  776. '**
  777. '** Purpose:
  778. '**     Adds the specified option files to the copy list.
  779. '** Arguments:
  780. '**     ftype%  - type of files to add, one of the following:
  781. '**             PROG_FILES, DVC_FILES, etc.
  782. '** Returns:
  783. '**     none.
  784. '*************************************************************************
  785. SUB AddOptFilesToCopyList (ftype%) STATIC
  786.     
  787.     IF GetListItem(CHECKSTATES$, ftype%) = "ON" THEN
  788.         SrcDir$ = GetSymbolValue("STF_SRCDIR")
  789.         IF ftype% = PROG_FILES THEN
  790.             AddSectionFilesToCopyList "ProgFiles", SrcDir$, DEST$
  791.             AddSectionFilesToCopyList "SysFiles", SrcDir$, GetWindowsSysDir
  792.         ELSEIF ftype% = DVC_FILES THEN
  793.             AddSectionFilesToCopyList "DvcFiles", SrcDir$, MakePath( DEST$, "DEVICES" )
  794.         ELSEIF ftype% = SMPL_FILES THEN
  795.             NumSamples% = GetListLength( SMPL_OPT$ )
  796.             IF NumSamples% > 0 THEN
  797.                 FOR x% = 1 TO NumSamples%
  798.                     sz$ = GetListItem( SMPL_OPT$, x% )
  799.                     AddSectionKeyFileToCopyList "SampleFiles", sz$, SrcDir$, MakePath( DEST$, "SAMPLES" )
  800.                 NEXT x%
  801.                 sz$ = ""
  802.             END IF
  803.         ELSEIF ftype% = TT_FILES THEN
  804.             AddSectionFilesToCopyList "TrueTypeFiles", SrcDir$, DEST$
  805.         ELSEIF ftype% = TYP1_FILES THEN
  806.             AddSectionFilesToCopyList "Type1Files", SrcDir$, TYP1_DEST$
  807.         ELSEIF ftype% = PPDRV_FILES THEN
  808.             AddSectionFilesToCopyList "PassportDrivers", SrcDir$, DEST$
  809.         END IF
  810.         
  811.     SrcDir$ = ""
  812.     END IF
  813. END SUB
  814.  
  815.  
  816. '**
  817. '** Purpose:
  818. '**     Recalculates disk space for the given option files and sets
  819. '**     the status info symbol "StatusItemsText".
  820. '** Arguments:
  821. '**     ftype% - type of files to add, one of the following:
  822. '**             PROG_FILES, etc.
  823. '** Returns:
  824. '**     none.
  825. '*************************************************************************
  826. SUB RecalcOptFiles (ftype%) STATIC
  827.  
  828.     CursorSave% = ShowWaitCursor()
  829.     ClearCopyList
  830.     AddOptFilesToCopyList ftype%
  831.  
  832.     fExtra% = 0
  833.     IF ftype% = PROG_FILES THEN
  834.         ListSym$ = PROG_NEEDS$
  835.         IF GetListItem(CHECKSTATES$, PROG_FILES) = "ON" THEN
  836.             ''Add extra cost to Windows drive for ini/progman, etc.
  837.             ndrive% = ASC(ucase$(WINDRIVE$)) - ASC("A") + 1
  838.             ReplaceListItem EXTRACOSTS$, ndrive%, "10240"
  839.             fExtra% = 1
  840.         END IF
  841.     ELSEIF ftype% = DVC_FILES THEN
  842.         ListSym$ = DVC_NEEDS$
  843.     ELSEIF ftype% = SMPL_FILES THEN
  844.         ListSym$ = SMPL_NEEDS$
  845.     ELSEIF ftype% = TT_FILES THEN
  846.         ListSym$ = TT_NEEDS$
  847.     ELSEIF ftype% = TYP1_FILES THEN
  848.         ListSym$ = TYP1_NEEDS$
  849.     ELSEIF ftype% = PPDRV_FILES THEN
  850.         ListSym$ = PPDRV_NEEDS$
  851.     END IF
  852.  
  853.     StillNeed& = GetCopyListCost(EXTRACOSTS$, ListSym$, "")
  854.  
  855.     cost& = 0
  856.     FOR i% = 1 TO 26 STEP 1
  857.         cost&  = cost& + VAL(GetListItem(ListSym$, i%))
  858.     NEXT i%
  859.  
  860.     ReplaceListItem STATUSTEXT$, ftype%, STR$(cost& / 1024) + " K"
  861.  
  862.     IF StillNeed& > 0 THEN
  863.         ReplaceListItem BIGLIST$, ftype%, "YES"
  864.     ELSE
  865.         ReplaceListItem BIGLIST$, ftype%, ""
  866.     END IF
  867.  
  868.     IF fExtra% THEN
  869.         ReplaceListItem EXTRACOSTS$, ndrive%, "0"
  870.     END IF
  871.     RestoreCursor CursorSave%
  872.     ListSym$ = ""
  873. END SUB
  874.  
  875.  
  876. '**
  877. '** Purpose:
  878. '**     Recalculates disk space and sets option status info according
  879. '**     to the current destination path.
  880. '** Arguments:
  881. '**     none.
  882. '** Returns:
  883. '**     none.
  884. '*************************************************************************
  885. SUB RecalcPath STATIC
  886.  
  887.     CursorSave% = ShowWaitCursor()
  888.  
  889.     RecalcOptFiles PROG_FILES
  890.     RecalcOptFiles DVC_FILES
  891.     RecalcOptFiles SMPL_FILES
  892.     RecalcOptFiles TT_FILES
  893.     RecalcOptFiles TYP1_FILES
  894.  
  895.     IF ItsAMiracle% THEN
  896.         RecalcOptFiles PPDRV_FILES
  897.     END IF
  898.  
  899.     RestoreCursor CursorSave%
  900. END SUB
  901.  
  902.  
  903. '**
  904. '** Purpose:
  905. '**     Sets drive status info according to latest disk space calcs.
  906. '** Arguments:
  907. '**     none.
  908. '** Returns:
  909. '**     none.
  910. '*************************************************************************
  911. SUB SetDriveStatus STATIC
  912.  
  913.     drive$ = MID$(DEST$, 1, 1)
  914.     ndrive% = ASC(ucase$(drive$)) - ASC("A") + 1
  915.  
  916.     cost& = VAL(GetListItem(PROG_NEEDS$, ndrive%)) + VAL(GetListItem(DVC_NEEDS$, ndrive%)) + VAL(GetListItem(SMPL_NEEDS$, ndrive%))
  917.     cost& = cost& + VAL(GetListItem(TT_NEEDS$, ndrive%))  + VAL(GetListItem(TYP1_NEEDS$, ndrive%))
  918.  
  919.     IF ItsAMiracle% THEN
  920.         cost& = cost& + VAL(GetListItem(PPDRV_NEEDS$, ndrive%))
  921.     END IF
  922.  
  923.     free& = GetFreeSpaceForDrive(drive$)
  924.     ReplaceListItem DRIVETEXT$, 1, drive$ + ":"
  925.     ReplaceListItem DRIVETEXT$, 2, STR$(cost& / 1024) + " K"
  926.     ReplaceListItem DRIVETEXT$, 3, STR$(free& / 1024) + " K"
  927.  
  928.     IF drive$ = WINDRIVE$ THEN
  929.         ReplaceListItem DRIVETEXT$, 4, ""
  930.         ReplaceListItem DRIVETEXT$, 5, ""
  931.         ReplaceListItem DRIVETEXT$, 6, ""
  932.     ELSE
  933.         ndrive% = ASC(ucase$(WINDRIVE$)) - ASC("A") + 1
  934.  
  935.         cost& = VAL(GetListItem(PROG_NEEDS$, ndrive%)) + VAL(GetListItem(DVC_NEEDS$, ndrive%)) + VAL(GetListItem(SMPL_NEEDS$, ndrive%))
  936.         cost& = cost& + VAL(GetListItem(TT_NEEDS$, ndrive%)) + VAL(GetListItem(TYP1_NEEDS$, ndrive%))
  937.  
  938.         IF ItsAMiracle% THEN
  939.             cost& = cost& + VAL(GetListItem(PPDRV_NEEDS$, ndrive%))
  940.         END IF
  941.  
  942.         IF cost& = 0 THEN
  943.             ReplaceListItem DRIVETEXT$, 4, ""
  944.             ReplaceListItem DRIVETEXT$, 5, ""
  945.             ReplaceListItem DRIVETEXT$, 6, ""
  946.         ELSE
  947.             free& = GetFreeSpaceForDrive(WINDRIVE$)
  948.             ReplaceListItem DRIVETEXT$, 4, WINDRIVE$ + ":"
  949.             ReplaceListItem DRIVETEXT$, 5, STR$(cost& / 1024) + " K"
  950.             ReplaceListItem DRIVETEXT$, 6, STR$(free& / 1024) + " K"
  951.         END IF
  952.  
  953. '$IFDEF DEBUG
  954.     y% = DoMsgBox( "Windrive Cost: " + str$( cost& ), "DEBUG", 1 )
  955. '$ENDIF
  956.  
  957.     END IF
  958. END SUB
  959.  
  960.  
  961. '**
  962. '** Purpose:
  963. '**     Appends a file name to the end of a directory path,
  964. '**     inserting a backslash character as needed.
  965. '** Arguments:
  966. '**     szDir$  - full directory path (with optional ending "\")
  967. '**     szFile$ - filename to append to directory
  968. '** Returns:
  969. '**     Resulting fully qualified path name.
  970. '*************************************************************************
  971. FUNCTION MakePath (szDir$, szFile$) STATIC AS STRING
  972.     IF szDir$ = "" THEN
  973.     MakePath = szFile$
  974.     ELSEIF szFile$ = "" THEN
  975.     MakePath = szDir$
  976.     ELSEIF MID$(szDir$, LEN(szDir$), 1) = "\" THEN
  977.     MakePath = szDir$ + szFile$
  978.     ELSE
  979.     MakePath = szDir$ + "\" + szFile$
  980.     END IF
  981. END FUNCTION
  982.  
  983. '**
  984. '** Purpose:
  985. '**     Validate a serial number
  986. '** Arguments:
  987. '**     szSerial$  - The number to validate
  988. '** Returns:
  989. '**     -1 if OK, 0 if invalid
  990. '*************************************************************************
  991. FUNCTION ValidSerialNo( szSerial$ ) STATIC AS INTEGER
  992.  
  993.     ValidSerialNo = -1      '' Assume it's OK
  994.     IF AlreadyInstalled% AND szSerial$ <> OrigSerial$ THEN
  995.         ValidSerialNo = 0
  996.     ELSEIF LEN( szSerial$ ) <> 17  OR  MID$( szSerial$, 1 , 5 ) <> "EV30-" OR MID$( szSerial$, 7 , 7 ) <> "-02032-" THEN
  997.         ValidSerialNo = 0
  998.     END IF
  999.  
  1000. END FUNCTION
  1001.  
  1002. '**
  1003. '** Purpose:
  1004. '**     Check Write Protection Status of Source Drive
  1005. '** Arguments:
  1006. '**     szPath$  - The source path
  1007. '** Returns:
  1008. '**     -1 if WriteProtected, 0 if not
  1009. '*************************************************************************
  1010. FUNCTION IsWriteProtected(  ) STATIC AS INTEGER
  1011.  
  1012.     IsWriteProtected = 0        '' Assume OK
  1013.  
  1014. '$IFDEF DEBUG
  1015.     szCheckPath$ = "B:\XXX.TST"
  1016. '$ELSE
  1017.     szCheckPath$ = MakePath( GetSymbolValue( "STF_SRCDIR" ), "XXX.TST" )
  1018. '$ENDIF
  1019.  
  1020.     ERR = 0
  1021.     OPEN szCheckPath$ FOR OUTPUT AS #1
  1022.     
  1023.     IF ERR THEN 
  1024.         IsWriteProtected = -1
  1025.     ELSE
  1026.         CLOSE #1
  1027.         KILL szCheckPath$
  1028.     END IF
  1029.     ERR = 0
  1030.  
  1031. END FUNCTION
  1032.  
  1033.