home *** CD-ROM | disk | FTP | other *** search
/ PC World 1998 October / PCWorld_1998-10_cd.bin / software / prehled / zoner / CONTEXT / DISK1 / CONTEXT.MS_ / CONTEXT.MS
Text File  |  1998-06-16  |  13KB  |  513 lines

  1.  
  2. '$DEFINE DEBUG  ''Define for script development/debugging
  3.  
  4. '$INCLUDE 'setupapi.inc'
  5. '$INCLUDE 'msdetect.inc'
  6.  
  7. ''Dialog ID's
  8. CONST ASKQUIT      = 200
  9. CONST DESTPATH     = 300
  10. CONST EXITFAILURE  = 400
  11. CONST EXITQUIT     = 600
  12. CONST EXITSUCCESS  = 700
  13. CONST APPHELP      = 900
  14. CONST CUSTINST     = 6200
  15. CONST TOOBIG       = 6300
  16. CONST BADPATH      = 6400
  17. CONST PASSWORDID   = 4571
  18. CONST NODLGEXIT    = 800
  19.  
  20. ''Bitmap ID
  21. CONST LOGO         = 1
  22.  
  23. ''File Types
  24. CONST APPFILES     = 1
  25. CONST ARCHIVFILES  = 2
  26. CONST SAMPLEFILES  = 3
  27.  
  28. GLOBAL DEST$        ''Default destination directory.
  29. GLOBAL USERNAME$
  30. GLOBAL USERORG$
  31. GLOBAL SAMPLEDIR$      ''Adresar SAMPLE
  32. GLOBAL WINDRIVE$    ''Windows drive letter.
  33. GLOBAL WINSYSDIR$
  34. GLOBAL IconStr$
  35. GLOBAL TESTD
  36.  
  37. ''CustInst list symbol names
  38. GLOBAL APPNEEDS$    ''Option list costs per drive
  39. GLOBAL SAMPLENEEDS$
  40. GLOBAL ARCHIVNEEDS$
  41. GLOBAL EXTRACOSTS$  ''List of extra costs to add per drive
  42. GLOBAL BIGLIST$     ''List of option files cost calc results (boolean)
  43.  
  44. ''Dialog list symbol names
  45. GLOBAL CHECKSTATES$
  46. GLOBAL STATUSTEXT$
  47. GLOBAL DRIVETEXT$
  48.  
  49.  
  50. DECLARE SUB AddOptFilesToCopyList (ftype%)
  51. DECLARE SUB AddZBLZVLFilesToCopyList
  52. DECLARE SUB RecalcOptFiles (ftype%)
  53. DECLARE SUB RecalcPath
  54. DECLARE SUB SetDriveStatus
  55. DECLARE SUB WriteSetupKeyIntoApp LIB "ctxstpui.dll" (lpTargetDir$,lpUserName$,lpUserOrg$)
  56. DECLARE FUNCTION TestDemo LIB "ctxstpui.dll" (lpTargetDir$) AS INTEGER
  57. DECLARE FUNCTION MakePath (szDir$, szFile$) AS STRING
  58.  
  59.  
  60.  
  61. INIT:
  62.      CUIDLL$ = "ctxstpui.dll"            ''custom user interface dll
  63.      HELPPROC$ = "UIHelpDialog"          ''Help dialog procedure
  64.  
  65.      SetBitmap CUIDLL$, LOGO
  66.      SetTitle "Zoner Context 3.0 - ZkuÜebnφ verze"
  67.  
  68.      szInf$ = GetSymbolValue("STF_SRCINFPATH")
  69.      IF szInf$ = "" THEN
  70.           szInf$ = GetSymbolValue("STF_CWDDIR") + "CONTEXT.INF"
  71.      END IF
  72.      ReadInfFile szInf$
  73.  
  74.      WINDRIVE$ = MID$(GetWindowsDir, 1, 1)
  75.      DEST$ = WINDRIVE$ + ":\CONTEXT3"
  76.  
  77.      WINSYSDIR$ = GetWindowsSysDir
  78.     GOSUB GENSUBDIRS
  79.  
  80.      ''CustInst list symbols
  81.      CHECKSTATES$ = "CheckItemsState"
  82.      STATUSTEXT$  = "StatusItemsText"
  83.      DRIVETEXT$   = "DriveStatusText"
  84.     FOR i% = 1 TO 3 STEP 1
  85.           AddListItem CHECKSTATES$, "ON"
  86.     NEXT i%
  87.      FOR i% = 1 TO 3 STEP 1
  88.         AddListItem STATUSTEXT$, ""
  89.     NEXT i%
  90.      FOR i% = 1 TO 7 STEP 1
  91.           AddListItem DRIVETEXT$, ""
  92.      NEXT i%
  93.      ReplaceListItem DRIVETEXT$, 7, DEST$
  94.  
  95.      ''Disk cost list symbols
  96.      APPNEEDS$   = "AppNeeds"
  97.      SAMPLENEEDS$  = "SampleNeeds"
  98.      EXTRACOSTS$ = "ExtraCosts"
  99.      BIGLIST$    = "BigList"
  100.      FOR i% = 1 TO 3 STEP 1
  101.           AddListItem BIGLIST$, ""
  102.      NEXT i%
  103.      FOR i% = 1 TO 26 STEP 1
  104.           AddListItem EXTRACOSTS$, "0"
  105.      NEXT i%
  106.  
  107.      RecalcPath
  108.      SetDriveStatus
  109.  
  110. '$IFDEF DEBUG
  111.      i% = SetSizeCheckMode(scmOnIgnore)    '' could use scmOff; def = scmOnFatal
  112. '$ENDIF ''DEBUG
  113.  
  114.  
  115.      TESTD = TestDemo(DEST$)
  116.      IF TESTD = 0 THEN
  117.         UIPopAll
  118.         ERROR NODLGEXIT
  119.          RETURN    
  120.      ENDIF
  121.  
  122. CUSTINST:
  123.      sz$ = UIStartDlg(CUIDLL$, CUSTINST, "ContextSetupDlg", APPHELP, HELPPROC$)
  124.  
  125.      IF sz$ = "CONTINUE" THEN
  126.           ''Install only if it will fit.
  127.           FOR i% = 1 TO 3 STEP 1
  128.                 IF GetListItem(BIGLIST$, i%) <> "" THEN
  129.                      GOSUB TOOBIG
  130.                      GOTO CUSTINST
  131.                 END IF
  132.           NEXT i%
  133.           UIPop 1
  134.           GOTO INSTALL
  135.      ELSEIF sz$ = "PATH" THEN
  136.           GOTO GETPATH
  137.      ELSEIF sz$ = "CHK1" THEN
  138.           RecalcPath
  139.           SetDriveStatus
  140.           GOTO CUSTINST
  141.      ELSEIF sz$ = "CHK2" THEN
  142.           RecalcPath
  143.           SetDriveStatus
  144.           GOTO CUSTINST
  145.      ELSEIF sz$ = "CHK3" THEN
  146.           RecalcPath
  147.           SetDriveStatus          
  148.         GOTO CUSTINST
  149.     ELSEIF sz$ = "REACTIVATE" THEN
  150.         RecalcPath
  151.     SetDriveStatus
  152.           GOTO CUSTINST
  153.      ELSE
  154.           GOSUB ASKQUIT
  155.           GOTO CUSTINST
  156.      END IF
  157.  
  158.  
  159.  
  160. INSTALL:
  161.      SetSymbolValue "UserNameTextIn", USERNAME$
  162.      SetSymbolValue "UserOrgTextIn", USERORG$
  163.      SetSymbolValue "PasswordFocus", "END"
  164. GETPASSWORDL1:
  165.      sz$ = UIStartDlg(CUIDLL$, PASSWORDID, "FPasswordDlgProc", APPHELP, HELPPROC$)
  166.  
  167.      IF sz$ = "CONTINUE" THEN
  168.           USERNAME$ = GetSymbolValue("UserNameTextOut")
  169.           USERORG$ = GetSymbolValue("UserOrgTextOut")
  170.           UIPop 1
  171.  
  172.           GOTO FINALINSTALL
  173.      ELSEIF sz$ = "REACTIVATE" THEN
  174.           GOTO GETPASSWORDL1
  175.      ELSEIF sz$ = "EXIT" THEN
  176.           GOSUB ASKQUIT
  177.           GOTO GETPASSWORDL1
  178.      ELSE
  179.           UIPop 1
  180.           GOTO GETPASSWORDL1
  181.      END IF
  182.  
  183. FINALINSTALL:
  184.  
  185.      ClearCopyList
  186.      AddOptFilesToCopyList APPFILES
  187.      AddOptFilesToCopyList SAMPLEFILES
  188.             AddZBLZVLFilesToCopyList
  189.  
  190.      SetRestartDir DEST$
  191.      IF (GetListItem(CHECKSTATES$, APPFILES) = "ON") THEN
  192.       CreateDir DEST$, cmoNone
  193.      END IF
  194.  
  195.      IF GetListItem(CHECKSTATES$, SAMPLEFILES) = "ON" THEN
  196.       CreateDir SAMPLEDIR$, cmoNone
  197.          END IF
  198.  
  199.      CopyFilesInCopyList
  200.  
  201.      IF (GetListItem(CHECKSTATES$, APPFILES) = "ON") OR (GetListItem(CHECKSTATES$, ARCHIVFILES) = "ON") THEN
  202.           CreateProgmanGroup "Zoner Context 3.0", "", cmoNone
  203.           ShowProgmanGroup  "Zoner Context 3.0", 1, cmoNone
  204.      END IF
  205.  
  206.      IF GetListItem(CHECKSTATES$, APPFILES) = "ON" THEN
  207.           CreateProgmanItem "Zoner Context 3.0", "Zoner Context", MakePath(DEST$,"context.exe"), "", cmoOverwrite
  208.           CreateProgmanItem "Zoner Context 3.0", "Zoner Context Editor", MakePath(DEST$,"contedit.exe"), "", cmoOverwrite
  209.           CreateProgmanItem "Zoner Context 3.0", "Zoner Context Compiler", MakePath(DEST$,"ctxcomp.exe"), "", cmoOverwrite
  210.      END IF
  211.  
  212.      IF GetListItem(CHECKSTATES$, SAMPLEFILES) = "ON" THEN
  213.           IconStr$=MakePath(DEST$,"context.exe")+",1"
  214.           CreateProgmanItem "Zoner Context 3.0", "Prezentace ZONER software", MakePath(DEST$,"context.exe") + " " + MakePath(SAMPLEDIR$,"zon-demo.ctx"), IconStr$, cmoOverwrite
  215.      END IF
  216.  
  217.     WriteSetupKeyIntoApp DEST$,USERNAME$,USERORG$ 
  218.  
  219.  
  220. QUIT:
  221.      ON ERROR GOTO ERRQUIT
  222.  
  223.      IF ERR = NODLGEXIT THEN
  224.        GOTO NODLGQUIT
  225.      ENDIF
  226.  
  227.      IF ERR = 0 THEN
  228.           dlg% = EXITSUCCESS
  229.      ELSEIF ERR = STFQUIT THEN
  230.           dlg% = EXITQUIT
  231.      ELSEIF ERR = NODLGEXIT THEN
  232.           dlg% = 0
  233.      ELSE
  234.           dlg% = EXITFAILURE
  235.      END IF
  236. QUITL1:
  237.      sz$ = UIStartDlg(CUIDLL$, dlg%, "FInfo0DlgProc", 0, "")
  238.      IF sz$ = "REACTIVATE" THEN
  239.           GOTO QUITL1
  240.      END IF
  241.      UIPop 1
  242.  
  243.      IF dlg%=EXITSUCCESS THEN
  244.       IF RestartListEmpty() = 0 THEN
  245.         i% = DoMsgBox("Instalßtor musφ nynφ restartovat Windows. Uzav°ete prosφm vÜechny ostatnφ aplikace a stiskn∞te tlaΦφtko OK.", "Zprßva instalßtoru", MB_OK+MB_ICONINFORMATION)
  246.       AGAINEX:
  247.         IF ExitExecRestart()=0 THEN
  248.         i% = DoMsgBox("Restartovßnφ Windows selhalo. Uzav°ete vÜechny aplikace pro MS-DOS a stiskn∞te tlaΦφtko OK.", "Zprßva instalßtoru", MB_OK+MB_ICONINFORMATION)
  249.         GOTO AGAINEX
  250.         END IF
  251.       END IF
  252.      END IF
  253.  
  254.      END
  255.  
  256. ERRQUIT:
  257.      i% = DoMsgBox("ZdrojovΘ soubory Setupu jsou poÜkozeny!", "Zprßva instalßtoru", MB_OK+MB_TASKMODAL+MB_ICONHAND)
  258.      END
  259. NODLGQUIT:
  260.      END
  261.  
  262.  
  263. GETPATH:
  264.      SetSymbolValue "EditTextIn", DEST$
  265.      SetSymbolValue "EditFocus", "END"
  266. GETPATHL1:
  267.      sz$ = UIStartDlg(CUIDLL$, DESTPATH, "FEditDlgProc", APPHELP, HELPPROC$)
  268.  
  269.      IF sz$ = "CONTINUE" THEN
  270.           olddest$ = DEST$
  271.           DEST$ = GetSymbolValue("EditTextOut")
  272.  
  273.           ''Validate new path.
  274.           IF IsDirWritable(DEST$) = 0 THEN
  275.                 GOSUB BADPATH
  276.                 GOTO GETPATHL1
  277.           END IF
  278.           UIPop 1
  279.  
  280.           ''Truncate display if too long.
  281.           IF LEN(DEST$) > 23 THEN
  282.                 ReplaceListItem DRIVETEXT$, 7, MID$(DEST$, 1, 23)+"..."
  283.           ELSE
  284.                 ReplaceListItem DRIVETEXT$, 7, DEST$
  285.           END IF
  286.  
  287.           ''Recalc if path changed.
  288.           IF (olddest$ <> DEST$) AND (olddest$ <> DEST$+"\") AND (olddest$+"\" <> DEST$) THEN
  289.                 GOSUB GENSUBDIRS
  290.                 RecalcPath
  291.                 SetDriveStatus
  292.           END IF
  293.  
  294.           olddest$ = ""
  295.           GOTO CUSTINST
  296.      ELSEIF sz$ = "REACTIVATE" THEN
  297.           GOSUB GENSUBDIRS
  298.           RecalcPath
  299.           SetDriveStatus
  300.           GOTO GETPATHL1
  301.      ELSEIF sz$ = "EXIT" THEN
  302.           GOSUB ASKQUIT
  303.           GOTO GETPATHL1
  304.      ELSE
  305.           UIPop 1
  306.           GOTO CUSTINST
  307.      END IF
  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. GENSUBDIRS:
  321.  
  322.      IF MID$(DEST$,LEN(DEST$),1) = "\" THEN
  323.       SAMPLEDIR$ = DEST$ + "SAMPLES"
  324.      ELSE
  325.       SAMPLEDIR$ = DEST$ + "\SAMPLES"
  326.      END IF
  327.      RETURN
  328.  
  329. BADPATH:
  330.      sz$ = UIStartDlg(CUIDLL$, BADPATH, "FInfo0DlgProc", 0, "")
  331.      IF sz$ = "REACTIVATE" THEN
  332.           RecalcPath
  333.           SetDriveStatus
  334.           GOTO BADPATH
  335.      END IF
  336.      UIPop 1
  337.      RETURN
  338.  
  339.  
  340.  
  341. ASKQUIT:
  342.      sz$ = UIStartDlg(CUIDLL$, ASKQUIT, "FQuitDlgProc", 0, "")
  343.  
  344.      IF sz$ = "EXIT" THEN
  345.           UIPopAll
  346.           ERROR STFQUIT
  347.      ELSEIF sz$ = "REACTIVATE" THEN
  348.           GOTO ASKQUIT
  349.      ELSE
  350.           UIPop 1
  351.      END IF
  352.      RETURN
  353.  
  354.  
  355.  
  356. '**
  357. '** Purpose:
  358. '**     Adds the specified option files to the copy list.
  359. '** Arguments:
  360. '**     ftype%  - type of files to add, one of the following:
  361. '**             APPFILES, SAMPLEFILES
  362. '** Returns:
  363. '**     none.
  364. '*************************************************************************
  365. SUB AddOptFilesToCopyList (ftype%) STATIC
  366.  
  367.      IF GetListItem(CHECKSTATES$, ftype%) = "ON" THEN
  368.           SrcDir$ = GetSymbolValue("STF_SRCDIR")
  369.           IF ftype% = APPFILES THEN
  370.                 AddSectionFilesToCopyList "App", SrcDir$, DEST$
  371.                 AddSectionFilesToCopyList "AppWinSys", SrcDir$, WINSYSDIR$
  372.           ELSEIF ftype% = SAMPLEFILES THEN
  373.                 AddSectionFilesToCopyList "Sample", SrcDir$, SAMPLEDIR$
  374.           END IF
  375.           SrcDir$ = ""
  376.      END IF
  377. END SUB
  378.  
  379. SUB AddZBLZVLFilesToCopyList STATIC
  380.  
  381.      IF (GetListItem(CHECKSTATES$, APPFILES) = "ON") THEN
  382.           SrcDir$ = GetSymbolValue("STF_SRCDIR")
  383.                 AddSectionFilesToCopyList "ZBLZVL", SrcDir$, DEST$
  384.           SrcDir$ = ""
  385.      END IF
  386. END SUB
  387.  
  388.  
  389. '**
  390. '** Purpose:
  391. '**     Recalculates disk space for the given option files and sets
  392. '**     the status info symbol "StatusItemsText".
  393. '** Arguments:
  394. '**     ftype% - type of files to add, one of the following:
  395. '**             APPFILES, SAMPLEFILES
  396. '** Returns:
  397. '**     none.
  398. '*************************************************************************
  399. SUB RecalcOptFiles (ftype%) STATIC
  400.      CursorSave% = ShowWaitCursor()
  401.      ClearCopyList
  402.      AddOptFilesToCopyList ftype%
  403.      
  404.      fExtra% = 0
  405.      IF ftype% = APPFILES THEN
  406.           ListSym$ = APPNEEDS$
  407.      ELSEIF ftype% = SAMPLEFILES THEN
  408.           ListSym$ = SAMPLENEEDS$
  409.      ENDIF
  410.  
  411.      StillNeed& = GetCopyListCost(EXTRACOSTS$, ListSym$, "")
  412.  
  413.      cost& = 0
  414.      FOR i% = 1 TO 26 STEP 1
  415.           cost&  = cost& + VAL(GetListItem(ListSym$, i%))
  416.      NEXT i%
  417.      ReplaceListItem STATUSTEXT$, ftype%, STR$(cost& / 1024) + " K"
  418.  
  419.      IF StillNeed& > 0 THEN
  420.           ReplaceListItem BIGLIST$, ftype%, "YES"
  421.      ELSE
  422.           ReplaceListItem BIGLIST$, ftype%, ""
  423.      END IF
  424.  
  425.      IF fExtra% THEN
  426.           ReplaceListItem EXTRACOSTS$, ndrive%, "0"
  427.      END IF
  428.      RestoreCursor CursorSave%
  429.      ListSym$ = ""
  430. END SUB
  431.  
  432.  
  433. '**
  434. '** Purpose:
  435. '**     Recalculates disk space and sets option status info according
  436. '**     to the current destination path.
  437. '** Arguments:
  438. '**     none.
  439. '** Returns:
  440. '**     none.
  441. '*************************************************************************
  442. SUB RecalcPath STATIC
  443.  
  444.      CursorSave% = ShowWaitCursor()
  445.  
  446.      RecalcOptFiles APPFILES
  447.      RecalcOptFiles SAMPLEFILES
  448.  
  449.      RestoreCursor CursorSave%
  450. END SUB
  451.  
  452.  
  453. '**
  454. '** Purpose:
  455. '**     Sets drive status info according to latest disk space calcs.
  456. '** Arguments:
  457. '**     none.
  458. '** Returns:
  459. '**     none.
  460. '*************************************************************************
  461. SUB SetDriveStatus STATIC
  462.  
  463.      drive$ = MID$(DEST$, 1, 1)
  464.      ndrive% = ASC(ucase$(drive$)) - ASC("A") + 1
  465.      cost& = VAL(GetListItem(APPNEEDS$, ndrive%)) + VAL(GetListItem(SAMPLENEEDS$, ndrive%))
  466.      free& = GetFreeSpaceForDrive(drive$)
  467.      ReplaceListItem DRIVETEXT$, 1, drive$ + ":"
  468.      ReplaceListItem DRIVETEXT$, 2, STR$(cost& / 1024) + " K"
  469.      ReplaceListItem DRIVETEXT$, 3, STR$(free& / 1024) + " K"
  470.  
  471.      IF drive$ = WINDRIVE$ THEN
  472.           ReplaceListItem DRIVETEXT$, 4, ""
  473.           ReplaceListItem DRIVETEXT$, 5, ""
  474.           ReplaceListItem DRIVETEXT$, 6, ""
  475.      ELSE
  476.           ndrive% = ASC(ucase$(WINDRIVE$)) - ASC("A") + 1
  477.           cost& = VAL(GetListItem(APPNEEDS$, ndrive%)) + VAL(GetListItem(SAMPLENEEDS$, ndrive%))
  478.           IF cost& = 0 THEN
  479.             ReplaceListItem DRIVETEXT$, 4, ""
  480.             ReplaceListItem DRIVETEXT$, 5, ""
  481.             ReplaceListItem DRIVETEXT$, 6, ""
  482.         ELSE
  483.             free& = GetFreeSpaceForDrive(WINDRIVE$)
  484.                 ReplaceListItem DRIVETEXT$, 4, WINDRIVE$ + ":"
  485.             ReplaceListItem DRIVETEXT$, 5, STR$(cost& / 1024) + " K"
  486.             ReplaceListItem DRIVETEXT$, 6, STR$(free& / 1024) + " K"
  487.         END IF
  488.      END IF
  489. END SUB
  490.  
  491.  
  492. '**
  493. '** Purpose:
  494. '**     Appends a file name to the end of a directory path,
  495. '**     inserting a backslash character as needed.
  496. '** Arguments:
  497. '**     szDir$  - full directory path (with optional ending "\")
  498. '**     szFile$ - filename to append to directory
  499. '** Returns:
  500. '**     Resulting fully qualified path name.
  501. '*************************************************************************
  502. FUNCTION MakePath (szDir$, szFile$) STATIC AS STRING
  503.     IF szDir$ = "" THEN
  504.         MakePath = szFile$
  505.     ELSEIF szFile$ = "" THEN
  506.         MakePath = szDir$
  507.     ELSEIF MID$(szDir$, LEN(szDir$), 1) = "\" THEN
  508.         MakePath = szDir$ + szFile$
  509.     ELSE
  510.         MakePath = szDir$ + "\" + szFile$
  511.     END IF
  512. END FUNCTION
  513.