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

  1. '         ^^^^^^^^^^
  2. '              This program is configured in table part: Choose radio button Table
  3. '
  4. ' StepOne Installation
  5. ' ***************************************************************************************************
  6. ' Version 3.0
  7. ' Copyright K&R Software - Markus Kreisel & Renate Reinartz GbR, Cologne
  8. ' ***************************************************************************************************
  9. ' Hint:
  10. ' You're allowed to use this script or parts of changed or unchanged in your StepOne
  11. ' installation. 
  12. ' This script features professional installations for Windows and is full of hints and
  13. ' examples for your work with StepOne.
  14. ' If you change the table part (view: Table) of the script to your needs,
  15. ' you have a very good installation.
  16. ' One of the highlights of StepOne is the possibility to improve this installation script with 
  17. ' the powerful script language, so you have full control of the whole installation process.
  18. ' If you start this script within StepIt, the StepOne FastCodeBuilder, you have to set the path
  19. ' of the to be copied files with menue FASTCODE - SETTINGS - COMMANDLINE, i.e. 'a:'.
  20. ' If the path is followed with a space and -1, you're abled to get the information that
  21. ' StepOne was started within StepIt.
  22. ' ***************************************************************************************************
  23.  
  24. ' ***************************************************************************************************
  25. ' The command line (View: FastCode - Settings - Commandline)which StepIt.exe or Install.exe (FirstStep) 
  26. ' passes through is saved in a variable.
  27. len "ln", "{_command}"
  28. If "{ln}" = "0"
  29.     Label "NoSourcePath"
  30.     pathbox "command", "Please choose the path of the to be installed files.", "Choose source path", "{_bootdrv}\", "", "", "0", "&OK"
  31. Else
  32.     Let "command", "{_command}"
  33. EndIf
  34. DirExist "res", "{command}"
  35. If "{res}" = "0"
  36.     goto "NoSourcePath"
  37. endif
  38.  
  39. split "sourcepath",    "{command}","32","1"
  40. split "StepIt",        "{command}","32","2"
  41. ' ***************************************************************************************************
  42.  
  43. Let "prgname",     "{prginfos[1;1]}"
  44. Let "mainprg",    "{prginfos[2;1]}"
  45.  
  46. ' Look if program runs
  47. gosub "CheckPrg","{mainprg}"
  48.                      
  49. ' Welcome the user and give hints of using the installation
  50. gosub "Welcome"
  51.  
  52. ' Checking VBX files if they are loaded or installed in the Windows directory
  53. gosub "CheckLibraries"
  54.  
  55. label "CopyLoop"
  56.  
  57. ' The user can choose the installation path
  58. gosub "GetTargetPath", "{prginfos[3;1]}"
  59.  
  60. ' Create the choosen path
  61. gosub "CreatePath"
  62. if "{path}" = "0"
  63.     ' If create operation fails or user choosed anything other
  64.     goto "CopyLoop"
  65. endif
  66.  
  67. ' Install files
  68. gosub "Copying"
  69.  
  70. if "{space}" = "-1"
  71.     ' Copying failed because of unsufficient disk space.
  72.     ' User has to choose another drive.
  73.     goto "CopyLoop"
  74. endif
  75.  
  76. ' Add icon(s) in Program Manager group
  77. gosub "ProgMan"
  78.  
  79. ' Add Extension(s)in Registration Database
  80. gosub "RegBase"
  81.  
  82. ' Edit program INI file(s)
  83. gosub "PrgINIs"
  84.  
  85. ' Inform user about end of installation.
  86. ' Name of program is passed through
  87. ' to give user the possibility to start
  88. ' program immediately.
  89. gosub "PrgEnd","{TargetPath}\{MainPrg}"
  90.  
  91. ' End of installation
  92. end
  93.  
  94. ' ***************************************************************************************************
  95. sub "Welcome"
  96.     IniRead "OldWallpaper", "", "Desktop", "Wallpaper"
  97.     IniRead "OldWallpaperPos", "", "Desktop", "TileWallPaper"
  98.     SetWallPaper "{SourcePath}\install2.bmp", "-1"
  99.     ' Temporary change. If user aborts installation the old one reappears after next
  100.     ' start of Windows. After correct end of installation the old wallpaper is set.
  101.     IniWrite "", "Desktop", "Wallpaper","{OldWallpaper}"
  102.     IniWrite "", "Desktop", "TileWallpaper","{OldWallpaperPos}"
  103.     ' Show main window
  104.     window "-1", "{prgname} Installation", "Welcome", "Welcome to {prgname} installation. Installation leads you through all needed parts.{_nl}{_nl}Choose Continue to start installation.{_nl}{_nl}Choose Ctrl and C together to abort installation.", "{SourcePath}\install1.bmp", "43;23;960;888", "3"
  105.      ' Plays the MIDI file, which is delivered with Windows.
  106.     ' canyon.mid has to be installed and a sound card has to be installed correctly.
  107.     mcisend "", "Open {_windowsdir}\canyon.mid type sequencer alias midisong"
  108.     if "{_err}" = "0"
  109.         mcisend "", "play midisong"
  110.         let "midiplaying", "-1"
  111.     endif
  112.      getuserinput "&Continue"
  113.  
  114. endsub
  115. ' ***************************************************************************************************
  116. sub "GetTargetPath"
  117.     parameter TargetPath    
  118.     window "-1", "", "Choose target path", "Please choose the path, where {prgname} should be installed to."
  119.     FileSearch "d", "{MainPrg}"
  120.     if "{d}" = ""
  121.         Let "Default", "{_windowsdir}\.."
  122.         Let "Default2", "{GetTargetPath:TargetPath}"
  123.     else
  124.         Splitpathname "d", "{d}", "1"
  125.         Splitpathname "Default",     "{d}", "1"
  126.         Splitpathname "Default2",     "{d}", "2"
  127.     endif
  128.     label "GetTargetPath1"
  129.     pathbox "TargetPath", "Please choose the path for {prgname}.", "", "{Default}\", "{Default2}", "", "0", "&OK;&Cancel"
  130.     if "{TargetPath}" = ""
  131.         askend
  132.         goto "GetTargetPath1"    
  133.     endif
  134. endsub
  135. ' ***************************************************************************************************
  136. ' New VBX and DLL files can be installed if they aren't loaded.
  137. sub "CheckLibraries"
  138.     ' If installation program is started within StepIt, check for libraries
  139.     ' isn't neccessary. StepIt uses 
  140.     ' cscombo.vbx, csdialog.vbx, csform.vbx, ss3d.vbx, ss3d2.vbx, qpro200.dll
  141.     ' Some installation programs would fail at this point.
  142.     ' If you don't use the libraries you should set the if selection as remark.
  143.     if "{StepIt}" <> "-1"
  144.         ' Gets number of elements
  145.         gettableelementcount "number_vbx", "vbxtable"
  146.         for "i", "1", "{number_vbx}"
  147.             fileexist "wfound", "{_windowsdir}\{vbxtable[1;i]}"
  148.              if "{wfound}" = "-1"
  149.                 gosub "CorrectVBX", "{i}"
  150.             endif
  151.         next
  152.     endif
  153. endsub
  154. ' *********************************************************************************************
  155. sub "CorrectVBX"
  156.     Parameter "iVbx"
  157.     Label "Active"
  158.     'Copies a common used file    from windows to system directory to force version control
  159.     'It isn't checked if any of the common used files are installed anywhere on the users
  160.     'system. So, nevertheless version conflicts may occure. But this procedure
  161.     'fixed the common mistake to install vbx and dll in the windows directory.
  162.     istaskactive "res", "{vbxtable[1;i]}"
  163.     if "{res}" = "-1"
  164.         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"
  165.         if "{res}" = "2"
  166.             gosub CloseAll
  167.             end
  168.         else
  169.             goto "Active"
  170.         endif
  171.     else
  172.         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"
  173.          if "{correct}" = "1"
  174.             copy "{_windowsdir}\{vbxtable[1;i]}", "{_systemdir}\{vbxtable[1;i]}", "2" 
  175.             if "{_err}" = "0"
  176.                 del "{_windowsdir}\{vbxtable[1;i]}"
  177.             else
  178.                 outbox "'{vbxtable[1;i]}' couldn't be moved to System directory. If '{prgname}' doesn't run you should repeat the installation."
  179.             endif
  180.         endif
  181.       endif
  182. endsub
  183. ' ***************************************************************************************************
  184. sub "CheckPrg"
  185.     parameter "p"
  186.     label "CheckPrg2"
  187.     istaskactive "res","{CheckPrg:p}"
  188.     if "{res}" = "-1"
  189.         msgbox "ret", "{CheckPrg:p} is running. To install a newer version of it you have to close it first. Should installation program close {CheckPrg:p} for you?", "", "&Task close;&Retry;&Program End"
  190.         if "{ret}" = "1"
  191.             taskstop "{CheckPrg:p}"
  192.         endif
  193.         if "{ret}" = "3"
  194.             gosub CloseAll
  195.             End
  196.         endif
  197.         goto "CheckPrg2"
  198.     else
  199.         goto "CheckPrg1"
  200.     endif
  201. label "CheckPrg1"
  202. endsub
  203. ' ***************************************************************************************************
  204. sub "CreatePath"
  205.     direxist "res", "{TargetPath}"
  206.     if "{res}" = "0"
  207.         msgbox "res", "'{TargetPath}' doesn't exist.{_nl}Do you want to create path?", "", "&Create;Choose &another;&Program End"
  208.         if "{res}" = "3"
  209.             gosub CloseAll
  210.             end
  211.         endif
  212.         if "{res}" = "2"
  213.             let "path", "0"    
  214.             goto "CreatePath1"    
  215.         endif
  216.         mkdir "{TargetPath}"
  217.         if "{_err}" = "-1"
  218.             outbox "During creation of path '{TargetPath}' appears an error. Please choose another path."
  219.             let "path", "0"        
  220.         else
  221.             gosub "SubDirectories"
  222.         endif
  223.     else
  224.         gosub "SubDirectories"
  225.     endif
  226. label "CreatePath1"
  227. endsub
  228. ' ***************************************************************************************************
  229. sub "SubDirectories"
  230.     mkdir "{TargetPath}\samples"
  231.     if "{_err}" = "-1"
  232.         outbox "During creation of path '{TargetPath}\samples' occures an error. Please choose another path."
  233.         let "Path", "0"        
  234.     else
  235.         mkdir "{TargetPath}\redist"
  236.         if "{_err}" = "-1"
  237.             outbox "During creation of path '{TargetPath}\redist' occures an error. Please choose another path."
  238.             let "Path", "0"        
  239.         else
  240.             let "Path", "-1"
  241.         endif
  242.     endif
  243. endsub
  244. ' ***************************************************************************************************
  245. sub "Copying"
  246.  
  247.     if "{_windowsversion}" < "310"
  248.         'let "systab" , "systemtable30"
  249.         OutBox "The version of StepOne Pro we uploaded in CompuServe doesn't include the files for MS Windows 3.0. Please contact us for further information at 100116,2133."
  250.     else
  251.         let "systab" , "systemtable"
  252.     endif
  253.     let "systab" , "systemtable"
  254.  
  255.     splitpathname "todrv", "{TargetPath}", "5"
  256.     if "{midiplaying}" = "-1"
  257.         mcisend "", "pause midisong"
  258.     endif
  259.     getdiskfree "tempfree", "{_tempdir}"
  260.     if "{tempfree}" < "1000000"
  261.         msgbox "ret", "Installation needs about one megabyte temporary disk space in path '{_tempdir}'. Your system hasn't this space free. Free enough disk space and restart installation. Choose 'Ignore' to continue installation.", "", "&OK;&Ignore"
  262.         if "{ret}" = "1"
  263.             gosub CloseAll
  264.             end
  265.         endif
  266.     endif
  267.     ' StepOne calcs the total of all file lengths and substracts the sum of
  268.     ' the file lengths which will be overwritten. The minimum isn't 0
  269.     ' indeed it is the length of the longest file, which should be installed
  270.     ' if the installation is on the same drive as temp drive.
  271.     calcfiletable "targetbytes", "targettable", "{sourcepath}", "{targetpath}", "3"
  272.     msgbox "samplesflag", "Do you want to install the samples?", "", "&Install;&Skip"
  273.     if "{samplesflag}" ="1"
  274.         ' While the samples are packed into 3 packed files and every file needs
  275.         ' at least 2K in the target we assume aprox. 1MB. 
  276.         compute "targetbytes", "{targetbytes}" + "1000000"
  277.     endif
  278.     calcfiletable "systembytes", "{systab}", "{sourcepath}", "{_systemdir}", "3"
  279.     ' Checks if two given paths have the same drive name
  280.     if "{_systemdir}" := "{targetpath}"
  281.         compute "tofreebytes","{tofreebytes}" + "{targetbytes}"
  282.     else
  283.         getdiskfree "systemfreebytes", "{_systemdir}"    
  284.         if "{systembytes}" > "{systemfreebytes}"
  285.             outbox "Drive{_nl}'{todrv}'{_nl}hasn't enough disk space free. {systembytes} Bytes free disk space required.{_nl}Please free enough disk space and retry installation."
  286.             gosub CloseAll
  287.             end
  288.         endif
  289.     endif
  290.  
  291.     getdiskfree "tofreebytes", "{targetpath}"
  292.     if "{targetbytes}" > "{tofreebytes}"
  293.         outbox "Drive{_nl}'{todrv}'{_nl}hasn't enough disk space free. Please choose another drive."
  294.         let "space", "-1"
  295.         goto "copy_end"
  296.     else
  297.         window "-1", "", "Copying program...", "Copying has up to three parts. Please be patient..."
  298.         copyfiletable "targettable", "{sourcepath}", "{targetpath}", "1", "0"
  299.         if "{_err}" = "-1"
  300.             msgbox "res", "During copying an error occures. Do you want to continue with installation?", "", "&OK;&Program end"
  301.             if "{res}" = "2"
  302.                 gosub CloseAll
  303.                 end
  304.             endif
  305.         endif
  306.         if "{StepIt}" <> "-1"
  307.             if "{samplesflag}" = "1"
  308.                 window "-1", "", "Copying samples..."
  309.                 copyfiletable "sampletable", "{sourcepath}\samples", "{targetpath}\samples", "3", "0"
  310.                 if "{_err}" = "-1"
  311.                     msgbox "res", "During copying an error occures. Do you want to continue with installation?", "", "&OK;&Program end"
  312.                     if "{res}" = "2"
  313.                         gosub CloseAll
  314.                         end
  315.                     endif
  316.                 endif
  317.             endif
  318.             window "-1", "", "Copying system files..."
  319.             copyfiletable "{systab}", "{sourcepath}", "{_systemdir}", "1", "0"
  320.             'Make sure, dialog will be closed
  321.             copyfiletable
  322.             if "{_err}" = "-1"
  323.                 msgbox "res", "During copying an error occures. Do you want to continue with installation?", "", "&OK;&Program end"
  324.                 if "{res}" = "2"
  325.                     gosub CloseAll
  326.                     end
  327.                 endif
  328.             endif
  329.         endif
  330.         let "space", "0"    
  331.     endif
  332.     if "{midiplaying}" = "-1"
  333.         mcisend "", "play midisong"
  334.     endif    
  335.     if "{samplesflag}" = "1"
  336.         window "-1", "", "Building examples", "StepOne is building the examples.{_NL}{_NL}Part one of three.{_NL}{_NL}Please be patient."
  337.         gosub "SplitFile", "{targetpath}\samples\example1.txt", "{targetpath}\samples"
  338.         del "{targetpath}\samples\example1.txt"
  339.         window "-1", "", "", "StepOne is building the examples.{_NL}{_NL}Part two of three.{_NL}{_NL}Please be patient."
  340.         gosub "SplitFile", "{targetpath}\samples\example2.txt", "{targetpath}\samples"
  341.         del "{targetpath}\samples\example2.txt"
  342.         window "-1", "", "", "StepOne is building the examples.{_NL}{_NL}Last part.{_NL}{_NL}Please be patient."
  343.         gosub "SplitFile", "{targetpath}\samples\example3.txt", "{targetpath}\samples"
  344.         del "{targetpath}\samples\example3.txt"
  345.     endif
  346.     label "copy_end"
  347. endsub
  348.  
  349. sub "SplitFile"
  350.     Parameter "fname", "targetpath"
  351.     textread "s", "{SplitFile:fname}", "0"
  352.     for "i", "1", "1024"
  353.         compute "j","{i}" * "2"
  354.         split "p", "{s}", "º", "{j}"
  355.             if "{p}" = ""
  356.             exitfor
  357.         endif
  358.         compute "j","{j}" + "1"
  359.         split "p1", "{s}", "º", "{j}"
  360.         Textwrite "{SplitFile:targetpath}\{p}", "{p1}", "0", "-1"
  361.     next 
  362. endsub
  363.  
  364. ' ***************************************************************************************************
  365. sub "ProgMan"
  366.     ' Get number of elements
  367.     gettablelinecount "number_prg", "prgmantable"
  368.     if "{number_prg}" > "0"
  369.         window "-1", "", "Install icons...", "Please be patient..."
  370.         let "i", "1"
  371.         let "mark",""
  372.         label "ProgMan1"    
  373.         if "{mark}" <>  "{prgmantable[i;1]}"
  374.             let "mark", "{prgmantable[i;1]}"
  375.             ddeexecute "ProgMan", "ProgMan", "", "[creategroup({prgmantable[i;1]})]"
  376.             if "{_err}" = "-1"
  377.                 outbox "Group '{prgmantable[i;1]}' couldn't be created in Program Manager."
  378.             endif
  379.         endif
  380.         gosub "icon","{prgmantable[i;1]}","{targetpath}\{prgmantable[i;2]}","{prgmantable[i;3]}"
  381.         compute "i", "{i}" + "1"
  382.         if "{i}" <= "{number_prg}"
  383.             goto "ProgMan1"
  384.         endif
  385.     endif
  386. endsub
  387. ' ***************************************************************************************************
  388. sub "Icon"
  389. parameter "group","name","text"
  390.     ' Sets the group window so that 'replaceitem' can find the group window
  391.     ddeexecute "ProgMan", "ProgMan", "", "[showgroup({icon:group},1)]"
  392.     ddeexecute "ProgMan", "ProgMan", "", "[showgroup({icon:group},2)]"
  393.     ' Deletes icon and saves position...
  394.     ddeexecute "ProgMan", "ProgMan", "", "[replaceitem({icon:text})]"
  395.     ' ... Additem can use it
  396.     ddeexecute "ProgMan", "ProgMan", "", "[additem({icon:name},{icon:text},,)]"
  397.     if "{_err}" = "-1"
  398.         outbox "Icon of '{prgname}' couldn't be created in Program Manager."
  399.     endif
  400.     ' Brings group window on top, so user can find it immediately.
  401.     ddeexecute "ProgMan", "ProgMan", "", "[showgroup({icon:group},1)]"
  402. endsub
  403. ' ***************************************************************************************************
  404. sub "RegBase"
  405.     ' Gets number of elements
  406.     gettablelinecount "number_reg", "regbasetable"
  407.     if "{number_reg}" > "0"
  408.         let "i", "1"
  409.         label "RegBase1"    
  410.         RegBaseWrite "{regbasetable[i;2]}", "{regbasetable[i;3]}"
  411.         RegBaseWrite "{regbasetable[i;3]}", "{regbasetable[i;4]}"
  412.         RegBaseWrite "{regbasetable[i;3]}\shell\open\command", "{targetpath}\{regbasetable[i;5]}"
  413.         if "{regbasetable[i;1]}" <> "CMD"
  414.             RegBaseWrite "{regbasetable[i;3]}\shell\open\ddeexec", "{regbasetable[i;6]}"
  415.             RegBaseWrite "{regbasetable[i;3]}\shell\open\ddeexec\application", "{regbasetable[i;7]}"
  416.             RegBaseWrite "{regbasetable[i;3]}\shell\open\ddeexec\topic", "{regbasetable[i;8]}"
  417.         endif
  418.         compute "i", "{i}" + "1"
  419.         if "{i}" <= "{number_reg}"
  420.             goto "RegBase1"
  421.         endif
  422.     endif    
  423. endsub
  424. ' ***************************************************************************************************
  425. sub "PrgINIs"
  426.     gettablelinecount "number_ini", "initable"
  427.     if "{anzahl_ini}" > "0"
  428.         let "i","1"
  429.         label "PrgINIs1"
  430.         INIWrite "{initable[i;1]}","{initable[i;2]}","{initable[i;3]}","{initable[i;4]}"
  431.         compute "i", "{i}" + "1"
  432.         if "{i}" <= "{number_ini}"
  433.             goto "PrgINIs1"
  434.         endif
  435.     endif
  436. endsub
  437. ' ***************************************************************************************************
  438. sub "PrgEnd"
  439. parameter "Name"
  440.     textread "txt","{targetpath}\readme.txt"
  441.     window "-1", "", "Ready!", "We got it. Installation of '{prgname}' is ready. You can start '{prgname}' from Program Manager.{_nl}{_nl}{txt}"
  442.     getuserinput "&OK"
  443.     msgbox "res", "Do you want to start '{prgname}' now?", "", "&Start;&Program end"
  444.     if "{res}" = "1"
  445.         taskstart "{PrgEnd:name}" 
  446.     endif
  447.     ' What someone opens, someone has to close.
  448.     gosub CloseAll
  449. endsub
  450. ' ***************************************************************************************************
  451. sub "_ctrlc"
  452.     resstringread "title","","26"
  453.     resstringread "buttons","","1"
  454.     msgbox "end", "{title}", "", "{buttons}"    
  455.     if "{end}" = "1"
  456.         ' What someone opens, someone has to close.
  457.         gosub CloseAll
  458.         end
  459.     endif
  460. endsub
  461. ' ***************************************************************************************************
  462. sub "CloseAll"
  463.     if "{midiplaying}" = "-1"
  464.         mcisend "", "close midisong"
  465.     endif
  466.     SetWallPaper "{OldWallPaper}","{OldWallpaperPos}"
  467. endsub
  468.  
  469.