home *** CD-ROM | disk | FTP | other *** search
/ PC World Komputer 1998 October A / Pcwk10a98.iso / Corel / Ventura8 / Ventura / Scripts / CSCConverter.csc < prev    next >
Text File  |  1998-07-08  |  40KB  |  850 lines

  1. REM Converts scripts from version 7.0 to 8.0[CorelSCRIPT 8]
  2. REM CSCConverter.csc  February 5, 1998
  3. REM ⌐ 1998 Corel Corporation. All rights reserved.
  4.  
  5. REM **********************************************************************
  6. REM This script updates version 7 scripts to version 8.
  7. REM The automation object number is updated in any WITHOBJECT statements:
  8. REM    WITHOBJECT "CorelVentura.Automation.7" --> WITHOBJECT "CorelVentura.Automation.8"
  9. REM    WITHOBJECT "CorelPhotoPaint.Automation.7" --> WITHOBJECT "CorelPhotoPaint.Automation.8"
  10. REM    WITHOBJECT "CorelDraw.Automation.7" --> WITHOBJECT "CorelDraw.Automation.8"
  11. REM IF you used the Script constants as defined in ScpConst.csi, then 
  12. REM you need not worry about your WITHOBJECT statement within your scripts.
  13. REM You will only have to update the automation object string in ScpConst.csi.
  14. REM This script also updates the registry key specifying the version number from 7 to 8.
  15. REM    "SOFTWARE\Corel\Corel *\7.0" --> "SOFTWARE\Corel\Corel *\8.0"
  16. REM **********************************************************************
  17.  
  18. ' Create a temporary folder to provide a path for the include files
  19. '  -this enables the include files to be located 
  20. #addfol "..\..\Scripts"
  21. #include "ScpConst.csi"
  22. #include "VPConst.csi"
  23.  
  24. ' Embed bitmaps if script is to be compiled into exe or csb formats
  25. ' -this will eliminate the need to include these files
  26. #ADDRESBMP Step2BMP "Bitmaps\Step2BMP.bmp"
  27. #ADDRESBMP Step3BMP "Bitmaps\Step3BMP.bmp"
  28.  
  29. 'Constants for Dialog Return Values
  30. GLOBAL CONST DIALOG_RETURN_CANCEL% = 2
  31. GLOBAL CONST DIALOG_RETURN_NEXT% = 3
  32. GLOBAL CONST DIALOG_RETURN_BACK% = 4
  33. GLOBAL CONST DIALOG_RETURN_BROWSE% = 5
  34.  
  35. GLOBAL CONST MAX_FILES% = 10
  36. GLOBAL CONST MAX_FILE_EXT% = 2
  37.  
  38. '/////FUNCTION & SUBROUTINE DECLARATIONS/////////////////////////////////////////////////
  39. DECLARE SUB RegQuery()
  40. DECLARE FUNCTION ShowIntro%()
  41. DECLARE FUNCTION GetSourceDir%()
  42. DECLARE SUB GetFileList(BYVAL SourceDir$, FileExt$)
  43. DECLARE FUNCTION ShowFileList%()
  44. DECLARE FUNCTION ShowFinish%()
  45. DECLARE FUNCTION ShowSummary
  46. DECLARE SUB ConvertFile(ScriptFile$)
  47. DECLARE FUNCTION EditObject$(ObjString$)
  48. DECLARE FUNCTION EditRegistry$(InputString$)
  49. DECLARE SUB LaunchScript(ScriptFileName$)
  50.  
  51.  
  52. '/////GLOBAL VARIABLES //////////////////////////////////////////////////////////
  53. GLOBAL VenturaRoot$                    'root directory where Ventura is installed
  54. GLOBAL SourceDir$                    'directory in which to start the search for files
  55. GLOBAL DestinationDir$                'directory in which to save the converted files
  56. GLOBAL FileExt$                    'file extension used by GetFileList sub
  57. FileExt$ = "*.CSC"
  58.  
  59. GLOBAL AvailableFiles$(MAX_FILES)        'list of files available for selection 
  60. GLOBAL AvailableDirs$(MAX_FILES)        'list of directories corresponding to available files    
  61. GLOBAL AvailableFilesCount%            'number of files available for selection
  62.  
  63. GLOBAL SelectedFiles$(MAX_FILES)        'list of file names selected for conversion
  64. GLOBAL SelectedDirs$(MAX_FILES)        'list of directories corresponding to selected files
  65. GLOBAL SelectedFilesCount%            'number of files selected
  66.  
  67. GLOBAL UnsuccessfulFiles$(MAX_FILES)    'list of files not successfully converted
  68. GLOBAL UnsuccessfulFilesCount%        'number of files not successfully converted
  69. GLOBAL SuccessfulFiles$(MAX_FILES)        'list of files successfully converted
  70. GLOBAL SuccessfulFilesCount%            'number of files successfully converted
  71.  
  72.  
  73. '////// LOCAL VARIABLES //////////////////////////////////////////////////////////////////////////////
  74. CONST MAXSTEP% = 6        'maximum number of pages in the Wizard
  75. DIM DialogReturn%        'identifies user's selection for next step in Wizard
  76. DIM NextStep%            'specifies which page appears next in the Wizard
  77.  
  78. ' **************************************************************************************
  79. ' MAIN
  80. ' **************************************************************************************
  81. ON ERROR GOTO ErrorHandler
  82. RegQuery                                        'get root directory where Ventura is installed
  83. SourceDir$= VenturaRoot$     & "\Ventura\Scripts"        'initialize source directory to Ventura\Samples dirextory
  84.  
  85. 'this section controls traversal through the Wizard pages
  86. NextStep% = 1
  87. DO
  88.     SELECT CASE NextStep%
  89.         CASE 1: DialogReturn% = ShowIntro()        'show Intro dialog
  90.         CASE 2: DialogReturn% = GetSourceDir()        'get source directory
  91.         CASE 3: DialogReturn%  = ShowFileList()        'select files to convert
  92.         CASE 4: DialogReturn%  = ShowFinish()        'show list of selected scripts
  93.         CASE 5:     BEGINWAITCURSOR
  94.                 REDIM SuccessfulFiles$(SelectedFilesCount%)        'dimension list for successful conversion
  95.                 REDIM UnsuccessfulFiles$(SelectedFilesCount%)    'dimension list for unsuccessful conversion    
  96.                 FOR i% = 1 TO SelectedFilesCount%    'convert selected scripts  
  97.                     ConvertFile SelectedDirs$(i%) & SelectedFiles$(i%)
  98.                    NEXT i%        
  99.                 ENDWAITCURSOR    
  100.         CASE 6: DialogReturn% = ShowSummary()        'show summary of conversion
  101.     END SELECT
  102.     NextStep% = NextStep%+ DialogReturn%
  103. LOOP UNTIL NextStep% = MAXSTEP + 1
  104.  
  105. ExitScript:
  106. STOP
  107.  
  108. ErrorHandler:
  109. SELECT CASE ErrNum
  110.     CASE 800
  111.         MESSAGE "FATAL ERROR" & CHR(13) & "Script will now exit."
  112.         RESUME AT ExitScript
  113.     CASE ELSE
  114.         MESSAGE "ERROR: " & STR(ErrNum) & CHR(13) & "Script will now exit."
  115.         RESUME AT ExitScript
  116.     END SELECT
  117.  
  118.  
  119. ' *******************************************************************************
  120. ' RegQuery
  121. ' This subroutine queries the Registry to determine the root directory where 
  122. ' Ventura is installed.
  123. ' *******************************************************************************
  124. SUB RegQuery
  125. ON ERROR GOTO ErrorHandler
  126.  
  127.     'get Ventura config directory
  128.     VentDir$ = REGISTRYQUERY(HKEY_LOCAL_MACHINE,VENTURA_REGQUERY_CONST,"ConfigDir")     
  129.     
  130.     'isolate Ventura root directory from Ventura config directory
  131.     first% = 1
  132.     pos% = 1
  133.     DO WHILE first <> 0
  134.         first = INSTR(VentDir$, "\", first )
  135.         IF first <> 0 THEN
  136.             pos = first
  137.             first = first + 1
  138.         END IF
  139.     LOOP
  140.     VenturaRoot$ = LEFT(VentDir$, pos - 1)     'root directory where Ventura is installed
  141.  
  142. EXIT SUB
  143. ErrorHandler:
  144.     MESSAGE "Error reading registry:" & CHR(13) & RegString$
  145.     ErrNum = 800
  146. END SUB
  147.  
  148.  
  149. ' *******************************************************************************
  150. ' ShowIntro
  151. ' This function displays the introduction dialog.
  152. ' PARAMS: None
  153. '
  154. ' RETURNS: ShowIntro AS INTEGER - Integer indicating dialog return value.
  155. ' *******************************************************************************
  156. FUNCTION ShowIntro%
  157. BEGIN DIALOG OBJECT IntroDialog 290, 180, "Corel SCRIPT Converter", SUB IntroDialogEventHandler
  158.     PUSHBUTTON  181, 160, 46, 14, .NextButton, "&Next >"
  159.     CANCELBUTTON  234, 160, 46, 14, .CancelButton
  160.     PUSHBUTTON  135, 160, 46, 14, .BackButton, "< &Back"
  161.     TEXT  95, 10, 185, 20, .Text2, "This Wizard converts scripts from previous versions of Corel SCRIPT to the version 8 format."
  162.     TEXT  95, 40, 185, 12, .Text3, "To begin converting your scripts, click Next."
  163.     IMAGE  10, 10, 75, 130, .IntroImage
  164.     GROUPBOX  10, 150, 270, 5, .LineGroupBox
  165. END DIALOG
  166.  
  167.     IntroDialog.IntroImage.SetImage "#Step2BMP"
  168.     IntroDialog.IntroImage.SetStyle STYLE_IMAGE_CENTERED
  169.     IntroRet%=DIALOG(IntroDialog)
  170.     IF IntroRet% = DIALOG_RETURN_CANCEL THEN STOP            
  171.     IF IntroRet% = DIALOG_RETURN_NEXT THEN ShowIntro = 1        
  172.  
  173. END FUNCTION
  174.  
  175. ' *******************************************************************************
  176. ' IntroDialogEventHandler
  177. ' This subroutine responds to user interface with the introduction dialog.
  178. ' PARAMS: BYVAL ControlID% - Integer indicating the dialog control that is 
  179. '                            generating a dialog event.
  180. '        BYVAL Event% - Integer indicating the dialog event that has occurred.
  181. ' *******************************************************************************
  182. SUB IntroDialogEventHandler(BYVAL ControlID%, BYVAL Event%)
  183.     IF Event% = EVENT_INITIALIZATION THEN         
  184.         IntroDialog.BackButton.Enable FALSE 
  185.     ENDIF
  186.     IF Event% = EVENT_MOUSE_CLICK THEN     
  187.         SELECT CASE ControlID%
  188.             CASE IntroDialog.NextButton.GetID()
  189.                 IntroDialog.CloseDialog DIALOG_RETURN_NEXT
  190.             CASE IntroDialog.CancelButton.GetID()
  191.                 IntroDialog.CloseDialog DIALOG_RETURN_CANCEL
  192.         END SELECT
  193.     ENDIF
  194. END FUNCTION
  195.  
  196.  
  197. ' *******************************************************************************
  198. ' GetSourceDir
  199. ' This function prompts the user for the directory at which to begin the search 
  200. ' for files, as well as the type of file (ie. chp or pub) to use and the 
  201. ' maximum size of embedded pictures.
  202. '
  203. ' PARAMS:  None
  204. ' RETURNS: GetSourceDir AS INTEGER - Integer indicating dialog return value.
  205. '
  206. ' COMMENTS: A valid souce directory is required to continue to next dialog.
  207. ' *******************************************************************************
  208. FUNCTION GetSourceDir
  209. BEGIN DIALOG OBJECT SourceDialog 290, 180, "Corel SCRIPT Converter", SUB SourceDialogEventHandler
  210.     TEXTBOX  100, 47, 175, 13, .SourceDirectory
  211.     PUSHBUTTON  229, 66, 46, 14, .BrowseButton, "B&rowse..."
  212.     PUSHBUTTON  135, 160, 46, 14, .BackButton, "< &Back"
  213.     PUSHBUTTON  181, 160, 46, 14, .NextButton, "&Next >"
  214.     CANCELBUTTON  234, 160, 46, 14, .CancelButton
  215.     TEXT  95, 11, 185, 16, .Text1, "What is the location of the scripts you want to convert?"
  216.     IMAGE  10, 10, 75, 130, .SourceImage
  217.     GROUPBOX  10, 150, 270, 5, .LineGroupBox
  218.     GROUPBOX  95, 34, 185, 52, .FilesGroupBox, "Location of files:"
  219. END DIALOG
  220.  
  221.     SourceDialog.SourceImage.SetImage "#Step2BMP"
  222.     SourceDialog.SourceImage.SetStyle STYLE_IMAGE_CENTERED
  223.  
  224.     SourceRet%=DIALOG(SourceDialog)
  225.     SELECT CASE SourceRet%
  226.         CASE DIALOG_RETURN_CANCEL    
  227.             STOP
  228.         CASE DIALOG_RETURN_NEXT        
  229.             IF INSTR(SourceDir$, "\", LEN(SourceDir$)) = 0 THEN 
  230.                 SourceDir$ = SourceDir$ & "\"
  231.             ENDIF
  232.             GetSourceDir = 1
  233.         CASE DIALOG_RETURN_BACK         
  234.             SETCURRFOLDER SourceDir
  235.             GetSourceDir = -1
  236.     END SELECT
  237. END FUNCTION
  238.  
  239.  
  240. ' *******************************************************************************
  241. ' SourceDialogEventHandler
  242. ' This subroutine responds to user interface with the source directory dialog.
  243. ' PARAMS: BYVAL ControlID% - Integer indicating the dialog control that is 
  244. '                            generating a dialog event.
  245. '        BYVAL Event% - Integer indicating the dialog event that has occurred.
  246. ' *******************************************************************************
  247. SUB SourceDialogEventHandler(BYVAL ControlID%, BYVAL Event%)
  248.     IF Event% = EVENT_INITIALIZATION THEN         
  249.         SourceDialog.SourceDirectory.SetText SourceDir$
  250.     ENDIF
  251.  
  252.     IF Event% = EVENT_CHANGE_IN_CONTENT THEN         
  253.         SELECT CASE ControlID%
  254.             CASE SourceDialog.SourceDirectory.GetID()        
  255.                 SourceDir$ = SourceDialog.SourceDirectory.GetText()    
  256.         END SELECT
  257.     ENDIF
  258.  
  259.     IF Event% = EVENT_MOUSE_CLICK THEN         
  260.         SELECT CASE ControlID%
  261.             CASE SourceDialog.NextButton.GetID()
  262.                 SourceDialog.closedialog DIALOG_RETURN_NEXT
  263.             CASE SourceDialog.BackButton.GetID()
  264.                 SourceDialog.closedialog DIALOG_RETURN_BACK
  265.             CASE SourceDialog.CancelButton.GetID()    
  266.                 SourceDialog.closedialog DIALOG_RETURN_CANCEL    
  267.             CASE SourceDialog.BrowseButton.GetID()    
  268.                 NewSourceDir$ = GETFOLDER(SourceDir$)                
  269.                 IF NewSourceDir$ = "" THEN 
  270.                     SourceDialog.SourceDirectory.SetText SourceDir$
  271.                 ELSE
  272.                     SourceDialog.SourceDirectory.SetText NewSourceDir$
  273.                     SourceDir$ = NewSourceDir$
  274.                 ENDIF
  275.         END SELECT
  276.     ENDIF
  277.     SourceDir$ = SourceDialog.SourceDirectory.gettext()        
  278.     IF SourceDir$  = "" THEN
  279.         SourceDialog.NextButton.Enable FALSE
  280.     ELSE
  281.         SourceDialog.NextButton.Enable TRUE
  282.     ENDIF    
  283.  
  284. END SUB
  285.  
  286.  
  287.  
  288. ' *******************************************************************************
  289. ' ShowFileList
  290. ' This function displays a list of available files of the specified type starting
  291. ' at the specified location.
  292. '
  293. ' PARAMS: None
  294. '
  295. ' RETURNS: ShowFileList AS INTEGER - Integer indicating dialog return value.
  296. ' *******************************************************************************
  297. FUNCTION ShowFileList
  298. BEGIN DIALOG OBJECT ShowFileListDialog 290, 180, "Corel SCRIPT Converter", SUB FileListDialogEventHandler
  299.     LISTBOX  10, 25, 100, 107, .FileListBox
  300.     PUSHBUTTON  122, 33, 46, 14, .SelectButton, "&Select >>"
  301.     PUSHBUTTON  122, 49, 46, 14, .DeselectButton, "<< &Deselect"
  302.     PUSHBUTTON  123, 95, 46, 14, .SelectAllButton, "Select &All"
  303.     PUSHBUTTON  123, 112, 46, 14, .DeselectAllButton, "D&eselect All"
  304.     LISTBOX  180, 25, 100, 107, .SelectedFileListBox
  305.     PUSHBUTTON  135, 160, 46, 14, .BackButton, "< &Back"
  306.     PUSHBUTTON  181, 160, 46, 14, .NextButton, "&Next >"
  307.     CANCELBUTTON  234, 160, 46, 14, .CancelButton
  308.     TEXT  10, 2, 269, 11, .Text2, "Select the files you wish to convert."
  309.     TEXT  10, 14, 56, 10, .Text4, "Available files:"
  310.     TEXT  88, 14, 20, 10, .FilesCountText, ""
  311.     TEXT  180, 14, 61, 10, .Text5, "Selected files:"
  312.     TEXT  258, 14, 20, 10, .SelectedFilesCountText, ""
  313.     TEXT  10, 136, 270, 12, .StatusText, "No files selected"
  314.     LISTBOX  10, 25, 100, 107, .DirectoryListBox
  315.     LISTBOX  180, 25, 100, 107, .SelectedDirectoryListBox
  316.     GROUPBOX  10, 150, 270, 5, .LineGroupBox
  317. END DIALOG
  318.     ShowFileListDialog.SetStyle STYLE_INVISIBLE
  319.     ShowFileListDialog.StatusText.SetStyle STYLE_SUNKEN
  320.     ShowFileListRet% = DIALOG(ShowFileListDialog)
  321.     
  322.     SELECT CASE ShowFileListRet%
  323.         CASE DIALOG_RETURN_CANCEL        
  324.             STOP
  325.         CASE DIALOG_RETURN_NEXT        
  326.             ShowFileList = 1
  327.         CASE DIALOG_RETURN_BACK         
  328.             ShowFileList = -1
  329.     END SELECT
  330. END FUNCTION
  331.  
  332.  
  333. ' *******************************************************************************
  334. ' FileListDialogEventHandler
  335. ' This subroutine responds to user interface with the file list dialog.
  336. ' PARAMS: BYVAL ControlID% - Integer indicating the dialog control that is 
  337. '                            generating a dialog event.
  338. '        BYVAL Event% - Integer indicating the dialog event that has occurred.
  339. ' *******************************************************************************
  340. SUB FileListDialogEventHandler(BYVAL ControlID%, BYVAL Event%)
  341.     IF Event% = EVENT_INITIALIZATION THEN         
  342.         ShowFileListDialog.DirectoryListBox.SetStyle STYLE_INVISIBLE            'hide directory list box (for tracking files - user doesn't need to see this)
  343.         ShowFileListDialog.SelectedDirectoryListBox.SetStyle STYLE_INVISIBLE        'hide selected directory list box (for tracking files - user doesn't need to see this)
  344.         ShowFileListDialog.FilesCountText.SetStyle STYLE_RIGHT_JUSTIFY            'right justify text displaying file count
  345.         ShowFileListDialog.SelectedFilesCountText.SetStyle STYLE_RIGHT_JUSTIFY    'right justify text displaying selected files count
  346.  
  347.         'disable NEXT button until file(s) have been selected
  348.         IF ShowFileListDialog.SelectedFileListBox.GetItemCount() = 0 THEN 
  349.             ShowFileListDialog.NextButton.Enable FALSE
  350.         ELSE
  351.             ShowFileListDialog.NextButton.Enable TRUE
  352.         ENDIF    
  353.  
  354.         'IF files have already been selected, display same list
  355.         IF SelectedFilesCount > 0 THEN
  356.             ShowFileListDialog.FileListBox.SetArray AvailableFiles$            'display available files list in Available Files listbox
  357.             ShowFileListDialog.DirectoryListBox.SetArray AvailableDirs$            'display available dirs list in Avaialable Dirs listbox
  358.             ShowFileListDialog.SelectedFileListBox.SetArray SelectedFiles$        'display selected files list in Selected Files listbox
  359.             ShowFileListDialog.SelectedDirectoryListBox.SetArray SelectedDirs$    'display selected dirs list in Selected Dirs listbox
  360.  
  361.         'get and display list of files (with extension FileExt$) starting in Source directory
  362.         ELSE
  363.             GetFileList SourceDir$, FileExt$                                                'get file list
  364.             ShowFileListDialog.FileListBox.SetSelect 1                                        'give focus to first element in file list box
  365.             ShowFileListDialog.StatusText.SetText ShowFileListDialog.DirectoryListBox.GetItem(1)        'set status text to first item in file list
  366.             ShowFileListDialog.FilesCountText.SetText ShowFileListDialog.FileListBox.GetItemCount()    'set file count to number of available files
  367.             ShowFileListDialog.SelectedFilesCountText.SetText ShowFileListDialog.SelectedFileListBox.GetItemCount()    'set selected files count to number of selected files
  368.         ENDIF
  369.         ShowFileListDialog.SetStyle STYLE_VISIBLE
  370.     ENDIF
  371.  
  372.     IF Event% = EVENT_MOUSE_CLICK THEN         
  373.         SELECT CASE ControlID%
  374.             CASE ShowFileListDialog.NextButton.GetID()        
  375.                 'create list of selected files and directories
  376.                 SelectedFilesCount% = ShowFileListDialog.SelectedFileListBox.GetItemCount()
  377.                 REDIM SelectedFiles$(SelectedFilesCount%)    'redimension array to accomodate all selected files
  378.                 REDIM SelectedDirs$(SelectedFilesCount%)    'redimension array to accomodate all selected directories
  379.                 FOR i% = 1 TO SelectedFilesCount%            'FOR all items in selected files list
  380.                     SelectedFiles$(i%) = ShowFileListDialog.SelectedFileListBox.GetItem(i%)    'add item to file list        
  381.                     SelectedDirs$(i%) = ShowFileListDialog.SelectedDirectoryListBox.GetItem(i%)'add item to directory list
  382.                 NEXT i%
  383.     
  384.                 'create list of available files and directories
  385.                 AvailableFilesCount% = ShowFileListDialog.FileListBox.GetItemCount()
  386.                 REDIM AvailableFiles$(AvailableFilesCount)    'redimension array to accomodate all available files
  387.                 REDIM AvailableDirs$(AvailableFilesCount)    'redimension array to accomodate all available directories
  388.                 FOR i% = 1 TO AvailableFilesCount%            'FOR all items in avialable files list
  389.                     AvailableFiles$(i%) = ShowFileListDialog.FileListBox.GetItem(i%)        'add item to file list
  390.                     AvailableDirs$(i%) = ShowFileListDialog.DirectoryListBox.GetItem(i%)    'add item to directory list
  391.                 NEXT i%
  392.                 ShowFileListDialog.closedialog DIALOG_RETURN_NEXT
  393.  
  394.             CASE ShowFileListDialog.BackButton.GetID()        
  395.                 ShowFileListDialog.closedialog DIALOG_RETURN_BACK
  396.  
  397.             CASE ShowFileListDialog.SelectButton.GetID()            
  398.                 indx% = ShowFileListDialog.FileListBox.GetSelect()        'get index of current selection
  399.                 IF indx%=0 THEN        'no files selected, display appropriate message
  400.                     IF ShowFileListDialog.FileListBox.GetItemCount() = 0 THEN
  401.                         MESSAGE "There are no files available for selection."
  402.                     ELSE
  403.                         MESSAGE "Please select a file from the available files list."
  404.                     ENDIF
  405.                 ELSE                    'valid selection, add current selection to selected files list            
  406.                     ShowFileListDialog.SelectedFileListBox.AddItem ShowFileListDialog.FileListBox.GetItem(indx%)            'add current selection to selected files list
  407.                     ShowFileListDialog.FileListBox.RemoveItem indx%                                                'remove current selection from available files list
  408.                     ShowFileListDialog.SelectedDirectoryListBox.AddItem ShowFileListDialog.DirectoryListBox.GetItem(indx%)    'add current selection to selected directory list
  409.                     ShowFileListDialog.DirectoryListBox.RemoveItem indx%                                            'remove current selection from available directory list
  410.                     IF indx% > ShowFileListDialog.FileListBox.GetItemCount() THEN                                    'IF current selection is not the last         
  411.                         ShowFileListDialog.FileListBox.SetSelect indx%-1                                            'set focus to previous item
  412.                     ELSE                    
  413.                         ShowFileListDialog.FileListBox.SetSelect indx%                                            'ELSE set    focus to current selection
  414.                     ENDIF
  415.                      ShowFileListDialog.StatusText.SetText ShowFileListDialog.DirectoryListBox.GetItem(ShowFileListDialog.FileListBox.GetSelect())
  416.                     ShowFileListDialog.SelectedFileListBox.SetSelect 0
  417.                 ENDIF
  418.  
  419.             CASE ShowFileListDialog.DeselectButton.GetID()            
  420.                 indx% = ShowFileListDialog.SelectedFileListBox.GetSelect()    'get index of current selection
  421.                 IF indx%=0 THEN        'no files selected, display appropriate message
  422.                     IF ShowFileListDialog.SelectedFileListBox.GetItemCount() = 0 THEN
  423.                         MESSAGE "There are no files available for deselection"
  424.                     ELSE
  425.                         MESSAGE "Please select a file from the selected files list."
  426.                     ENDIF        
  427.                 ELSE                    'valid selection, remove current selection from selected files list
  428.                     ShowFileListDialog.FileListBox.AddItem ShowFileListDialog.SelectedFileListBox.GetItem(indx%)            'add current selection to available files list
  429.                     ShowFileListDialog.SelectedFileListBox.RemoveItem indx%                                        'remove current selection from selected files list
  430.                     ShowFileListDialog.DirectoryListBox.AddItem ShowFileListDialog.SelectedDirectoryListBox.GetItem(indx%)    'add current selection to available directory list
  431.                     ShowFileListDialog.SelectedDirectoryListBox.RemoveItem indx%                                    'remove current selection from selected directory list
  432.                     IF indx% > ShowFileListDialog.SelectedFileListBox.GetItemCount() THEN                                'IF current selection is not the last         
  433.                         ShowFileListDialog.SelectedFileListBox.SetSelect indx%-1                                    'set focus to previous item
  434.                     ELSE
  435.                         ShowFileListDialog.SelectedFileListBox.SetSelect indx%                                        'ELSE set    focus to current selection
  436.                     ENDIF
  437.                      ShowFileListDialog.StatusText.SetText ShowFileListDialog.SelectedDirectoryListBox.GetItem(ShowFileListDialog.SelectedFileListBox.GetSelect())
  438.                     ShowFileListDialog.FileListBox.SetSelect 0
  439.                 ENDIF
  440.  
  441.             CASE ShowFileListDialog.SelectAllButton.GetID()        
  442.                 ShowFileListDialog.StatusText.SetText "All files selected."
  443.                 ShowFileListDialog.SelectedFileListBox.SetSelect 0
  444.                 WHILE ShowFileListDialog.FileListBox.GetItemCount() > 0        'repeat while there are available files 
  445.                     ShowFileListDialog.SelectedFileListBox.AddItem ShowFileListDialog.FileListBox.GetItem(1)            'add first list item to selected files list
  446.                     ShowFileListDialog.FileListBox.RemoveItem 1                                                'remove first list item from available files list    
  447.                     ShowFileListDialog.SelectedDirectoryListBox.AddItem ShowFileListDialog.DirectoryListBox.GetItem(1)    'add first list item to selected directory list
  448.                     ShowFileListDialog.DirectoryListBox.RemoveItem 1                                            'remove first list item from available directory list
  449.                     ShowFileListDialog.FilesCountText.SetText ShowFileListDialog.FileListBox.GetItemCount()                'display number of available files
  450.                     ShowFileListDialog.SelectedFilesCountText.SetText ShowFileListDialog.SelectedFileListBox.GetItemCount()    'display number of selected files
  451.                 WEND
  452.  
  453.  
  454.             CASE ShowFileListDialog.DeselectAllButton.GetID()        
  455.                 ShowFileListDialog.StatusText.SetText "No files selected."
  456.                 ShowFileListDialog.FileListBox.SetSelect 0
  457.                 WHILE ShowFileListDialog.SelectedFileListBox.GetItemCount() > 0    'repeat while there are selected files
  458.                     ShowFileListDialog.FileListBox.AddItem ShowFileListDialog.SelectedFileListBox.GetItem(1)            'add first list item to FilesList
  459.                     ShowFileListDialog.SelectedFileListBox.RemoveItem 1                                        'remove first list item from selected files list
  460.                     ShowFileListDialog.DirectoryListBox.AddItem ShowFileListDialog.SelectedDirectoryListBox.GetItem(1)    'add first list item to available directory list
  461.                     ShowFileListDialog.SelectedDirectoryListBox.RemoveItem 1                                    'remove first list item from selected directory list
  462.                         ShowFileListDialog.FilesCountText.SetText ShowFileListDialog.FileListBox.GetItemCount()            'display number of available files
  463.                     ShowFileListDialog.SelectedFilesCountText.SetText ShowFileListDialog.SelectedFileListBox.GetItemCount()    'display number of selected files
  464.                 WEND
  465.  
  466.             CASE ShowFileListDialog.CancelButton.GetID()            
  467.                 ShowFileListDialog.closedialog DIALOG_RETURN_CANCEL    
  468.             CASE ShowFileListDialog.FileListBox.GetID()                    
  469.                  ShowFileListDialog.StatusText.SetText ShowFileListDialog.DirectoryListBox.GetItem(ShowFileListDialog.FileListBox.GetSelect())
  470.                 ShowFileListDialog.SelectedFileListBox.SetSelect 0
  471.             CASE ShowFileListDialog.SelectedFileListBox.GetID()            
  472.                  ShowFileListDialog.StatusText.SetText ShowFileListDialog.SelectedDirectoryListBox.GetItem(ShowFileListDialog.SelectedFileListBox.GetSelect())
  473.                 ShowFileListDialog.FileListBox.SetSelect 0
  474.         END SELECT
  475.         ShowFileListDialog.FilesCountText.SetText ShowFileListDialog.FileListBox.GetItemCount()                'display number of available files
  476.         ShowFileListDialog.SelectedFilesCountText.SetText ShowFileListDialog.SelectedFileListBox.GetItemCount()    'display number of selected files
  477.     ENDIF
  478.  
  479.     IF Event% = EVENT_DBL_MOUSE_CLICK THEN         
  480.         SELECT CASE ControlID%
  481.             CASE ShowFileListDialog.FileListBox.GetID()                    'files list
  482.                 indx% = ShowFileListDialog.FileListBox.GetSelect()                                    'get index of selection
  483.                 ShowFileListDialog.SelectedFileListBox.AddItem ShowFileListDialog.FileListBox.GetItem(indx%)    'add selection to SelectedFilesList
  484.                 ShowFileListDialog.FileListBox.RemoveItem indx%                                        'remove selection from available files list
  485.                 ShowFileListDialog.SelectedDirectoryListBox.AddItem ShowFileListDialog.DirectoryListBox.GetItem(indx%)    'add selection to selected path list
  486.                 ShowFileListDialog.DirectoryListBox.RemoveItem indx%                                        'remove selection from available paths list
  487.                 IF indx% > ShowFileListDialog.FileListBox.GetItemCount() THEN
  488.                     ShowFileListDialog.FileListBox.SetSelect indx%-1
  489.                 ELSE
  490.                     ShowFileListDialog.FileListBox.SetSelect indx%
  491.                 ENDIF
  492.  
  493.             CASE ShowFileListDialog.SelectedFileListBox.GetID()            'selected files list
  494.                 indx% = ShowFileListDialog.SelectedFileListBox.GetSelect()                                'get index of selection
  495.                 ShowFileListDialog.FileListBox.AddItem ShowFileListDialog.SelectedFileListBox.GetItem(indx%)    'add selection to FilesList
  496.                 ShowFileListDialog.SelectedFileListBox.RemoveItem indx%                                'remove selection from selected files list
  497.                 ShowFileListDialog.DirectoryListBox.AddItem ShowFileListDialog.SelectedDirectoryListBox.GetItem(indx%)    'add selection to available path list
  498.                 ShowFileListDialog.SelectedDirectoryListBox.RemoveItem indx%                                'remove selection from selected path list
  499.                 IF indx% > ShowFileListDialog.SelectedFileListBox.GetItemCount() THEN
  500.                     ShowFileListDialog.SelectedFileListBox.SetSelect indx%-1
  501.                 ELSE
  502.                     ShowFileListDialog.SelectedFileListBox.SetSelect indx%
  503.                 ENDIF
  504.  
  505.         END SELECT
  506.         ShowFileListDialog.FilesCountText.SetText ShowFileListDialog.FileListBox.GetItemCount()                'number of available files
  507.         ShowFileListDialog.SelectedFilesCountText.SetText ShowFileListDialog.SelectedFileListBox.GetItemCount()    'number of selected files
  508.     ENDIF
  509.     IF ShowFileListDialog.SelectedFileListBox.GetItemCount() = 0 THEN 
  510.         ShowFileListDialog.NextButton.Enable FALSE
  511.     ELSE
  512.         ShowFileListDialog.NextButton.Enable TRUE
  513.     ENDIF    
  514. END SUB
  515.  
  516.  
  517. ' *******************************************************************************
  518. ' GetFileList
  519. ' This subroutine recursively searches for files of the specified type, starting
  520. ' in the specified directory (SourceDir). The found files are displayed in the 
  521. ' File List dialog (files and paths separately).
  522. '
  523. ' PARAMS: BYVAL SourceDir$ - The directory at which to begin the search.
  524. '               FileExt$  - The type of file (extension) for which to search.
  525. ' *******************************************************************************
  526. SUB GetFileList(BYVAL SourceDir$, FileExt$)
  527.     'This section finds files of the type specified by FileExt in the directory specified by SourceDir
  528.     File$ = FINDFIRSTFOLDER(SourceDir$ & FileExt$, FILEATTR_READ_ONLY OR FILEATTR_HIDDEN OR FILEATTR_SYSTEM OR FILEATTR_ARCHIVE OR FILEATTR_NORMAL_FILE OR FILEATTR_TEMPORARY OR FILEATTR_COMPRESSED)
  529.     DO WHILE File$ <> ""
  530.         ShowFileListDialog.FileListBox.AddItem File$        'add file name to File drop-down list
  531.         ShowFileListDialog.DirectoryListBox.AddItem SourceDir$        'add file dir to Directory drop-down list
  532.         File$ = FINDNEXTFOLDER()
  533.     LOOP 
  534.  
  535.     'This section finds directories starting in the directory specified by SourceDir
  536.     File$ = FINDFIRSTFOLDER(SourceDir$ & "*.*", FILEATTR_FOLDER OR FILEATTR_READ_ONLY OR FILEATTR_HIDDEN OR FILEATTR_SYSTEM OR FILEATTR_ARCHIVE OR FILEATTR_NORMAL_FILE OR FILEATTR_TEMPORARY OR FILEATTR_COMPRESSED)
  537.     DO WHILE File$ <> ""    
  538.         IF File$ <> "." AND File$ <> ".." AND File$ <> SourceDir$ THEN
  539.             GetFileList SourceDir$ &  File$ & "\", FileExt$
  540.             
  541.             ' This next loop resets the FINDNEXTFOLDER function to the same place as it was before 
  542.             ' we recursed into ourselves.
  543.             SearchFile$ = FINDFIRSTFOLDER(SourceDir$ & "*.*", FILEATTR_FOLDER OR FILEATTR_READ_ONLY OR FILEATTR_HIDDEN OR FILEATTR_SYSTEM OR FILEATTR_ARCHIVE OR FILEATTR_NORMAL_FILE OR FILEATTR_TEMPORARY OR FILEATTR_COMPRESSED)
  544.             DO WHILE File$ <> SearchFile$
  545.                 SearchFile$ = FINDNEXTFOLDER()
  546.             LOOP
  547.         ENDIF
  548.         File$ = FINDNEXTFOLDER()
  549.     LOOP 
  550. END SUB
  551.  
  552.  
  553. ' **************************************************************************************
  554. ' ShowFinish
  555. ' This function displays the final dialog containing the list of successfully converted 
  556. ' publications as well as those that were not successfully converted.
  557. '
  558. ' RETURNS: ShowFinish AS INTEGER - Integer indicating dialog return value.
  559. ' **************************************************************************************
  560. FUNCTION ShowFinish%
  561. BEGIN DIALOG OBJECT ShowFinishDialog 290, 180, "Corel SCRIPT Converter", SUB ShowFinishDialogEventHandler
  562.     PUSHBUTTON  181, 160, 46, 14, .FinishButton, "&Finish"
  563.     CANCELBUTTON  234, 160, 46, 14, .CancelButton
  564.     PUSHBUTTON  135, 160, 46, 14, .BackButton, "< &Back"
  565.     LISTBOX  95, 25, 185, 75, .FileListBox
  566.     IMAGE  10, 10, 75, 130, .ShowFinishImage
  567.     TEXT  95, 10, 185, 12, .Text1, InfoText$
  568.     TEXT  95, 124, 185, 20, .Text3, "Click Finish, then sit back and allow your scripts to be converted for you."
  569.     GROUPBOX  10, 150, 270, 5, .LineGroupBox
  570.     TEXT  95, 107, 185, 12, .StatusText, ""
  571. END DIALOG
  572.  
  573.     IF SelectedFilesCount = 1 THEN 
  574.         InfoText$ = "The " & SelectedFilesCount & " file listed below has been selected for conversion:"
  575.     ELSE
  576.         InfoText$ = "The " & SelectedFilesCount & " files listed below have been selected for conversion:"
  577.     ENDIF
  578.     
  579.     ShowFinishDialog.SetStyle STYLE_INVISIBLE
  580.     ShowFinishDialog.ShowFinishImage.SetImage "#Step3BMP"
  581.     ShowFinishDialog.ShowFinishImage.SetStyle STYLE_IMAGE_CENTERED
  582.     ShowFinishDialog.StatusText.SetStyle STYLE_SUNKEN
  583.  
  584.     ShowFinishRet% = Dialog(ShowFinishDialog)
  585.     SELECT CASE ShowFinishRet%
  586.         CASE DIALOG_RETURN_CANCEL     
  587.             STOP
  588.         CASE DIALOG_RETURN_NEXT      
  589.             ShowFinishDialog.SetVisible FALSE
  590.             ShowFinish = 1
  591.         CASE DIALOG_RETURN_BACK 
  592.             ShowFinish = -1
  593.     END SELECT
  594. END FUNCTION
  595.  
  596.  
  597. ' *******************************************************************************
  598. ' ShowFinishDialogEventHandler
  599. ' This subroutine responds to user interface with the finish dialog.
  600. ' PARAMS: BYVAL ControlID% - Integer indicating the dialog control that is 
  601. '                            generating a dialog event.
  602. '        BYVAL Event% - Integer indicating the dialog event that has occurred.
  603. ' *******************************************************************************
  604. SUB ShowFinishDialogEventHandler(BYVAL ControlID%, BYVAL Event%)
  605.     IF Event% = EVENT_INITIALIZATION THEN         
  606.         ShowFinishDialog.FileListBox.SetArray SelectedFiles$
  607.         ShowFinishDialog.StatusText.SetText SelectedDirs(1)
  608.         ShowFinishDialog.SetStyle STYLE_VISIBLE
  609.     ENDIF
  610.  
  611.     IF Event% = EVENT_MOUSE_CLICK THEN     
  612.         SELECT CASE ControlID%
  613.             CASE ShowFinishDialog.FinishButton.GetID()
  614.                 ShowFinishDialog.CloseDialog DIALOG_RETURN_NEXT
  615.             CASE ShowFinishDialog.BackButton.GetID()
  616.                 ShowFinishDialog.CloseDialog DIALOG_RETURN_BACK
  617.             CASE ShowFinishDialog.CancelButton.GetID()
  618.                 ShowFinishDialog.CloseDialog DIALOG_RETURN_CANCEL
  619.             CASE ShowFinishDialog.FileListBox.GetID()
  620.                 ShowFinishDialog.StatusText.SetText SelectedDirs(ShowFinishDialog.FileListBox.GetSelect())
  621.         END SELECT
  622.     ENDIF
  623. END SUB
  624.  
  625.  
  626. ' **************************************************************************************
  627. ' ShowSummary
  628. ' This function displays the final dialog containing the list of successfully converted 
  629. ' scripts as well as those that were not successfully converted.
  630. '
  631. ' RETURNS: ShowSummary AS INTEGER - Integer indicating dialog return value.
  632. ' **************************************************************************************
  633. FUNCTION ShowSummary
  634. BEGIN DIALOG OBJECT SummaryDialog 290, 180, "Corel SCRIPT Converter", SUB SummaryDialogEventHandler
  635.     LISTBOX  10, 50, 120, 85, .SuccessfulDirectoryList
  636.     LISTBOX  160, 50, 120, 85, .UnsuccessfulDirectoryList
  637.     PUSHBUTTON  181, 160, 46, 14, .DoneButton, "&Done"
  638.     PUSHBUTTON  135, 160, 46, 14, .BackButton, "< &Back"
  639.     CANCELBUTTON  234, 160, 46, 14, .CancelButton
  640.     LISTBOX  10, 50, 120, 85, .SuccessfulFilesList
  641.     LISTBOX  160, 50, 120, 85, .UnsuccessfulFilesList
  642.     TEXT  10, 37, 80, 12, .Text4, "Converted files:"
  643.     TEXT  164, 37, 88, 12, .AvailableFiles, "Unconverted files:"
  644.     TEXT  10, 3, 267, 20, .Text3, "The conversion is now complete. Any files that were not converted are shown in the Unconverted files list."
  645.     TEXT  115, 37, 15, 10, .SuccessfulFilesCountText, ""
  646.     TEXT  265, 37, 15, 12, .UnsuccessfulFilesCountText, ""
  647.     TEXT  10, 138, 270, 12, .StatusText, ""
  648.     GROUPBOX  10, 150, 270, 5, .LineGroupBox
  649.     TEXT  10, 24, 268, 12, .Text7, "You can double-click a file in the Converted Files list to open it in Corel SCRIPT."
  650. END DIALOG
  651.  
  652.     SummaryDialog.StatusText.SetStyle STYLE_SUNKEN
  653.     
  654.     FinishRet%=DIALOG(SummaryDialog)
  655.     SELECT CASE FinishRet%
  656.         CASE DIALOG_RETURN_CANCEL    
  657.             STOP
  658.         CASE DIALOG_RETURN_NEXT        
  659.             SummaryDialog.SetVisible FALSE
  660.             STOP
  661.         CASE DIALOG_RETURN_BACK         
  662.             ShowSummary = -4
  663.         END SELECT
  664.     
  665. END FUNCTION
  666.  
  667. ' *******************************************************************************
  668. ' ShowSummaryDialogEventHandler
  669. ' This subroutine responds to user interface with the finish dialog.
  670. ' PARAMS: BYVAL ControlID% - Integer indicating the dialog control that is 
  671. '                            generating a dialog event.
  672. '        BYVAL Event% - Integer indicating the dialog event that has occurred.
  673. ' *******************************************************************************
  674. SUB SummaryDialogEventHandler(BYVAL ControlID%, BYVAL Event%)
  675.     IF Event% = EVENT_INITIALIZATION THEN         
  676.         SummaryDialog.SuccessfulDirectoryList.SetStyle STYLE_INVISIBLE
  677.         SummaryDialog.UnsuccessfulDirectoryList.SetStyle STYLE_INVISIBLE
  678.         SummaryDialog.SuccessfulFilesCountText.SetStyle STYLE_RIGHT_JUSTIFY
  679.         SummaryDialog.UnsuccessfulFilesCountText.SetStyle STYLE_RIGHT_JUSTIFY
  680.         SummaryDialog.SetStyle STYLE_VISIBLE
  681.         SummaryDialog.CancelButton.Enable FALSE
  682.         FOR i% = 1 TO SuccessfulFilesCount%
  683.             first% = 1
  684.             pos% = 1
  685.             NameLength = LEN(SuccessfulFiles(i%))
  686.             DO WHILE first <> 0
  687.                 first% = INSTR(SuccessfulFiles(i%), "\", first%)
  688.                 IF first% <> 0 THEN
  689.                     pos% = first%
  690.                     first% = first% + 1
  691.                 END IF
  692.             LOOP
  693.             SummaryDialog.SuccessfulFilesList.AddItem RIGHT(SuccessfulFiles(i%), NameLength - pos%) 
  694.             SummaryDialog.SuccessfulDirectoryList.AddItem SuccessfulFiles(i%)
  695.         NEXT i%
  696.  
  697.         FOR i% = 1 TO UnsuccessfulFilesCount%
  698.             first% = 1
  699.             pos% = 1
  700.             NameLength = LEN(UnsuccessfulFiles(i%))
  701.             DO WHILE first <> 0
  702.                 first% = INSTR(UnsuccessfulFiles(i%), "\", first%)
  703.                 IF first% <> 0 THEN
  704.                     pos% = first%
  705.                     first% = first% + 1
  706.                 END IF
  707.             LOOP
  708.             SummaryDialog.UnsuccessfulFilesList.AddItem RIGHT(UnsuccessfulFiles(i%), NameLength - pos%) 
  709.             SummaryDialog.UnsuccessfulDirectoryList.AddItem UnsuccessfulFiles(i%)
  710.         NEXT i%
  711.         SummaryDialog.SuccessfulFilesCountText.SetText SummaryDialog.SuccessfulFilesList.GetItemCount()
  712.         SummaryDialog.UnsuccessfulFilesCountText.SetText SummaryDialog.UnsuccessfulFilesList.GetItemCount()
  713.     ENDIF
  714.  
  715.     IF Event% = EVENT_MOUSE_CLICK THEN         
  716.         SELECT CASE ControlID%
  717.  
  718.             CASE SummaryDialog.DoneButton.GetID()        
  719.                 SummaryDialog.closedialog DIALOG_RETURN_NEXT
  720.  
  721.             CASE SummaryDialog.BackButton.GetID()        
  722.                 SummaryDialog.closedialog DIALOG_RETURN_BACK
  723.  
  724.             CASE SummaryDialog.CancelButton.GetID()        
  725.                 SummaryDialog.closedialog DIALOG_RETURN_CANCEL
  726.  
  727.             CASE SummaryDialog.SuccessfulFilesList.GetID()        
  728.                 SummaryDialog.StatusText.SetText SummaryDialog.SuccessfulDirectoryList.GetItem(SummaryDialog.SuccessfulFilesList.GetSelect())
  729.                 SummaryDialog.UnsuccessfulFilesList.SetSelect 0
  730.  
  731.             CASE SummaryDialog.UnsuccessfulFilesList.GetID()        
  732.                 SummaryDialog.StatusText.SetText SummaryDialog.UnsuccessfulDirectoryList.GetItem(SummaryDialog.UnsuccessfulFilesList.GetSelect())
  733.                 SummaryDialog.SuccessfulFilesList.SetSelect 0
  734.         END SELECT
  735.     ENDIF
  736.  
  737.     IF Event% = EVENT_DBL_MOUSE_CLICK THEN         
  738.         SELECT CASE ControlID%
  739.             CASE SummaryDialog.SuccessfulFilesList.GetID()            
  740.                 LaunchScript SummaryDialog.SuccessfulDirectoryList.GetItem(SummaryDialog.SuccessfulFilesList.GetSelect())
  741.         END SELECT
  742.     ENDIF
  743.  
  744. END SUB
  745.  
  746.  
  747. ' *******************************************************************************
  748. ' LaunchScript
  749. ' This function launches the Corel SCRIPT Editor and loads the specified file.
  750. '
  751. ' PARAMS: ScriptFileName$ - The complete name (including path) of the script 
  752. '                           to open.
  753. ' *******************************************************************************
  754. SUB LaunchScript(ScriptFileName$)
  755.     WITHOBJECT "CorelScript.Automation.8"
  756.         .FileOpen ScriptFileName$    
  757.     END WITHOBJECT
  758. END SUB
  759.  
  760.  
  761.  
  762. ' *******************************************************************************
  763. ' ConvertFile
  764. ' This subroutine opens the specified Corel SCRIPT file, convert it to the 
  765. ' version 8 format, then saves it to the specified location.
  766. '
  767. ' PARAMS: ScriptFile$ - The name of the Corel SCRIPT file to be converted.
  768. ' *******************************************************************************
  769. SUB ConvertFile(ScriptFile$)
  770. ON ERROR GOTO ErrorHandler
  771. ObjString$ = "WITHOBJECT"
  772. RegString$ = "SOFTWARE\Corel\Corel"
  773.  
  774.     TempFile$ = GETTEMPFOLDER() & "ScpTemp.txt"
  775.  
  776.     OPEN ScriptFile$ FOR INPUT AS 1    'READ from script file
  777.     OPEN TempFile$ FOR OUTPUT AS 2    'WRITE to temporary text file
  778.  
  779.     'check the entire file - line by line
  780.     WHILE NOT EOF(1) 
  781.         LINE INPUT #1, CurrentLine$
  782.         'check for automation object 
  783.         IF ObjString$ = MID(LTRIM(CurrentLine$), 1,10) THEN 'MESSAGE CurrentLine$
  784.             CurrentLine$ = EditObject(CurrentLine$)
  785.         ENDIF
  786.         'check for registry queries
  787.         IF INSTR(CurrentLine$, RegString$) <> 0 THEN
  788.             CurrentLine$ = EditRegistry$(CurrentLine$)
  789.         ENDIF
  790.         PRINT #2, CurrentLine$
  791.     WEND 
  792.     
  793.     CLOSE                        'close all open files 
  794.     COPY TempFile$, ScriptFile$, 0    'replace script with modified file
  795.     KILL TempFile$                    'remove temporary text file
  796.     SuccessfulFilesCount% = SuccessfulFilesCount% + 1                    'conversion successful
  797.     SuccessfulFiles(SuccessfulFilesCount%) = ScriptFile$                'add pub name to SuccessfilFiles list
  798.  
  799. SubEnd:
  800. EXIT SUB
  801.  
  802. ErrorHandler:
  803.     CLOSE            'close any open files 
  804.     KILL TempFile$        'remove temporary text file
  805.     UnsuccessfulFilesCount% = UnsuccessfulFilesCount% + 1        'conversion not successful
  806.     UnsuccessfulFiles$(UnsuccessfulFilesCount%) = FileName$    'add script name to UnsuccessfulFiles list
  807.     RESUME AT SubEnd
  808. END SUB
  809.  
  810.  
  811. ' *******************************************************************************
  812. ' EditObject
  813. ' This function updates the automation object number from 7 to 8
  814. '    WITHOBJECT "CorelVentura.Automation.7" --> WITHOBJECT "CorelVentura.Automation.8"
  815. '    WITHOBJECT "CorelPhotoPaint.Automation.7" --> WITHOBJECT "CorelPhotoPaint.Automation.8"
  816. '    WITHOBJECT "CorelDraw.Automation.7" --> WITHOBJECT "CorelDraw.Automation.8"
  817. '
  818. ' PARAMS: AppString$ - The application's automation object string.
  819. ' *******************************************************************************
  820. FUNCTION EditObject$(AppString$)
  821.     IF INSTR(AppString$, ".7") THEN
  822.         MID(AppString$, LEN(AppString$)-1, 1) = "8"
  823.     ENDIF
  824.     EditObject$ = AppString$
  825. END FUNCTION
  826.  
  827.  
  828. ' *******************************************************************************
  829. ' EditObject
  830. ' This function updates the registry key specifying the version number from 7 to 8
  831. '    "SOFTWARE\Corel\Corel *\7.0" --> "SOFTWARE\Corel\Corel *\8.0"
  832.  
  833. ' PARAMS: InputString$ - The registry key string.
  834. ' *******************************************************************************
  835. FUNCTION EditRegistry$(InputString$)
  836.     Pos% = INSTR(InputString$, "7.0")
  837.     IF Pos% THEN
  838.         MID(InputString$, Pos% , 3) = "8.0"
  839.     ENDIF
  840.     EditRegistry$ = InputString$
  841. END FUNCTION
  842.  
  843.  
  844.