home *** CD-ROM | disk | FTP | other *** search
/ Power-Programmierung / CD2.mdf / c / library / mslang / stepon / _temp302.scp < prev    next >
Encoding:
Text File  |  1994-05-04  |  14.1 KB  |  362 lines

  1. '         ^^^^^^^^^^
  2. '            This program is configured in table part: Choose radio button Table
  3. '
  4. ' Hint:
  5. ' You're allowed to use this script or parts of changed or unchanged in your StepOne
  6. ' installation. 
  7. ' This script features professional installations for Windows and is full of hints and
  8. ' examples for your work with StepOne.
  9. ' If you change the table part (view: Table) of the script to your needs,
  10. ' you have a very good installation.
  11. ' One of the highlights of StepOne is the possibility to improve this installation script with 
  12. ' the powerful script language, so you have full control of the whole installation process.
  13. ' If you start this program without making changes, a new path will be created.
  14. ' If you edit the tables of the Table part corresponding to your needs you get a full installation.
  15.  
  16. ' If you start this script within StepIt, the StepOne FastCodeBuilder, you have to set the path
  17. ' of the to be copied files with menue FASTCODE - SETTINGS - COMMANDLINE, i.e. 'a:'.
  18. ' If the path is followed with a space and -1, you're abled to get the information that
  19. ' StepOne was started within StepIt.
  20. ' ***************************************************************************************************
  21.  
  22. ' ***************************************************************************************************
  23. ' The command line (View: FastCode - Settings - Commandline)which StepIt.exe or Install.exe (FirstStep) 
  24. ' passes through is saved in a variable.
  25. Len "ln", "{_command}"
  26. If "{ln}" = "0"
  27.     Label "NoSourcePath"
  28.     PathBox "command", "Please choose the path of the to be installed files.", "Choose source path", "{_bootdrv}\", "\", "*.*", "0", "&OK;&End"
  29.     if "{command}" = ""
  30.         end
  31.     endif
  32. Else
  33.     Let "command", "{_command}"
  34. EndIf
  35. DirExist "res", "{command}"
  36. If "{res}" = "0"
  37.     Goto "NoSourcePath"
  38. EndIf
  39.  
  40. Split "sourcepath",    "{command}"," ","1"
  41. Split "StepIt",        "{command}"," ","2"
  42.  
  43. Let "prgname", "{prginfos[1;1]}"
  44. Let "mainprg", "{prginfos[2;1]}"
  45.  
  46. ' Look if program runs
  47. GoSub "CheckPrg","{mainprg}"
  48. ' Welcome the user and give hints of using the installation
  49. GoSub "Welcome"
  50. ' Checking VBX files if they are loaded or installed in the Windows directory
  51. GoSub "CheckLibraries"    
  52.  
  53. Label "copyloop"
  54. ' The user can choose the installation path
  55. GoSub "GetTargetPath",  "{prginfos[3;1]}"
  56. ' Create the choosen path
  57. GoSub "CreatePath"
  58. If "{path}" = "0"
  59.     ' If create operation fails or user choosed anything other
  60.     Goto "CopyLoop"
  61. EndIf
  62.  
  63. ' Install files
  64. GoSub "Copying"
  65. If "{space}" = "-1"
  66.     ' Copying failed because of unsufficient disk space.
  67.     ' User has to choose another drive.
  68.     Goto "CopyLoop"
  69. EndIf
  70.  
  71. ' Add icon(s) in Program Manager group
  72. GoSub "ProgMan"
  73.  
  74. ' Add Extension(s)in Registration Database
  75. GoSub "RegBase"
  76.  
  77. ' Edit program INI file(s)
  78. GoSub "PrgINIs"
  79. If "{prginfos[4;1]}" = "-1"
  80.     GoSub "ShareExe"
  81. EndIf
  82.  
  83. ' Inform user about end of installation.
  84. ' Name of program is passed through to give user the possibility to start program immediately.
  85. GoSub "PrgEnd"
  86. ' End of installation
  87. End
  88.  
  89. ' *************************************************************
  90. Sub "Welcome"
  91.     ' Show main window
  92.     Window "-1", "{prgname} Installation", "Welcome", "Welcome to installation of {prgname}. Installation program will lead you through all neccessary steps.{_nl}{_nl}Press Continue to start installation.{_nl}{_nl}Press keys Ctrl and C together to cancel installation.", "", "43;23;960;888", "9"
  93.      GetUserInput "&Continue"
  94. EndSub
  95.  
  96. ' ***************************************************************************************************
  97. Sub "GetTargetPath"
  98.     Parameter targetpath    
  99.     Window "-1", "", "Choose target path", "Please select the path where {prgname} should be installed to."
  100.     Label "GetTargetPath1"
  101.     ' If {ret} is a complete path, 'pathbox' uses only the part after the last backslash.
  102.     ' In example 'c:\windows\system' will be used from 'PathBox' paramter 'Additional Path' as 'system'.
  103.     ' PathBox parameter DefaultPath can contain a relative path, i.e.: 'c:\windows\..' get to 'c:\'.
  104.     PathBox "targetpath", "Please choose the path for {prgname}.", "", "{_windowsdir}\..", "{GetTargetPath:targetpath}", "", "0", "&OK;&Cancel"
  105.     If "{targetpath}" = ""
  106.         ' User has choosed 'Cancel'. AskEnd asks the user if he want to end the program.
  107.         'If user chooses 'Yes', AskEnd works like End.
  108.         AskEnd
  109.         Goto "GetTargetPath1"    
  110.     EndIf
  111. EndSub
  112. ' ***************************************************************************************************
  113. ' New VBX and DLL files can be installed if they aren't loaded.
  114. Sub "CheckLibraries"
  115.     ' If installation program is started within StepIt, check for libraries
  116.     ' isn't neccessary. StepIt uses 
  117.     ' cscombo.vbx, csdialog.vbx, csform.vbx, ss3d.vbx, ss3d2.vbx, qpro200.dll
  118.     ' Some installation programs would fail at this point.
  119.     ' If you don't use the libraries you should set the if selection as remark.
  120.     If "{StepIt}" <> "-1"
  121.         ' Gets number of elements
  122.         GetTableElementCount "number_vbx", "vbxtable"
  123.         For "i", "1", "{number_vbx}"
  124.             FileExist "wfound", "{_windowsdir}\{vbxtable[1;i]}"
  125.              If "{wfound}" = "-1"
  126.                 GoSub "CorrectVBX", "{i}"
  127.             EndIf
  128.         Next
  129.     EndIf
  130. EndSub
  131. ' *********************************************************************************************
  132. Sub "CorrectVBX"
  133.     Parameter "iVbx"
  134.     Label "Active"
  135.     'Copies a common used file    from windows to system directory to force version control
  136.     'It isn't checked if any of the common used files are installed anywhere on the users
  137.     'system. So, nevertheless version conflicts may occure. But this procedure
  138.     'fixed the common mistake to install vbx and dll in the windows directory.
  139.     IsTaskActive "res", "{vbxtable[1;i]}"
  140.     If "{res}" = "-1"
  141.         MsgBox "res", "'{vbxtable[1;i]}' is in use. Please exit the application which uses the file and try it again.{_NL}If you aren't sure which application uses the library please exit all applications except of the Program Manager and this program.", "", "&Retry;&Program End"
  142.         If "{res}" = "2"
  143.             AskEnd
  144.         Else
  145.             Goto "Active"
  146.         EndIf
  147.     Else
  148.         MsgBox "correct", "'{vbxtable[1;i]}' was found in your Windows directory. {_nl}Libraries like '{vbxtable[1;i]}' should be installed in System directory.{_nl}Should installation program '{vbxtable[1;i]}' correct the problem? To be sure that '{prgname}' runs correctly you should choose 'Correct'!", "", "&Correct;&Ignore"
  149.          If "{correct}" = "1"
  150.             Copy "{_windowsdir}\{vbxtable[1;i]}", "{_systemdir}\{vbxtable[1;i]}", "2" 
  151.             If "{_err}" = "0"
  152.                 Del "{_windowsdir}\{vbxtable[1;i]}"
  153.             Else
  154.                 OutBox "'{vbxtable[1;i]}' couldn't be moved to System directory. If '{prgname}' doesn't run you should repeat the installation."
  155.             EndIf
  156.         EndIf
  157.       EndIf
  158. EndSub
  159.  
  160. ' ***************************************************************************************************
  161. Sub "CheckPrg"
  162.     Parameter "p"
  163.     Label "CheckPrg2"
  164.     IsTaskActive "res","{CheckPrg:p}"
  165.     If "{res}" = "-1"
  166.         MsgBox "ret", "{CheckPrg:p} is active. To install a newer version you have to close it first, to be sure that version control works correct. Should installation program close {PrⁿfePrg:p} for you?", "", "&Task close;&Retry;&Program end"
  167.         If "{ret}" = "1"
  168.             TaskStop "{CheckPrg:p}"
  169.         EndIf
  170.         If "{ret}" = "3"
  171.             End
  172.         EndIf
  173.         Goto "CheckPrg2"
  174.     Else
  175.         Goto "CheckPrg1"
  176.     EndIf
  177. Label "CheckPrg1"
  178. EndSub
  179.  
  180. ' ***************************************************************************************************
  181. Sub "CreatePath"
  182.     DirExist "res", "{targetpath}"
  183.     If "{res}" = "0"
  184.         MsgBox "res", "'{targetpath}' doesn't exist.{_nl}Do you want to create the path?", "", "&Create;Change &selection;&Program end"
  185.         If "{res}" = "3"
  186.             End
  187.         EndIf
  188.         If "{res}" = "2"
  189.             Let "directory", "0"    
  190.             Goto "CreatePath1"    
  191.         EndIf
  192.         MkDir "{targetpath}"
  193.         If "{_err}" = "-1"
  194.             OutBox "During creation of path '{targetpath}' an error occurs. Please choose another path."
  195.             Let "directory", "0"        
  196.         Else
  197.             Let "directory", "-1"
  198.         EndIf
  199.     Else
  200.         Let "directory", "-1"
  201.     EndIf
  202. Label "CreatePath1"
  203. EndSub
  204.  
  205. ' ***************************************************************************************************
  206. Sub "Copying"
  207.     Window "-1", "", "Copying...", " "
  208.     SplitPathName "todrv", "{targetpath}", "5"
  209.     ' StepOne calcs the total of all file lengths and substracts the sum of
  210.     ' the file lengths which will be overwritten. The minimum isn't 0
  211.     ' indeed it is the length of the longest file, which should be installed
  212.     ' if the installation is on the same drive as temp drive.
  213.     CalcFileTable "targetbytes", "targettable", "{sourcepath}", "{targetpath}", "3"
  214.     CalcFileTable "systembytes", "systemtable", "{sourcepath}", "{_systemdir}", "3"
  215.     ' Checks if two given paths have the same drive name
  216.     If "{_systemdir}" := "{targetpath}"
  217.         Compute "tofreebytes","{tofreebytes}" + "{targetbytes}"
  218.     Else
  219.         GetDiskFree "systemfreebytes", "{_systemdir}"    
  220.         If "{systembytes}" > "{systemfreebytes}"
  221.             OutBox "On drive{_nl}'{todrv}'{_nl}isn't enough space free. {systembytes} bytes free space required.{_nl}Please free enough space on drive and retry installation."
  222.             End
  223.         EndIf
  224.     EndIf
  225.     GetDiskFree "tofreebytes", "{targetpath}"
  226.     If "{targetbytes}" > "{tofreebytes}"
  227.         OutBox "On drive{_nl}'{todrv}'{_nl}isn't enough space free. Please choose another drive."
  228.         Let "space", "-1"
  229.         Goto "Copying_end"
  230.     Else
  231.         Window "-1", "", "Copying...", "Please be patient..."
  232.         GetTableLineCount "number_copy", "targettable"
  233.         If "{number_copy}" > "0"
  234.             CopyFileTable "targettable", "{sourcepath}", "{targetpath}", "1", "0"
  235.             If "{_err}" = "-1"
  236.                 MsgBox "res", "During copying occurs errors. Do you want to continue installation nevertheless?", "", "&OK;&Program end"
  237.                 If "{res}" = "2"
  238.                     End
  239.                 EndIf
  240.             EndIf
  241.         EndIf
  242.         If "{StepIt}" <> "-1"
  243.             GetTableLineCount "number_copy", "systemtable"
  244.             If "{number_copy}" > "0"
  245.                 Window "-1", "", "Copying system files..."
  246.                 CopyFileTable "systemtable", "{sourcepath}", "{_systemdir}", "1", "0"
  247.                 'Make sure, dialog will be closed
  248.                 CopyFileTable
  249.                 If "{_err}" = "-1"
  250.                     MsgBox "res", "During copying occurs errors. Do you want to continue installation nevertheless?", "", "&OK;&Program end"
  251.                     If "{res}" = "2"
  252.                         End
  253.                     EndIf
  254.                 EndIf
  255.             EndIf
  256.         EndIf
  257.         Let "space", "0"    
  258.     EndIf
  259.     Label "copying_end"
  260. EndSub
  261.  
  262. ' ***************************************************************************************************
  263. Sub "ProgMan"
  264.     ' Get number of elements
  265.     GetTableLineCount "number_prg", "prgmantable"
  266.     If "{number_prg}" > "0"
  267.         Window "-1", "", "Installing icons...", "Please be patient..."
  268.         Let "i", "1"
  269.         Let "tmp",""
  270.         Label "ProgMan1"    
  271.         If "{tmp}" <>  "{prgmantable[i;1]}"
  272.             Let "tmp", "{prgmantable[i;1]}"
  273.             DDEExecute "ProgMan", "ProgMan", "", "[creategroup({prgmantable[i;1]})]"
  274.             If "{_err}" = "-1"
  275.                 OutBox "Group '{prgmantable[i;1]}' couldn't be created in Program Manager."
  276.             EndIf
  277.         EndIf
  278.         GoSub "icon","{prgmantable[i;1]}","{targetpath}\{prgmantable[i;2]}","{prgmantable[i;3]}"
  279.         Compute "i", "{i}" + "1"
  280.         If "{i}" <= "{number_prg}"
  281.             Goto "ProgMan1"
  282.         EndIf
  283.     EndIf
  284. EndSub
  285.  
  286. ' ***************************************************************************************************
  287. Sub "Icon"
  288. Parameter "group","name","title"
  289.     ' Sets the group window so that 'replaceitem' can find the group window
  290.     DDEExecute "ProgMan", "ProgMan", "", "[showgroup({icon:group},1)]"
  291.     DDEExecute "ProgMan", "ProgMan", "", "[showgroup({icon:group},2)]"
  292.     ' Deletes icon and saves position...
  293.     DDEExecute "ProgMan", "ProgMan", "", "[replaceitem({icon:title})]"
  294.     ' ... Additem can use it
  295.     DDEExecute "ProgMan", "ProgMan", "", "[additem({icon:name},{icon:title},,)]"
  296.     If "{_err}" = "-1"
  297.         OutBox "'{prgname}' icon couldn't be installed in Program Manager."
  298.     EndIf
  299.     ' Brings group window on top, so user can find it immediately.
  300.     DDEExecute "ProgMan", "ProgMan", "", "[showgroup({icon:group},1)]"
  301. EndSub
  302. ' ***************************************************************************************************
  303. Sub "RegBase"
  304.     ' Gets number of elements
  305.     GetTableLineCount "number_reg", "regbasetable"
  306.     If "{number_reg}" > "0"
  307.         Let "i", "1"
  308.         Label "RegBase1"    
  309.         RegBaseWrite "{regbasetable[i;2]}", "{regbasetable[i;3]}"
  310.         RegBaseWrite "{regbasetable[i;3]}", "{regbasetable[i;4]}"
  311.         RegBaseWrite "{regbasetable[i;3]}\shell\open\command", "{targetpath}\{regbasetable[i;5]}"
  312.         If "{regbasetable[i;1]}" <> "CMD"
  313.             RegBaseWrite "{regbasetable[i;3]}\shell\open\ddeexec", "{regbasetable[i;6]}"
  314.             RegBaseWrite "{regbasetable[i;3]}\shell\open\ddeexec\application", "{regbasetable[i;7]}"
  315.             RegBaseWrite "{regbasetable[i;3]}\shell\open\ddeexec\topic", "{regbasetable[i;8]}"
  316.         EndIf
  317.         Compute "i", "{i}" + "1"
  318.         If "{i}" <= "{number_reg}"
  319.             Goto "RegBase1"
  320.         EndIf
  321.     EndIf    
  322. EndSub
  323.  
  324. ' ***************************************************************************************************
  325. Sub "PrgINIs"
  326.     ' Gets number of elements
  327.     GetTableLineCount "number_ini", "initable"
  328.     If "{number_ini}" > "0"
  329.         Let "i","1"
  330.         Label "PrgINIs1"
  331.         INIWrite "{initable[i;1]}","{initable[i;2]}","{initable[i;3]}","{initable[i;4]}"
  332.         Compute "i", "{i}" + "1"
  333.         If "{i}" <= "{number_ini}"
  334.             Goto "PrgINIs1"
  335.         EndIf
  336.     EndIf
  337. EndSub
  338.  
  339. ' ***************************************************************************************************
  340. Sub "ShareExe"
  341.     If "{_locking}" = "0"
  342.         MsgBox "addlocking", "'{prgname}' needs a network or SHARE for his database. Installation program can install SHARE in your AUTOEXEC.BAT and restarts your system after end of installation to let the changes effect. Do you want to add SHARE? To make the changes on yourself choose 'Not install'.", "SHARE.EXE", "&Install;&Not install"
  343.         If "{addlocking}" = "1"
  344.             AddShareExe
  345.         EndIf    
  346.     EndIf
  347. EndSub
  348.  
  349. Sub "PrgEnd"
  350.     Window "-1", "", "Ready!", "It's completed. Installation of '{prgname}' is finished."
  351.     GetUserInput "&OK"
  352.     If "{addlocking}" = "1"
  353.         MsgBox "reboot", "Installation program has add SHARE.EXE to your AUTOEXEC.BAT. To let the changes effect you've to restart your system. Should installation program makes a restart?", "Warmstart", "&Restart;&No Restart"
  354.         If "{reboot}" = "1"
  355.             ReBoot "3"
  356.         Else
  357.             OutBox "Before start of {prgname} you've to restart your system."
  358.         EndIf
  359.     EndIf
  360. EndSub
  361.