home *** CD-ROM | disk | FTP | other *** search
Wrap
REM Converts scripts from version 7.0 to 8.0[CorelSCRIPT 8] REM CSCConverter.csc February 5, 1998 REM ⌐ 1998 Corel Corporation. All rights reserved. REM ********************************************************************** REM This script updates version 7 scripts to version 8. REM The automation object number is updated in any WITHOBJECT statements: REM WITHOBJECT "CorelVentura.Automation.7" --> WITHOBJECT "CorelVentura.Automation.8" REM WITHOBJECT "CorelPhotoPaint.Automation.7" --> WITHOBJECT "CorelPhotoPaint.Automation.8" REM WITHOBJECT "CorelDraw.Automation.7" --> WITHOBJECT "CorelDraw.Automation.8" REM IF you used the Script constants as defined in ScpConst.csi, then REM you need not worry about your WITHOBJECT statement within your scripts. REM You will only have to update the automation object string in ScpConst.csi. REM This script also updates the registry key specifying the version number from 7 to 8. REM "SOFTWARE\Corel\Corel *\7.0" --> "SOFTWARE\Corel\Corel *\8.0" REM ********************************************************************** ' Create a temporary folder to provide a path for the include files ' -this enables the include files to be located #addfol "..\..\Scripts" #include "ScpConst.csi" #include "VPConst.csi" ' Embed bitmaps if script is to be compiled into exe or csb formats ' -this will eliminate the need to include these files #ADDRESBMP Step2BMP "Bitmaps\Step2BMP.bmp" #ADDRESBMP Step3BMP "Bitmaps\Step3BMP.bmp" 'Constants for Dialog Return Values GLOBAL CONST DIALOG_RETURN_CANCEL% = 2 GLOBAL CONST DIALOG_RETURN_NEXT% = 3 GLOBAL CONST DIALOG_RETURN_BACK% = 4 GLOBAL CONST DIALOG_RETURN_BROWSE% = 5 GLOBAL CONST MAX_FILES% = 10 GLOBAL CONST MAX_FILE_EXT% = 2 '/////FUNCTION & SUBROUTINE DECLARATIONS///////////////////////////////////////////////// DECLARE SUB RegQuery() DECLARE FUNCTION ShowIntro%() DECLARE FUNCTION GetSourceDir%() DECLARE SUB GetFileList(BYVAL SourceDir$, FileExt$) DECLARE FUNCTION ShowFileList%() DECLARE FUNCTION ShowFinish%() DECLARE FUNCTION ShowSummary DECLARE SUB ConvertFile(ScriptFile$) DECLARE FUNCTION EditObject$(ObjString$) DECLARE FUNCTION EditRegistry$(InputString$) DECLARE SUB LaunchScript(ScriptFileName$) '/////GLOBAL VARIABLES ////////////////////////////////////////////////////////// GLOBAL VenturaRoot$ 'root directory where Ventura is installed GLOBAL SourceDir$ 'directory in which to start the search for files GLOBAL DestinationDir$ 'directory in which to save the converted files GLOBAL FileExt$ 'file extension used by GetFileList sub FileExt$ = "*.CSC" GLOBAL AvailableFiles$(MAX_FILES) 'list of files available for selection GLOBAL AvailableDirs$(MAX_FILES) 'list of directories corresponding to available files GLOBAL AvailableFilesCount% 'number of files available for selection GLOBAL SelectedFiles$(MAX_FILES) 'list of file names selected for conversion GLOBAL SelectedDirs$(MAX_FILES) 'list of directories corresponding to selected files GLOBAL SelectedFilesCount% 'number of files selected GLOBAL UnsuccessfulFiles$(MAX_FILES) 'list of files not successfully converted GLOBAL UnsuccessfulFilesCount% 'number of files not successfully converted GLOBAL SuccessfulFiles$(MAX_FILES) 'list of files successfully converted GLOBAL SuccessfulFilesCount% 'number of files successfully converted '////// LOCAL VARIABLES ////////////////////////////////////////////////////////////////////////////// CONST MAXSTEP% = 6 'maximum number of pages in the Wizard DIM DialogReturn% 'identifies user's selection for next step in Wizard DIM NextStep% 'specifies which page appears next in the Wizard ' ************************************************************************************** ' MAIN ' ************************************************************************************** ON ERROR GOTO ErrorHandler RegQuery 'get root directory where Ventura is installed SourceDir$= VenturaRoot$ & "\Ventura\Scripts" 'initialize source directory to Ventura\Samples dirextory 'this section controls traversal through the Wizard pages NextStep% = 1 DO SELECT CASE NextStep% CASE 1: DialogReturn% = ShowIntro() 'show Intro dialog CASE 2: DialogReturn% = GetSourceDir() 'get source directory CASE 3: DialogReturn% = ShowFileList() 'select files to convert CASE 4: DialogReturn% = ShowFinish() 'show list of selected scripts CASE 5: BEGINWAITCURSOR REDIM SuccessfulFiles$(SelectedFilesCount%) 'dimension list for successful conversion REDIM UnsuccessfulFiles$(SelectedFilesCount%) 'dimension list for unsuccessful conversion FOR i% = 1 TO SelectedFilesCount% 'convert selected scripts ConvertFile SelectedDirs$(i%) & SelectedFiles$(i%) NEXT i% ENDWAITCURSOR CASE 6: DialogReturn% = ShowSummary() 'show summary of conversion END SELECT NextStep% = NextStep%+ DialogReturn% LOOP UNTIL NextStep% = MAXSTEP + 1 ExitScript: STOP ErrorHandler: SELECT CASE ErrNum CASE 800 MESSAGE "FATAL ERROR" & CHR(13) & "Script will now exit." RESUME AT ExitScript CASE ELSE MESSAGE "ERROR: " & STR(ErrNum) & CHR(13) & "Script will now exit." RESUME AT ExitScript END SELECT ' ******************************************************************************* ' RegQuery ' This subroutine queries the Registry to determine the root directory where ' Ventura is installed. ' ******************************************************************************* SUB RegQuery ON ERROR GOTO ErrorHandler 'get Ventura config directory VentDir$ = REGISTRYQUERY(HKEY_LOCAL_MACHINE,VENTURA_REGQUERY_CONST,"ConfigDir") 'isolate Ventura root directory from Ventura config directory first% = 1 pos% = 1 DO WHILE first <> 0 first = INSTR(VentDir$, "\", first ) IF first <> 0 THEN pos = first first = first + 1 END IF LOOP VenturaRoot$ = LEFT(VentDir$, pos - 1) 'root directory where Ventura is installed EXIT SUB ErrorHandler: MESSAGE "Error reading registry:" & CHR(13) & RegString$ ErrNum = 800 END SUB ' ******************************************************************************* ' ShowIntro ' This function displays the introduction dialog. ' ' PARAMS: None ' ' RETURNS: ShowIntro AS INTEGER - Integer indicating dialog return value. ' ******************************************************************************* FUNCTION ShowIntro% BEGIN DIALOG OBJECT IntroDialog 290, 180, "Corel SCRIPT Converter", SUB IntroDialogEventHandler PUSHBUTTON 181, 160, 46, 14, .NextButton, "&Next >" CANCELBUTTON 234, 160, 46, 14, .CancelButton PUSHBUTTON 135, 160, 46, 14, .BackButton, "< &Back" TEXT 95, 10, 185, 20, .Text2, "This Wizard converts scripts from previous versions of Corel SCRIPT to the version 8 format." TEXT 95, 40, 185, 12, .Text3, "To begin converting your scripts, click Next." IMAGE 10, 10, 75, 130, .IntroImage GROUPBOX 10, 150, 270, 5, .LineGroupBox END DIALOG IntroDialog.IntroImage.SetImage "#Step2BMP" IntroDialog.IntroImage.SetStyle STYLE_IMAGE_CENTERED IntroRet%=DIALOG(IntroDialog) IF IntroRet% = DIALOG_RETURN_CANCEL THEN STOP IF IntroRet% = DIALOG_RETURN_NEXT THEN ShowIntro = 1 END FUNCTION ' ******************************************************************************* ' IntroDialogEventHandler ' This subroutine responds to user interface with the introduction dialog. ' ' PARAMS: BYVAL ControlID% - Integer indicating the dialog control that is ' generating a dialog event. ' BYVAL Event% - Integer indicating the dialog event that has occurred. ' ******************************************************************************* SUB IntroDialogEventHandler(BYVAL ControlID%, BYVAL Event%) IF Event% = EVENT_INITIALIZATION THEN IntroDialog.BackButton.Enable FALSE ENDIF IF Event% = EVENT_MOUSE_CLICK THEN SELECT CASE ControlID% CASE IntroDialog.NextButton.GetID() IntroDialog.CloseDialog DIALOG_RETURN_NEXT CASE IntroDialog.CancelButton.GetID() IntroDialog.CloseDialog DIALOG_RETURN_CANCEL END SELECT ENDIF END FUNCTION ' ******************************************************************************* ' GetSourceDir ' This function prompts the user for the directory at which to begin the search ' for files, as well as the type of file (ie. chp or pub) to use and the ' maximum size of embedded pictures. ' ' PARAMS: None ' RETURNS: GetSourceDir AS INTEGER - Integer indicating dialog return value. ' ' COMMENTS: A valid souce directory is required to continue to next dialog. ' ******************************************************************************* FUNCTION GetSourceDir BEGIN DIALOG OBJECT SourceDialog 290, 180, "Corel SCRIPT Converter", SUB SourceDialogEventHandler TEXTBOX 100, 47, 175, 13, .SourceDirectory PUSHBUTTON 229, 66, 46, 14, .BrowseButton, "B&rowse..." PUSHBUTTON 135, 160, 46, 14, .BackButton, "< &Back" PUSHBUTTON 181, 160, 46, 14, .NextButton, "&Next >" CANCELBUTTON 234, 160, 46, 14, .CancelButton TEXT 95, 11, 185, 16, .Text1, "What is the location of the scripts you want to convert?" IMAGE 10, 10, 75, 130, .SourceImage GROUPBOX 10, 150, 270, 5, .LineGroupBox GROUPBOX 95, 34, 185, 52, .FilesGroupBox, "Location of files:" END DIALOG SourceDialog.SourceImage.SetImage "#Step2BMP" SourceDialog.SourceImage.SetStyle STYLE_IMAGE_CENTERED SourceRet%=DIALOG(SourceDialog) SELECT CASE SourceRet% CASE DIALOG_RETURN_CANCEL STOP CASE DIALOG_RETURN_NEXT IF INSTR(SourceDir$, "\", LEN(SourceDir$)) = 0 THEN SourceDir$ = SourceDir$ & "\" ENDIF GetSourceDir = 1 CASE DIALOG_RETURN_BACK SETCURRFOLDER SourceDir GetSourceDir = -1 END SELECT END FUNCTION ' ******************************************************************************* ' SourceDialogEventHandler ' This subroutine responds to user interface with the source directory dialog. ' ' PARAMS: BYVAL ControlID% - Integer indicating the dialog control that is ' generating a dialog event. ' BYVAL Event% - Integer indicating the dialog event that has occurred. ' ******************************************************************************* SUB SourceDialogEventHandler(BYVAL ControlID%, BYVAL Event%) IF Event% = EVENT_INITIALIZATION THEN SourceDialog.SourceDirectory.SetText SourceDir$ ENDIF IF Event% = EVENT_CHANGE_IN_CONTENT THEN SELECT CASE ControlID% CASE SourceDialog.SourceDirectory.GetID() SourceDir$ = SourceDialog.SourceDirectory.GetText() END SELECT ENDIF IF Event% = EVENT_MOUSE_CLICK THEN SELECT CASE ControlID% CASE SourceDialog.NextButton.GetID() SourceDialog.closedialog DIALOG_RETURN_NEXT CASE SourceDialog.BackButton.GetID() SourceDialog.closedialog DIALOG_RETURN_BACK CASE SourceDialog.CancelButton.GetID() SourceDialog.closedialog DIALOG_RETURN_CANCEL CASE SourceDialog.BrowseButton.GetID() NewSourceDir$ = GETFOLDER(SourceDir$) IF NewSourceDir$ = "" THEN SourceDialog.SourceDirectory.SetText SourceDir$ ELSE SourceDialog.SourceDirectory.SetText NewSourceDir$ SourceDir$ = NewSourceDir$ ENDIF END SELECT ENDIF SourceDir$ = SourceDialog.SourceDirectory.gettext() IF SourceDir$ = "" THEN SourceDialog.NextButton.Enable FALSE ELSE SourceDialog.NextButton.Enable TRUE ENDIF END SUB ' ******************************************************************************* ' ShowFileList ' This function displays a list of available files of the specified type starting ' at the specified location. ' ' PARAMS: None ' ' RETURNS: ShowFileList AS INTEGER - Integer indicating dialog return value. ' ******************************************************************************* FUNCTION ShowFileList BEGIN DIALOG OBJECT ShowFileListDialog 290, 180, "Corel SCRIPT Converter", SUB FileListDialogEventHandler LISTBOX 10, 25, 100, 107, .FileListBox PUSHBUTTON 122, 33, 46, 14, .SelectButton, "&Select >>" PUSHBUTTON 122, 49, 46, 14, .DeselectButton, "<< &Deselect" PUSHBUTTON 123, 95, 46, 14, .SelectAllButton, "Select &All" PUSHBUTTON 123, 112, 46, 14, .DeselectAllButton, "D&eselect All" LISTBOX 180, 25, 100, 107, .SelectedFileListBox PUSHBUTTON 135, 160, 46, 14, .BackButton, "< &Back" PUSHBUTTON 181, 160, 46, 14, .NextButton, "&Next >" CANCELBUTTON 234, 160, 46, 14, .CancelButton TEXT 10, 2, 269, 11, .Text2, "Select the files you wish to convert." TEXT 10, 14, 56, 10, .Text4, "Available files:" TEXT 88, 14, 20, 10, .FilesCountText, "" TEXT 180, 14, 61, 10, .Text5, "Selected files:" TEXT 258, 14, 20, 10, .SelectedFilesCountText, "" TEXT 10, 136, 270, 12, .StatusText, "No files selected" LISTBOX 10, 25, 100, 107, .DirectoryListBox LISTBOX 180, 25, 100, 107, .SelectedDirectoryListBox GROUPBOX 10, 150, 270, 5, .LineGroupBox END DIALOG ShowFileListDialog.SetStyle STYLE_INVISIBLE ShowFileListDialog.StatusText.SetStyle STYLE_SUNKEN ShowFileListRet% = DIALOG(ShowFileListDialog) SELECT CASE ShowFileListRet% CASE DIALOG_RETURN_CANCEL STOP CASE DIALOG_RETURN_NEXT ShowFileList = 1 CASE DIALOG_RETURN_BACK ShowFileList = -1 END SELECT END FUNCTION ' ******************************************************************************* ' FileListDialogEventHandler ' This subroutine responds to user interface with the file list dialog. ' ' PARAMS: BYVAL ControlID% - Integer indicating the dialog control that is ' generating a dialog event. ' BYVAL Event% - Integer indicating the dialog event that has occurred. ' ******************************************************************************* SUB FileListDialogEventHandler(BYVAL ControlID%, BYVAL Event%) IF Event% = EVENT_INITIALIZATION THEN ShowFileListDialog.DirectoryListBox.SetStyle STYLE_INVISIBLE 'hide directory list box (for tracking files - user doesn't need to see this) ShowFileListDialog.SelectedDirectoryListBox.SetStyle STYLE_INVISIBLE 'hide selected directory list box (for tracking files - user doesn't need to see this) ShowFileListDialog.FilesCountText.SetStyle STYLE_RIGHT_JUSTIFY 'right justify text displaying file count ShowFileListDialog.SelectedFilesCountText.SetStyle STYLE_RIGHT_JUSTIFY 'right justify text displaying selected files count 'disable NEXT button until file(s) have been selected IF ShowFileListDialog.SelectedFileListBox.GetItemCount() = 0 THEN ShowFileListDialog.NextButton.Enable FALSE ELSE ShowFileListDialog.NextButton.Enable TRUE ENDIF 'IF files have already been selected, display same list IF SelectedFilesCount > 0 THEN ShowFileListDialog.FileListBox.SetArray AvailableFiles$ 'display available files list in Available Files listbox ShowFileListDialog.DirectoryListBox.SetArray AvailableDirs$ 'display available dirs list in Avaialable Dirs listbox ShowFileListDialog.SelectedFileListBox.SetArray SelectedFiles$ 'display selected files list in Selected Files listbox ShowFileListDialog.SelectedDirectoryListBox.SetArray SelectedDirs$ 'display selected dirs list in Selected Dirs listbox 'get and display list of files (with extension FileExt$) starting in Source directory ELSE GetFileList SourceDir$, FileExt$ 'get file list ShowFileListDialog.FileListBox.SetSelect 1 'give focus to first element in file list box ShowFileListDialog.StatusText.SetText ShowFileListDialog.DirectoryListBox.GetItem(1) 'set status text to first item in file list ShowFileListDialog.FilesCountText.SetText ShowFileListDialog.FileListBox.GetItemCount() 'set file count to number of available files ShowFileListDialog.SelectedFilesCountText.SetText ShowFileListDialog.SelectedFileListBox.GetItemCount() 'set selected files count to number of selected files ENDIF ShowFileListDialog.SetStyle STYLE_VISIBLE ENDIF IF Event% = EVENT_MOUSE_CLICK THEN SELECT CASE ControlID% CASE ShowFileListDialog.NextButton.GetID() 'create list of selected files and directories SelectedFilesCount% = ShowFileListDialog.SelectedFileListBox.GetItemCount() REDIM SelectedFiles$(SelectedFilesCount%) 'redimension array to accomodate all selected files REDIM SelectedDirs$(SelectedFilesCount%) 'redimension array to accomodate all selected directories FOR i% = 1 TO SelectedFilesCount% 'FOR all items in selected files list SelectedFiles$(i%) = ShowFileListDialog.SelectedFileListBox.GetItem(i%) 'add item to file list SelectedDirs$(i%) = ShowFileListDialog.SelectedDirectoryListBox.GetItem(i%)'add item to directory list NEXT i% 'create list of available files and directories AvailableFilesCount% = ShowFileListDialog.FileListBox.GetItemCount() REDIM AvailableFiles$(AvailableFilesCount) 'redimension array to accomodate all available files REDIM AvailableDirs$(AvailableFilesCount) 'redimension array to accomodate all available directories FOR i% = 1 TO AvailableFilesCount% 'FOR all items in avialable files list AvailableFiles$(i%) = ShowFileListDialog.FileListBox.GetItem(i%) 'add item to file list AvailableDirs$(i%) = ShowFileListDialog.DirectoryListBox.GetItem(i%) 'add item to directory list NEXT i% ShowFileListDialog.closedialog DIALOG_RETURN_NEXT CASE ShowFileListDialog.BackButton.GetID() ShowFileListDialog.closedialog DIALOG_RETURN_BACK CASE ShowFileListDialog.SelectButton.GetID() indx% = ShowFileListDialog.FileListBox.GetSelect() 'get index of current selection IF indx%=0 THEN 'no files selected, display appropriate message IF ShowFileListDialog.FileListBox.GetItemCount() = 0 THEN MESSAGE "There are no files available for selection." ELSE MESSAGE "Please select a file from the available files list." ENDIF ELSE 'valid selection, add current selection to selected files list ShowFileListDialog.SelectedFileListBox.AddItem ShowFileListDialog.FileListBox.GetItem(indx%) 'add current selection to selected files list ShowFileListDialog.FileListBox.RemoveItem indx% 'remove current selection from available files list ShowFileListDialog.SelectedDirectoryListBox.AddItem ShowFileListDialog.DirectoryListBox.GetItem(indx%) 'add current selection to selected directory list ShowFileListDialog.DirectoryListBox.RemoveItem indx% 'remove current selection from available directory list IF indx% > ShowFileListDialog.FileListBox.GetItemCount() THEN 'IF current selection is not the last ShowFileListDialog.FileListBox.SetSelect indx%-1 'set focus to previous item ELSE ShowFileListDialog.FileListBox.SetSelect indx% 'ELSE set focus to current selection ENDIF ShowFileListDialog.StatusText.SetText ShowFileListDialog.DirectoryListBox.GetItem(ShowFileListDialog.FileListBox.GetSelect()) ShowFileListDialog.SelectedFileListBox.SetSelect 0 ENDIF CASE ShowFileListDialog.DeselectButton.GetID() indx% = ShowFileListDialog.SelectedFileListBox.GetSelect() 'get index of current selection IF indx%=0 THEN 'no files selected, display appropriate message IF ShowFileListDialog.SelectedFileListBox.GetItemCount() = 0 THEN MESSAGE "There are no files available for deselection" ELSE MESSAGE "Please select a file from the selected files list." ENDIF ELSE 'valid selection, remove current selection from selected files list ShowFileListDialog.FileListBox.AddItem ShowFileListDialog.SelectedFileListBox.GetItem(indx%) 'add current selection to available files list ShowFileListDialog.SelectedFileListBox.RemoveItem indx% 'remove current selection from selected files list ShowFileListDialog.DirectoryListBox.AddItem ShowFileListDialog.SelectedDirectoryListBox.GetItem(indx%) 'add current selection to available directory list ShowFileListDialog.SelectedDirectoryListBox.RemoveItem indx% 'remove current selection from selected directory list IF indx% > ShowFileListDialog.SelectedFileListBox.GetItemCount() THEN 'IF current selection is not the last ShowFileListDialog.SelectedFileListBox.SetSelect indx%-1 'set focus to previous item ELSE ShowFileListDialog.SelectedFileListBox.SetSelect indx% 'ELSE set focus to current selection ENDIF ShowFileListDialog.StatusText.SetText ShowFileListDialog.SelectedDirectoryListBox.GetItem(ShowFileListDialog.SelectedFileListBox.GetSelect()) ShowFileListDialog.FileListBox.SetSelect 0 ENDIF CASE ShowFileListDialog.SelectAllButton.GetID() ShowFileListDialog.StatusText.SetText "All files selected." ShowFileListDialog.SelectedFileListBox.SetSelect 0 WHILE ShowFileListDialog.FileListBox.GetItemCount() > 0 'repeat while there are available files ShowFileListDialog.SelectedFileListBox.AddItem ShowFileListDialog.FileListBox.GetItem(1) 'add first list item to selected files list ShowFileListDialog.FileListBox.RemoveItem 1 'remove first list item from available files list ShowFileListDialog.SelectedDirectoryListBox.AddItem ShowFileListDialog.DirectoryListBox.GetItem(1) 'add first list item to selected directory list ShowFileListDialog.DirectoryListBox.RemoveItem 1 'remove first list item from available directory list ShowFileListDialog.FilesCountText.SetText ShowFileListDialog.FileListBox.GetItemCount() 'display number of available files ShowFileListDialog.SelectedFilesCountText.SetText ShowFileListDialog.SelectedFileListBox.GetItemCount() 'display number of selected files WEND CASE ShowFileListDialog.DeselectAllButton.GetID() ShowFileListDialog.StatusText.SetText "No files selected." ShowFileListDialog.FileListBox.SetSelect 0 WHILE ShowFileListDialog.SelectedFileListBox.GetItemCount() > 0 'repeat while there are selected files ShowFileListDialog.FileListBox.AddItem ShowFileListDialog.SelectedFileListBox.GetItem(1) 'add first list item to FilesList ShowFileListDialog.SelectedFileListBox.RemoveItem 1 'remove first list item from selected files list ShowFileListDialog.DirectoryListBox.AddItem ShowFileListDialog.SelectedDirectoryListBox.GetItem(1) 'add first list item to available directory list ShowFileListDialog.SelectedDirectoryListBox.RemoveItem 1 'remove first list item from selected directory list ShowFileListDialog.FilesCountText.SetText ShowFileListDialog.FileListBox.GetItemCount() 'display number of available files ShowFileListDialog.SelectedFilesCountText.SetText ShowFileListDialog.SelectedFileListBox.GetItemCount() 'display number of selected files WEND CASE ShowFileListDialog.CancelButton.GetID() ShowFileListDialog.closedialog DIALOG_RETURN_CANCEL CASE ShowFileListDialog.FileListBox.GetID() ShowFileListDialog.StatusText.SetText ShowFileListDialog.DirectoryListBox.GetItem(ShowFileListDialog.FileListBox.GetSelect()) ShowFileListDialog.SelectedFileListBox.SetSelect 0 CASE ShowFileListDialog.SelectedFileListBox.GetID() ShowFileListDialog.StatusText.SetText ShowFileListDialog.SelectedDirectoryListBox.GetItem(ShowFileListDialog.SelectedFileListBox.GetSelect()) ShowFileListDialog.FileListBox.SetSelect 0 END SELECT ShowFileListDialog.FilesCountText.SetText ShowFileListDialog.FileListBox.GetItemCount() 'display number of available files ShowFileListDialog.SelectedFilesCountText.SetText ShowFileListDialog.SelectedFileListBox.GetItemCount() 'display number of selected files ENDIF IF Event% = EVENT_DBL_MOUSE_CLICK THEN SELECT CASE ControlID% CASE ShowFileListDialog.FileListBox.GetID() 'files list indx% = ShowFileListDialog.FileListBox.GetSelect() 'get index of selection ShowFileListDialog.SelectedFileListBox.AddItem ShowFileListDialog.FileListBox.GetItem(indx%) 'add selection to SelectedFilesList ShowFileListDialog.FileListBox.RemoveItem indx% 'remove selection from available files list ShowFileListDialog.SelectedDirectoryListBox.AddItem ShowFileListDialog.DirectoryListBox.GetItem(indx%) 'add selection to selected path list ShowFileListDialog.DirectoryListBox.RemoveItem indx% 'remove selection from available paths list IF indx% > ShowFileListDialog.FileListBox.GetItemCount() THEN ShowFileListDialog.FileListBox.SetSelect indx%-1 ELSE ShowFileListDialog.FileListBox.SetSelect indx% ENDIF CASE ShowFileListDialog.SelectedFileListBox.GetID() 'selected files list indx% = ShowFileListDialog.SelectedFileListBox.GetSelect() 'get index of selection ShowFileListDialog.FileListBox.AddItem ShowFileListDialog.SelectedFileListBox.GetItem(indx%) 'add selection to FilesList ShowFileListDialog.SelectedFileListBox.RemoveItem indx% 'remove selection from selected files list ShowFileListDialog.DirectoryListBox.AddItem ShowFileListDialog.SelectedDirectoryListBox.GetItem(indx%) 'add selection to available path list ShowFileListDialog.SelectedDirectoryListBox.RemoveItem indx% 'remove selection from selected path list IF indx% > ShowFileListDialog.SelectedFileListBox.GetItemCount() THEN ShowFileListDialog.SelectedFileListBox.SetSelect indx%-1 ELSE ShowFileListDialog.SelectedFileListBox.SetSelect indx% ENDIF END SELECT ShowFileListDialog.FilesCountText.SetText ShowFileListDialog.FileListBox.GetItemCount() 'number of available files ShowFileListDialog.SelectedFilesCountText.SetText ShowFileListDialog.SelectedFileListBox.GetItemCount() 'number of selected files ENDIF IF ShowFileListDialog.SelectedFileListBox.GetItemCount() = 0 THEN ShowFileListDialog.NextButton.Enable FALSE ELSE ShowFileListDialog.NextButton.Enable TRUE ENDIF END SUB ' ******************************************************************************* ' GetFileList ' This subroutine recursively searches for files of the specified type, starting ' in the specified directory (SourceDir). The found files are displayed in the ' File List dialog (files and paths separately). ' ' PARAMS: BYVAL SourceDir$ - The directory at which to begin the search. ' FileExt$ - The type of file (extension) for which to search. ' ******************************************************************************* SUB GetFileList(BYVAL SourceDir$, FileExt$) 'This section finds files of the type specified by FileExt in the directory specified by SourceDir 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) DO WHILE File$ <> "" ShowFileListDialog.FileListBox.AddItem File$ 'add file name to File drop-down list ShowFileListDialog.DirectoryListBox.AddItem SourceDir$ 'add file dir to Directory drop-down list File$ = FINDNEXTFOLDER() LOOP 'This section finds directories starting in the directory specified by SourceDir 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) DO WHILE File$ <> "" IF File$ <> "." AND File$ <> ".." AND File$ <> SourceDir$ THEN GetFileList SourceDir$ & File$ & "\", FileExt$ ' This next loop resets the FINDNEXTFOLDER function to the same place as it was before ' we recursed into ourselves. 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) DO WHILE File$ <> SearchFile$ SearchFile$ = FINDNEXTFOLDER() LOOP ENDIF File$ = FINDNEXTFOLDER() LOOP END SUB ' ************************************************************************************** ' ShowFinish ' This function displays the final dialog containing the list of successfully converted ' publications as well as those that were not successfully converted. ' ' RETURNS: ShowFinish AS INTEGER - Integer indicating dialog return value. ' ************************************************************************************** FUNCTION ShowFinish% BEGIN DIALOG OBJECT ShowFinishDialog 290, 180, "Corel SCRIPT Converter", SUB ShowFinishDialogEventHandler PUSHBUTTON 181, 160, 46, 14, .FinishButton, "&Finish" CANCELBUTTON 234, 160, 46, 14, .CancelButton PUSHBUTTON 135, 160, 46, 14, .BackButton, "< &Back" LISTBOX 95, 25, 185, 75, .FileListBox IMAGE 10, 10, 75, 130, .ShowFinishImage TEXT 95, 10, 185, 12, .Text1, InfoText$ TEXT 95, 124, 185, 20, .Text3, "Click Finish, then sit back and allow your scripts to be converted for you." GROUPBOX 10, 150, 270, 5, .LineGroupBox TEXT 95, 107, 185, 12, .StatusText, "" END DIALOG IF SelectedFilesCount = 1 THEN InfoText$ = "The " & SelectedFilesCount & " file listed below has been selected for conversion:" ELSE InfoText$ = "The " & SelectedFilesCount & " files listed below have been selected for conversion:" ENDIF ShowFinishDialog.SetStyle STYLE_INVISIBLE ShowFinishDialog.ShowFinishImage.SetImage "#Step3BMP" ShowFinishDialog.ShowFinishImage.SetStyle STYLE_IMAGE_CENTERED ShowFinishDialog.StatusText.SetStyle STYLE_SUNKEN ShowFinishRet% = Dialog(ShowFinishDialog) SELECT CASE ShowFinishRet% CASE DIALOG_RETURN_CANCEL STOP CASE DIALOG_RETURN_NEXT ShowFinishDialog.SetVisible FALSE ShowFinish = 1 CASE DIALOG_RETURN_BACK ShowFinish = -1 END SELECT END FUNCTION ' ******************************************************************************* ' ShowFinishDialogEventHandler ' This subroutine responds to user interface with the finish dialog. ' ' PARAMS: BYVAL ControlID% - Integer indicating the dialog control that is ' generating a dialog event. ' BYVAL Event% - Integer indicating the dialog event that has occurred. ' ******************************************************************************* SUB ShowFinishDialogEventHandler(BYVAL ControlID%, BYVAL Event%) IF Event% = EVENT_INITIALIZATION THEN ShowFinishDialog.FileListBox.SetArray SelectedFiles$ ShowFinishDialog.StatusText.SetText SelectedDirs(1) ShowFinishDialog.SetStyle STYLE_VISIBLE ENDIF IF Event% = EVENT_MOUSE_CLICK THEN SELECT CASE ControlID% CASE ShowFinishDialog.FinishButton.GetID() ShowFinishDialog.CloseDialog DIALOG_RETURN_NEXT CASE ShowFinishDialog.BackButton.GetID() ShowFinishDialog.CloseDialog DIALOG_RETURN_BACK CASE ShowFinishDialog.CancelButton.GetID() ShowFinishDialog.CloseDialog DIALOG_RETURN_CANCEL CASE ShowFinishDialog.FileListBox.GetID() ShowFinishDialog.StatusText.SetText SelectedDirs(ShowFinishDialog.FileListBox.GetSelect()) END SELECT ENDIF END SUB ' ************************************************************************************** ' ShowSummary ' This function displays the final dialog containing the list of successfully converted ' scripts as well as those that were not successfully converted. ' ' RETURNS: ShowSummary AS INTEGER - Integer indicating dialog return value. ' ************************************************************************************** FUNCTION ShowSummary BEGIN DIALOG OBJECT SummaryDialog 290, 180, "Corel SCRIPT Converter", SUB SummaryDialogEventHandler LISTBOX 10, 50, 120, 85, .SuccessfulDirectoryList LISTBOX 160, 50, 120, 85, .UnsuccessfulDirectoryList PUSHBUTTON 181, 160, 46, 14, .DoneButton, "&Done" PUSHBUTTON 135, 160, 46, 14, .BackButton, "< &Back" CANCELBUTTON 234, 160, 46, 14, .CancelButton LISTBOX 10, 50, 120, 85, .SuccessfulFilesList LISTBOX 160, 50, 120, 85, .UnsuccessfulFilesList TEXT 10, 37, 80, 12, .Text4, "Converted files:" TEXT 164, 37, 88, 12, .AvailableFiles, "Unconverted files:" TEXT 10, 3, 267, 20, .Text3, "The conversion is now complete. Any files that were not converted are shown in the Unconverted files list." TEXT 115, 37, 15, 10, .SuccessfulFilesCountText, "" TEXT 265, 37, 15, 12, .UnsuccessfulFilesCountText, "" TEXT 10, 138, 270, 12, .StatusText, "" GROUPBOX 10, 150, 270, 5, .LineGroupBox TEXT 10, 24, 268, 12, .Text7, "You can double-click a file in the Converted Files list to open it in Corel SCRIPT." END DIALOG SummaryDialog.StatusText.SetStyle STYLE_SUNKEN FinishRet%=DIALOG(SummaryDialog) SELECT CASE FinishRet% CASE DIALOG_RETURN_CANCEL STOP CASE DIALOG_RETURN_NEXT SummaryDialog.SetVisible FALSE STOP CASE DIALOG_RETURN_BACK ShowSummary = -4 END SELECT END FUNCTION ' ******************************************************************************* ' ShowSummaryDialogEventHandler ' This subroutine responds to user interface with the finish dialog. ' ' PARAMS: BYVAL ControlID% - Integer indicating the dialog control that is ' generating a dialog event. ' BYVAL Event% - Integer indicating the dialog event that has occurred. ' ******************************************************************************* SUB SummaryDialogEventHandler(BYVAL ControlID%, BYVAL Event%) IF Event% = EVENT_INITIALIZATION THEN SummaryDialog.SuccessfulDirectoryList.SetStyle STYLE_INVISIBLE SummaryDialog.UnsuccessfulDirectoryList.SetStyle STYLE_INVISIBLE SummaryDialog.SuccessfulFilesCountText.SetStyle STYLE_RIGHT_JUSTIFY SummaryDialog.UnsuccessfulFilesCountText.SetStyle STYLE_RIGHT_JUSTIFY SummaryDialog.SetStyle STYLE_VISIBLE SummaryDialog.CancelButton.Enable FALSE FOR i% = 1 TO SuccessfulFilesCount% first% = 1 pos% = 1 NameLength = LEN(SuccessfulFiles(i%)) DO WHILE first <> 0 first% = INSTR(SuccessfulFiles(i%), "\", first%) IF first% <> 0 THEN pos% = first% first% = first% + 1 END IF LOOP SummaryDialog.SuccessfulFilesList.AddItem RIGHT(SuccessfulFiles(i%), NameLength - pos%) SummaryDialog.SuccessfulDirectoryList.AddItem SuccessfulFiles(i%) NEXT i% FOR i% = 1 TO UnsuccessfulFilesCount% first% = 1 pos% = 1 NameLength = LEN(UnsuccessfulFiles(i%)) DO WHILE first <> 0 first% = INSTR(UnsuccessfulFiles(i%), "\", first%) IF first% <> 0 THEN pos% = first% first% = first% + 1 END IF LOOP SummaryDialog.UnsuccessfulFilesList.AddItem RIGHT(UnsuccessfulFiles(i%), NameLength - pos%) SummaryDialog.UnsuccessfulDirectoryList.AddItem UnsuccessfulFiles(i%) NEXT i% SummaryDialog.SuccessfulFilesCountText.SetText SummaryDialog.SuccessfulFilesList.GetItemCount() SummaryDialog.UnsuccessfulFilesCountText.SetText SummaryDialog.UnsuccessfulFilesList.GetItemCount() ENDIF IF Event% = EVENT_MOUSE_CLICK THEN SELECT CASE ControlID% CASE SummaryDialog.DoneButton.GetID() SummaryDialog.closedialog DIALOG_RETURN_NEXT CASE SummaryDialog.BackButton.GetID() SummaryDialog.closedialog DIALOG_RETURN_BACK CASE SummaryDialog.CancelButton.GetID() SummaryDialog.closedialog DIALOG_RETURN_CANCEL CASE SummaryDialog.SuccessfulFilesList.GetID() SummaryDialog.StatusText.SetText SummaryDialog.SuccessfulDirectoryList.GetItem(SummaryDialog.SuccessfulFilesList.GetSelect()) SummaryDialog.UnsuccessfulFilesList.SetSelect 0 CASE SummaryDialog.UnsuccessfulFilesList.GetID() SummaryDialog.StatusText.SetText SummaryDialog.UnsuccessfulDirectoryList.GetItem(SummaryDialog.UnsuccessfulFilesList.GetSelect()) SummaryDialog.SuccessfulFilesList.SetSelect 0 END SELECT ENDIF IF Event% = EVENT_DBL_MOUSE_CLICK THEN SELECT CASE ControlID% CASE SummaryDialog.SuccessfulFilesList.GetID() LaunchScript SummaryDialog.SuccessfulDirectoryList.GetItem(SummaryDialog.SuccessfulFilesList.GetSelect()) END SELECT ENDIF END SUB ' ******************************************************************************* ' LaunchScript ' This function launches the Corel SCRIPT Editor and loads the specified file. ' ' PARAMS: ScriptFileName$ - The complete name (including path) of the script ' to open. ' ******************************************************************************* SUB LaunchScript(ScriptFileName$) WITHOBJECT "CorelScript.Automation.8" .FileOpen ScriptFileName$ END WITHOBJECT END SUB ' ******************************************************************************* ' ConvertFile ' This subroutine opens the specified Corel SCRIPT file, convert it to the ' version 8 format, then saves it to the specified location. ' ' PARAMS: ScriptFile$ - The name of the Corel SCRIPT file to be converted. ' ******************************************************************************* SUB ConvertFile(ScriptFile$) ON ERROR GOTO ErrorHandler ObjString$ = "WITHOBJECT" RegString$ = "SOFTWARE\Corel\Corel" TempFile$ = GETTEMPFOLDER() & "ScpTemp.txt" OPEN ScriptFile$ FOR INPUT AS 1 'READ from script file OPEN TempFile$ FOR OUTPUT AS 2 'WRITE to temporary text file 'check the entire file - line by line WHILE NOT EOF(1) LINE INPUT #1, CurrentLine$ 'check for automation object IF ObjString$ = MID(LTRIM(CurrentLine$), 1,10) THEN 'MESSAGE CurrentLine$ CurrentLine$ = EditObject(CurrentLine$) ENDIF 'check for registry queries IF INSTR(CurrentLine$, RegString$) <> 0 THEN CurrentLine$ = EditRegistry$(CurrentLine$) ENDIF PRINT #2, CurrentLine$ WEND CLOSE 'close all open files COPY TempFile$, ScriptFile$, 0 'replace script with modified file KILL TempFile$ 'remove temporary text file SuccessfulFilesCount% = SuccessfulFilesCount% + 1 'conversion successful SuccessfulFiles(SuccessfulFilesCount%) = ScriptFile$ 'add pub name to SuccessfilFiles list SubEnd: EXIT SUB ErrorHandler: CLOSE 'close any open files KILL TempFile$ 'remove temporary text file UnsuccessfulFilesCount% = UnsuccessfulFilesCount% + 1 'conversion not successful UnsuccessfulFiles$(UnsuccessfulFilesCount%) = FileName$ 'add script name to UnsuccessfulFiles list RESUME AT SubEnd END SUB ' ******************************************************************************* ' EditObject ' This function updates the automation object number from 7 to 8 ' WITHOBJECT "CorelVentura.Automation.7" --> WITHOBJECT "CorelVentura.Automation.8" ' WITHOBJECT "CorelPhotoPaint.Automation.7" --> WITHOBJECT "CorelPhotoPaint.Automation.8" ' WITHOBJECT "CorelDraw.Automation.7" --> WITHOBJECT "CorelDraw.Automation.8" ' ' PARAMS: AppString$ - The application's automation object string. ' ******************************************************************************* FUNCTION EditObject$(AppString$) IF INSTR(AppString$, ".7") THEN MID(AppString$, LEN(AppString$)-1, 1) = "8" ENDIF EditObject$ = AppString$ END FUNCTION ' ******************************************************************************* ' EditObject ' This function updates the registry key specifying the version number from 7 to 8 ' "SOFTWARE\Corel\Corel *\7.0" --> "SOFTWARE\Corel\Corel *\8.0" ' PARAMS: InputString$ - The registry key string. ' ******************************************************************************* FUNCTION EditRegistry$(InputString$) Pos% = INSTR(InputString$, "7.0") IF Pos% THEN MID(InputString$, Pos% , 3) = "8.0" ENDIF EditRegistry$ = InputString$ END FUNCTION