home *** CD-ROM | disk | FTP | other *** search
/ Computer Buyer 1996 February / BUYER_0296.iso / disk1 / myob.ms_ / myob.bin
Text File  |  1995-05-10  |  16KB  |  482 lines

  1. '**************************************************************************
  2. '*                       M.Y.O.B. 5.0 Test Drive Setup Script
  3. '*
  4. '*  Written 05/15/1992 by BMT
  5. '*  Revised 12/27/1994 by KPL
  6. '*
  7. '**************************************************************************
  8.  
  9. ''$DEFINE DEBUG  ''Define for script development/debugging
  10.  
  11. '$INCLUDE 'setupapi.inc'
  12. '$INCLUDE 'msdetect.inc'
  13. ''$INCLUDE 'myob.inc'        '' Routines extracted from setupapi.inc and msdetect.inc
  14.  
  15. DECLARE SUB MaximizeWindow LIB "mscuistf.dll" (hwnd%)
  16. DECLARE SUB AddFilesToCopyList LIB "mscuistf.dll" (Dest$, SectType%)
  17. DECLARE FUNCTION CalcSectionSize LIB "mscuistf.dll" (SectType%) AS LONG
  18. DECLARE SUB DoWinExec LIB "mscuistf.dll" (CmdLine$)
  19.  
  20. ''Default string constants
  21. CONST DEFPATH$      = ":\TESTMYOB"                     ''Default path
  22. CONST DEFGROUP$     = "Best!Ware"                   ''Default group
  23. CONST SETUPTITLE$   = "M.Y.O.B. Test Drive Setup"   ''Title of setup window
  24. CONST ICONNAME$     = "M.Y.O.B. Test Drive"         ''Name of program icon
  25. CONST READMEICON$    = "M.Y.O.B. Read Me"            ''Name of readme icon
  26. CONST APPEXENAME$   = "MYOB.EXE"                    ''Name of executable
  27. CONST READMENAME$    = "README.TXT"                    ''Name of readme text file
  28.  
  29. CONST LETTERSDIR$   = "LETTERS"        ''Sub directory for Personalized Letters
  30.  
  31. ''Miscellaneous numeric constants
  32. CONST WINDRIVECOST  = 1024  '' Extra space needed on Windows drive
  33. CONST SW_SHOWNORMAL = 1        '' Display notepad.exe normally
  34.  
  35. ''Dialog ID's
  36. CONST WELCOME       = 100
  37. CONST ASKQUIT       = 200
  38. CONST DESTPATH      = 300
  39. CONST GROUPNAME     = 350
  40. CONST REGISTER      = 360
  41. CONST EXITFAILURE   = 400
  42. CONST EXITQUIT      = 600
  43. CONST EXITSUCCESS   = 700
  44. CONST APPHELP       = 900
  45. CONST CHECK         = 2500
  46. CONST MODLESS       = 5000
  47. CONST CUSTINST      = 6200
  48. CONST TOOBIG        = 6300
  49. CONST BADPATH       = 6400
  50. CONST README        = 6500
  51.  
  52. ''Bitmap IDs
  53. CONST LOGOPR        = 1
  54. CONST LOGONP        = 2
  55.  
  56. ''File Types
  57. CONST NUMFILETYPES  = 2 '' Number of selectable file types defined below
  58. CONST APPFILES      = 1 '' Application files
  59. CONST LETTERS       = 2 '' Personalized Letters
  60.  
  61.  ''CustInst list symbol names
  62. CONST LISTAPPFILES$ = "ListAppFiles"    ''App. files key list
  63. CONST LISTLETFILES$ = "ListLetFiles"    ''Personalized Letters key list
  64.  
  65. ''Free space calculation symbols
  66. CONST EXTRAS$   = "Extras"  ''List of extra costs to add per drive
  67. CONST COSTS$    = "Costs"   ''Disk space cost for each drive
  68. CONST NEEDEDS$  = "Neededs" ''Disk space needed for each drive
  69.  
  70. ''Section names
  71. CONST SECTAPPFILES$ = "APPFILES"    ''.INF file section for app. files
  72. CONST SECTLETFILES$ = "LETTERS"     ''.INF file section for Letters
  73.  
  74. ''Dialog list symbol names
  75. CONST CHECKSTATES$    = "CheckItemsState"   ''Checkbox state in main dialog
  76. ''CONST CHECKITEMS$     = "CheckItems"        ''Checkbox state in QTW data dialog
  77. CONST STATUSTEXT$     = "StatusItemsText"   ''Disk space requirements display
  78. CONST DRIVETEXT$      = "DriveStatusText"   ''Path display
  79.  
  80. ''Reusable strings
  81. CONST KON$          = "ON"
  82. CONST KOFF$         = "OFF"
  83. CONST ZERO$         = "0"
  84. CONST KEND$         = "END"
  85. CONST CONTINUE$     = "CONTINUE"
  86. CONST REACTIVATE$   = "REACTIVATE"
  87. CONST KEXIT$        = "EXIT"
  88.  
  89. ''Miscellaneous string constants
  90. CONST CUIDLL$         = "mscuistf.dll"      ''Custom user interface dll
  91. CONST HELPPROC$       = "FHelpDlgProc"      ''Help dialog procedure
  92. CONST DIVIDER$        = ", "                ''String dividing data file and description
  93. CONST CENTERMODELESS$ ="CenterMode"         ''Modeless dialog center flag
  94.  
  95. ''Global system strings
  96. GLOBAL gDest$           ''Default destination directory.
  97. GLOBAL gGroup$          ''Default program manager group
  98. GLOBAL gSysDir$         ''Windows system directory (with the backslash)
  99. GLOBAL gWinDir$         ''Windows directory (with the backslash)
  100. GLOBAL gWinDrive$       ''Windows drive letter.
  101. GLOBAL gSrcDir$            ''Installation Source Directory
  102. GLOBAL gReadmeDest$        ''Deafult readme.txt destination
  103.  
  104. '' Miscellanoues
  105. GLOBAL  gWinVer%        ''Version of windows
  106. GLOBAL  gLastDrive%     ''Number (1 to 26) of LASTDRIVE in config.sys
  107. GLOBAL  gAppSize&       ''Application file(s) size in bytes
  108. GLOBAL  gLetSize&       ''Personalized Letters size in bytes
  109.  
  110. DECLARE SUB SetDriveStatus
  111. DECLARE FUNCTION MakePath (sDir$, sFile$) AS STRING
  112.  
  113.  
  114. INIT:   '' Initialization
  115.  
  116.     ''Display maximized window and get Windows version
  117.     hwnd% = HwndFrame()
  118.     MaximizeWindow hwnd%
  119.     SetBitmap CUIDLL$, LOGONP
  120.     SetTitle SETUPTITLE$
  121.     SetCopyGaugePosition -1, 2   '' Centered horizontally, but near top vertically
  122.     gWinVer% = GetWindowsMajorVersion() * 10 + GetWindowsMinorVersion()
  123.     gLastDrive% = WGetConfigLastDrive() - ASC("A") + 1
  124.     IF gLastDrive% < 5 THEN
  125.         gLastDrive% = 26
  126.     END IF
  127.     AddListItem CENTERMODELESS$, "3"    '' Center both horizontally and vertically
  128.     s$ = UIStartDlg(CUIDLL$, REGISTER, "FModelessDlgProc", APPHELP, HELPPROC$)
  129.  
  130.     ''Read the .INF file
  131.     Inf$ = GetSymbolValue("STF_SRCINFPATH")
  132.     IF Inf$ = "" THEN
  133.         Inf$ = GetSymbolValue("STF_CWDDIR") + "SETUP.INF"
  134.     END IF
  135.     ReadInfFile Inf$
  136.     
  137.     ''Get path and group
  138.     gWinDir$     = GetWindowsDir
  139.     gWinDrive$   = MID$(gWinDir$, 1, 1)
  140.     gDest$       = gWinDrive$ + DEFPATH$
  141.     gSysDir$     = GetWindowsSysDir()
  142.     gGroup$      = DEFGROUP$
  143.     gSrcDir$     = GetSymbolValue("STF_SRCDIR")
  144.     
  145.         ''CustInst list symbols
  146.     FOR i% = 1 TO NUMFILETYPES STEP 1
  147.         AddListItem CHECKSTATES$, KON$
  148.     NEXT i%
  149.  
  150.     ''Build permanent key list for applications
  151.     MakeListFromSectionKeys LISTAPPFILES$, SECTAPPFILES$
  152.  
  153.     ''Build permanent key list for Personalized Letters
  154.     MakeListFromSectionKeys LISTLETFILES$, SECTLETFILES$
  155.  
  156.         ''CustInst status text
  157.     FOR i% = 1 TO 2 STEP 1
  158.         AddListItem STATUSTEXT$, ""
  159.     NEXT i%
  160.     FOR i% = 1 TO 11 STEP 1
  161.         AddListItem DRIVETEXT$, ""
  162.     NEXT i%
  163.     ReplaceListItem DRIVETEXT$, 7, gDest$
  164.     ReplaceListItem DRIVETEXT$, 11, gGroup$
  165.  
  166.     ''Initialize disk requirements for applications
  167.     FOR i% = 1 TO gLastDrive% STEP 1
  168.         AddListItem EXTRAS$, ZERO$
  169.         AddListItem COSTS$, ZERO$
  170.         AddListItem NEEDEDS$, ZERO$
  171.     NEXT i%
  172.  
  173.     gAppSize&  = CalcSectionSize(APPFILES)
  174.     gLetSize&  = CalcSectionSize(LETTERS)
  175.     gAppSize&  = gAppSize& + gLetSize&
  176.     SetDriveStatus
  177.     UIPop 1 '' Remove modeless welcome/wait
  178.  
  179.     CUSTINST:   '' Custom installation dialog
  180.     s$ = UIStartDlg(CUIDLL$, CUSTINST, "FCustInstDlgProc", APPHELP, HELPPROC$)
  181.  
  182.     ''"Continue" button
  183.     IF s$ = CONTINUE$ THEN
  184.         ''Install
  185.         GOTO INSTALL
  186.     ''"Path" button.  Change installation path.
  187.     ELSEIF s$ = "PATH" THEN
  188.         GOTO GETPATH
  189.  
  190.     ''"Group" button.  Change Program manager group.
  191.     ELSEIF s$ = "GROUP" THEN
  192.         GOTO GETGROUP
  193.  
  194.     ''Applications checkbox.  Determine new disk requirements.
  195.     ELSEIF s$ = "CHK1" THEN
  196.         SetDriveStatus
  197.         GOTO CUSTINST
  198.  
  199.     ''Redisplay status.
  200.     ELSEIF s$ = REACTIVATE$ THEN
  201.         SetDriveStatus
  202.         GOTO CUSTINST
  203.  
  204.     ''Must be quitting.
  205.     ELSE
  206.         GOSUB ASKQUIT
  207.         GOTO CUSTINST
  208.     END IF
  209.  
  210.  
  211. INSTALL:
  212.     UIPop 1
  213.     ClearCopyList
  214.     IF GetListItem(CHECKSTATES$, APPFILES) = KON$ THEN
  215.         AddSectionFilesToCopyList SECTAPPFILES$, gSrcDir$, gDest$
  216.         AddSectionFilesToCopyList SECTLETFILES$, gSrcDir$, gDest$ + "\" + LETTERSDIR$
  217.     END IF
  218.     IF GetCopyListCost(EXTRAS$, COSTS$, NEEDEDS$) <> 0 THEN
  219.         GOSUB TOOBIG
  220.         GOTO CUSTINST
  221.     END IF
  222.     CD$ = GetSymbolValue("STF_CWDDIR")
  223.     CreateDir gDest$, cmoNone
  224.     SetRestartDir(gDest$)
  225.     ClearBillboardList
  226.     ReplaceListItem CENTERMODELESS$, 1, "5" '' Center horizontally and put at bottom
  227.     AddToBillboardList "MSCUISTF.DLL", WELCOME, "FModelessDlgProc", 50
  228.     AddToBillboardList "MSCUISTF.DLL", MODLESS, "FModelessDlgProc", 50
  229.     CopyFilesInCopyList
  230.     ClearBillboardList
  231.     
  232.     IF GetListItem(CHECKSTATES$, APPFILES) = KON$ AND LEN(gGroup$) <> 0 THEN
  233.         CreateProgmanGroup gGroup$, "", cmoNone
  234.         ShowProgmanGroup  gGroup$, 1, cmoNone
  235.         CreateProgmanItem gGroup$, ICONNAME$, MakePath(gDest$, APPEXENAME$), "", cmoOverwrite
  236.         CreateProgmanItem gGroup$, READMEICON$, MakePath(gDest$, READMENAME$), "", cmoOverwrite
  237.     END IF
  238.  
  239.  
  240. RESTARTWIN:
  241.     IF RestartListEmpty() = 0 THEN
  242.         IF gWinVer% >= 31 THEN
  243.             i% = DoMsgBox("Windows system files need to be updated.  This requires that Windows be shut down.  Press OK to continue or Cancel to abort.", "M.Y.O.B. Setup", MB_OKCANCEL+MB_TASKMODAL+MB_ICONINFORMATION)
  244.             IF i% = IDOK THEN
  245.                 i% = ExitExecRestart()
  246.             ELSEIF i% = IDCANCEL THEN
  247.                 GOSUB ASKQUIT
  248.                 GOTO RESTARTWIN
  249.             END IF
  250.         ELSE
  251.             i% = DoMsgBox("Windows system files need to be updated.  To do this, exit windows and execute the batch file _MSSETUP.BAT located in " + CD$, "M.Y.O.B. Setup", MB_OK+MB_TASKMODAL+MB_ICONINFORMATION)
  252.         END IF
  253.     END IF
  254.  
  255.  
  256. QUIT:
  257.     ON ERROR GOTO ERRQUIT
  258.  
  259.     IF ERR = 0 THEN
  260.         dlg% = EXITSUCCESS
  261.     ELSEIF ERR = STFQUIT THEN
  262.         dlg% = EXITQUIT
  263.     ELSE
  264.         dlg% = EXITFAILURE
  265.     END IF
  266. QUITL1:
  267.     s$ = UIStartDlg(CUIDLL$, dlg%, "FInfo0DlgProc", 0, "")
  268.     IF s$ = REACTIVATE$ THEN
  269.         GOTO QUITL1
  270.     END IF
  271.     UIPop 1
  272.     END
  273.  
  274. ERRQUIT:
  275.     i% = DoMsgBox("Setup sources were corrupted, call M.Y.O.B. customer support.", "Setup Message", MB_OK+MB_TASKMODAL+MB_ICONHAND)
  276.     END
  277.  
  278.  
  279. ''Get user-entered group name
  280. GETGROUP:
  281.     SetSymbolValue "EditTextIn", gGroup$
  282.     SetSymbolValue "EditFocus", KEND$
  283.  
  284. GETGROUPL1:
  285.     s$ = UIStartDlg(CUIDLL$, GROUPNAME, "FEditDlgProc", APPHELP, HELPPROC$)
  286.  
  287.     IF s$ = CONTINUE$ THEN
  288.         gGroup$ = GetSymbolValue("EditTextOut")
  289.         ReplaceListItem DRIVETEXT$, 11, gGroup$
  290.         UIPop 1
  291.         GOTO CUSTINST
  292.     ELSEIF s$ = REACTIVATE$ THEN
  293.         SetDriveStatus
  294.         GOTO GETGROUPL1
  295.     ELSEIF s$ = KEXIT$ THEN
  296.         GOSUB ASKQUIT
  297.         GOTO GETGROUPL1
  298.     ELSE
  299.         UIPop 1
  300.         GOTO CUSTINST
  301.     END IF
  302.  
  303. ''Get user-entered path
  304. GETPATH:
  305.     SetSymbolValue "EditTextIn", gDest$
  306.     SetSymbolValue "EditFocus", KEND$
  307. GETPATHL1:
  308.     s$ = UIStartDlg(CUIDLL$, DESTPATH, "FEditDlgProc", APPHELP, HELPPROC$)
  309.  
  310.     IF s$ = CONTINUE$ THEN
  311.         olddest$ = gDest$
  312.         gDest$ = GetSymbolValue("EditTextOut")
  313.  
  314.         ''Validate new path.
  315.         IF IsDirWritable(gDest$) = 0 THEN
  316.             GOSUB BADPATH
  317.             GOTO GETPATHL1
  318.         END IF
  319.         UIPop 1
  320.  
  321.         ''Truncate display if too long.
  322.         IF LEN(gDest$) > 23 THEN
  323.             ReplaceListItem DRIVETEXT$, 7, MID$(gDest$, 1, 23)+"..."
  324.         ELSE
  325.             ReplaceListItem DRIVETEXT$, 7, gDest$
  326.         END IF
  327.  
  328.         ''Recalc if path changed.
  329.         IF (olddest$ <> gDest$) AND (olddest$ <> gDest$+"\") AND (olddest$+"\" <> gDest$) THEN
  330.             SetDriveStatus
  331.         END IF
  332.  
  333.         olddest$ = ""
  334.         GOTO CUSTINST
  335.     ELSEIF s$ = REACTIVATE$ THEN
  336.         SetDriveStatus
  337.         GOTO GETPATHL1
  338.     ELSEIF s$ = KEXIT$ THEN
  339.         GOSUB ASKQUIT
  340.         GOTO GETPATHL1
  341.     ELSE
  342.         UIPop 1
  343.         GOTO CUSTINST
  344.     END IF
  345.  
  346.  
  347. ''Not enough space dialog
  348. TOOBIG:
  349.     s$ = UIStartDlg(CUIDLL$, TOOBIG, "FInfo0DlgProc", 0, "")
  350.     IF s$ = REACTIVATE$ THEN
  351.         SetDriveStatus
  352.         GOTO TOOBIG
  353.     END IF
  354.     UIPop 1
  355.     RETURN
  356.  
  357.  
  358. ''Bad path dialog
  359. BADPATH:
  360.     s$ = UIStartDlg(CUIDLL$, BADPATH, "FInfo0DlgProc", 0, "")
  361.     IF s$ = REACTIVATE$ THEN
  362.         SetDriveStatus
  363.         GOTO BADPATH
  364.     END IF
  365.     UIPop 1
  366.     RETURN
  367.  
  368.  
  369. ''Quit confirmation dialog
  370. ASKQUIT:
  371.     s$ = UIStartDlg(CUIDLL$, ASKQUIT, "FQuitDlgProc", 0, "")
  372.  
  373.     IF s$ = KEXIT$ THEN
  374.         UIPopAll
  375.         ERROR STFQUIT
  376.     ELSEIF s$ = REACTIVATE$ THEN
  377.         GOTO ASKQUIT
  378.     ELSE
  379.         UIPop 1
  380.     END IF
  381.     RETURN
  382.  
  383.  
  384.  
  385.  
  386. '**
  387. '** Purpose:
  388. '**     Sets drive status info according to latest disk space calcs.
  389. '** Arguments:
  390. '**     none.
  391. '** Returns:
  392. '**     none.
  393. '*************************************************************************
  394. SUB SetDriveStatus STATIC
  395.     CursorSave% = ShowWaitCursor()
  396.  
  397.     drive$ = MID$(gDest$, 1, 1)
  398.     ndrive% = ASC(ucase$(drive$)) - ASC("A") + 1
  399.     nWinDrive% = ASC(ucase$(gWinDrive$)) - ASC("A") + 1
  400.     free& = GetFreeSpaceForDrive(drive$)
  401.     freedrive& = free&
  402.     ReplaceListItem DRIVETEXT$, 1, drive$ + ":"
  403.     ReplaceListItem DRIVETEXT$, 3, STR$(free& / 1024) + " K"
  404.  
  405.     IF GetListItem(CHECKSTATES$, APPFILES) = KON$ THEN
  406.         cost& = gAppSize&
  407.     ELSE
  408.         cost& = 0
  409.     END IF
  410.     ReplaceListItem STATUSTEXT$, APPFILES, STR$(cost& / 1024) + " K"
  411.  
  412.     ClearCopyList
  413.     IF GetListItem(CHECKSTATES$, APPFILES) = KON$ THEN
  414.         AddSectionFilesToCopyList SECTAPPFILES$, gSrcDir$, gDest$
  415.         AddSectionFilesToCopyList SECTLETFILES$, gSrcDir$, gDest$ + "\" + LETTERSDIR$
  416.     END IF
  417.     ReplaceListItem EXTRAS$, nWinDrive%, ZERO$
  418.     l& = GetCopyListCost(EXTRAS$, COSTS$, NEEDEDS$)
  419.     IF GetListItem(CHECKSTATES$, APPFILES) = KON$ THEN
  420.         ''Add extra cost to Windows drive for ini/progman, etc.
  421.         cost& = VAL(GetListItem(EXTRAS$, nWinDrive%))
  422.         IF cost& = 0 THEN
  423.             cost& = WINDRIVECOST
  424.         END IF
  425.         ReplaceListItem EXTRAS$, nWinDrive%, STR$(cost&)
  426.     ELSE
  427.         ReplaceListItem EXTRAS$, nWinDrive%, ZERO$
  428.     END IF
  429.  
  430.     IF ndrive% = nWinDrive% THEN
  431.         ReplaceListItem DRIVETEXT$, 4, ""
  432.         ReplaceListItem DRIVETEXT$, 5, ""
  433.         ReplaceListItem DRIVETEXT$, 6, ""
  434.         nWinDrive% = -1
  435.     ELSE
  436.         cost& = VAL(GetListItem(COSTS$, nWinDrive%)) + VAL(GetListItem(EXTRAS$, nWinDrive%))
  437.         IF cost& = 0 THEN
  438.             ReplaceListItem DRIVETEXT$, 4, ""
  439.             ReplaceListItem DRIVETEXT$, 5, ""
  440.             ReplaceListItem DRIVETEXT$, 6, ""
  441.         ELSE
  442.             free& = GetFreeSpaceForDrive(gWinDrive$)
  443.             ReplaceListItem DRIVETEXT$, 4, gWinDrive$ + ":"
  444.             ReplaceListItem DRIVETEXT$, 5, STR$(cost& / 1024) + " K"
  445.             ReplaceListItem DRIVETEXT$, 6, STR$(free& / 1024) + " K"
  446.         END IF
  447.     END IF
  448.  
  449.     cost& = 0
  450.     FOR i% = 1 to gLastDrive% STEP 1
  451.         IF (i% <> nWinDrive%) THEN
  452.             cost& = cost& + VAL(GetListItem(COSTS$, i%)) + VAL(GetListItem(EXTRAS$, i%))
  453.         END IF
  454.     NEXT i%
  455.     ReplaceListItem DRIVETEXT$, 2, STR$(cost& / 1024) + " K"
  456.     RestoreCursor CursorSave%
  457. END SUB
  458.  
  459.  
  460. '**
  461. '** Purpose:
  462. '**     Appends a file name to the end of a directory path,
  463. '**     inserting a backslash character as needed.
  464. '** Arguments:
  465. '**     sDir$  - full directory path (with optional ending "\")
  466. '**     sFile$ - filename to append to directory
  467. '** Returns:
  468. '**     Resulting fully qualified path name.
  469. '*************************************************************************
  470. FUNCTION MakePath (sDir$, sFile$) STATIC AS STRING
  471.     IF sDir$ = "" THEN
  472.         MakePath = sFile$
  473.     ELSEIF sFile$ = "" THEN
  474.         MakePath = sDir$
  475.     ELSEIF MID$(sDir$, LEN(sDir$), 1) = "\" THEN
  476.         MakePath = sDir$ + sFile$
  477.     ELSE
  478.         MakePath = sDir$ + "\" + sFile$
  479.     END IF
  480. END FUNCTION
  481.  
  482.