home *** CD-ROM | disk | FTP | other *** search
/ Computer Buyer 1998 October / dpcb1098.iso / Business / Ventura / Ventura / Scripts / EnableExportOnSave.csc < prev    next >
Text File  |  1998-07-07  |  25KB  |  568 lines

  1. REM Sets Export On Save for all text files in current pub[CorelSCRIPT 8]
  2. REM EnableExportOnSave.csc  March, 1998
  3. REM ⌐ 1998 Corel Corporation. All rights reserved.
  4.  
  5. REM **************************************************************************************
  6. REM This script identifies all text files in the current publication. A list of all files 
  7. REM is then presented to the user to select those files to be set to export on save. The 
  8. REM specified files are set to export on save, names changed as required, and the 
  9. REM publication is saved to implement the new settings.
  10. REM **************************************************************************************
  11.  
  12. ' Create a temporary folder to provide a path for the include files
  13. '  -this enables the include files to be located 
  14. #addfol "..\..\Scripts"
  15. #include "ScpConst.csi"
  16. #include "VPConst.csi"
  17.  
  18. ' Embed bitmaps if script is to be compiled into exe or csb formats
  19. ' -this will eliminate the need to include these files
  20. #ADDRESBMP IntroBMP "Bitmaps\IntroBMP.bmp"
  21.  
  22. 'Constants for Dialog Return Values
  23. GLOBAL CONST DIALOG_RETURN_CANCEL% = 2
  24. GLOBAL CONST DIALOG_RETURN_NEXT% = 3
  25. GLOBAL CONST DIALOG_RETURN_BACK% = 4
  26. GLOBAL CONST DIALOG_RETURN_BROWSE% = 5
  27.  
  28. 'Constants for file specifications
  29. GLOBAL CONST MAX_FILES% = 100                'number of text files in publication
  30. GLOBAL CONST EXPORT_FORMAT_TYPES% = 4        'number of export format types
  31.  
  32. '/////FUNCTION & SUBROUTINE DECLARATIONS/////////////////////////////////////////////////
  33. DECLARE SUB RegQuery()
  34. DECLARE SUB CreateFolder(Folder$)
  35. DECLARE SUB SetToExport()
  36. DECLARE FUNCTION ShowIntro%()
  37. DECLARE FUNCTION ShowFileList%()
  38. DECLARE FUNCTION GetCurrentPub$()
  39. DECLARE FUNCTION GetPublicationDir$(CurrentPublication$)
  40.  
  41. '/////GLOBAL VARIABLES ///////////////////////////////////////////////////////////////////
  42. GLOBAL VenturaRoot$                        'Root directory of Ventura from registry
  43. GLOBAL SelectedFiles$(MAX_FILES)            'array of selected files to set to Export on Save
  44. GLOBAL SelectedChapters$(MAX_FILES)        'array of selected chapters corresponding to selected files
  45. GLOBAL SelectedFilesCount%                'number of files selected to set to Export on Save
  46. GLOBAL CurrentDir$                        'name of the current directory
  47.  
  48. GLOBAL ExportFilters%(EXPORT_FORMAT_TYPES)    'array of export filter types (integers corresponding to the format type)
  49. ExportFilters%(1) = FILTER_VEN_ANSI        'ANSI Text    
  50. ExportFilters%(2) = FILTER_VEN_ASCII        'ASCII Text
  51. ExportFilters%(3) = FILTER_VEN_ASCII_8BIT    'ASCII 8-bit Text
  52. ExportFilters%(4) = FILTER_RTF            'Rich Text Format
  53.  
  54. GLOBAL ExportExtensions$(EXPORT_FORMAT_TYPES)'array of export filter extensions
  55. ExportExtensions$(1) = "TXT"                'ANSI Text
  56. ExportExtensions$(2) = "TXT"                'ASCII Text
  57. ExportExtensions$(3) = "TXT"                'ASCII 8-bit Text
  58. ExportExtensions$(4) = "RTF"                'Rich Text Format
  59.  
  60. GLOBAL ExportFormats$(EXPORT_FORMAT_TYPES)    'array of export filter formats (these are the strings used by the drop-down list of filter types)
  61. ExportFormats$(1) = "ANSI Text (*.TXT)"        'ANSI Text
  62. ExportFormats$(2) = "ASCII Text (*.TXT)"    'ASCII Text
  63. ExportFormats$(3) = "ASCII 8-bit Text (*.TXT)"    'ASCII 8-bit Text
  64. ExportFormats$(4) = "Rich Text Format (*.RTF)"    'Rich Text Format
  65.  
  66. GLOBAL FilterSelection%                    'index corresponding to filter selection
  67. FilterSelection% = 1                    'initialize filter selection to first element (ie. ANSI text)
  68.  
  69. '/////LOCAL DECLARATIONS//////////////////////////////////////////////////////////////////
  70. CONST MAXSTEP% = 2        'maximum number of pages in the Wizard
  71. DIM DialogReturn%        'identifies user's selection for next step in Wizard
  72. DIM NextStep%            'specifies which page appears next in the Wizard
  73.  
  74.  
  75. '///// MAIN ////////////////////////////////////////////////////////////////////////////////
  76. ON ERROR GOTO ErrorHandler
  77. RegQuery                                    'get root directory where Ventura is installed
  78. CurrentPub$ = GetCurrentPub$()                'get name of current (active) publication
  79. CurrentDir$ = GetPublicationDir$(CurrentPub$)    'get directory of current (active) publication
  80.  
  81. 'this section controls traversal through the Wizard pages
  82. NextStep% = 1
  83. DO
  84.     SELECT CASE NextStep%
  85.         CASE 1: DialogReturn%  = ShowIntro()    'display Intro dialog
  86.         CASE 2: DialogReturn%  = ShowFileList()    'display File list dialog
  87.     END SELECT
  88.     NextStep% = NextStep% + DialogReturn% 
  89. LOOP UNTIL NextStep% = MAXSTEP + 1
  90.  
  91. SetToExport        'set selected files to export on save
  92.  
  93. ExitScript:
  94. STOP
  95.  
  96. ErrorHandler:
  97. SELECT CASE ErrNum
  98.     CASE 800
  99.         MESSAGE "FATAL ERROR" & CHR(13) & "Script will now exit."
  100.         RESUME AT ExitScript
  101.     CASE ELSE
  102.         MESSAGE "ERROR: " & STR(ErrNum) & CHR(13) & "Script will now exit."
  103.         RESUME AT ExitScript
  104.     END SELECT
  105.  
  106.  
  107. ' *******************************************************************************
  108. ' RegQuery
  109. ' This subroutine queries the Registry to determine the root directory where 
  110. ' Ventura is installed.
  111. ' *******************************************************************************
  112. SUB RegQuery
  113. ON ERROR GOTO ErrorHandler
  114.  
  115.     'get Ventura config directory
  116.     VentDir$ = REGISTRYQUERY(HKEY_LOCAL_MACHINE,VENTURA_REGQUERY_CONST,"ConfigDir")     
  117.     
  118.     'isolate Ventura root directory from Ventura config directory
  119.     first% = 1
  120.     pos% = 1
  121.     DO WHILE first <> 0
  122.         first = INSTR(VentDir$, "\", first )
  123.         IF first <> 0 THEN
  124.             pos = first
  125.             first = first + 1
  126.         END IF
  127.     LOOP
  128.     VenturaRoot$ = LEFT(VentDir$, pos - 1)     'root directory where Ventura is installed
  129.  
  130. EXIT SUB
  131. ErrorHandler:
  132.     MESSAGE "Error reading registry:" & CHR(13) & RegString$
  133.     ErrNum = 800
  134. END SUB
  135.  
  136.  
  137. ' *******************************************************************************
  138. ' GetCurrentPub
  139. ' This function queries VENTURA for the name of the current publication. IF no 
  140. ' publication is open, the user is prompted to open one before continuing.
  141. ' PARAMS: None
  142. '
  143. ' RETURNS: GetCurrentPub$ - the name of the current publication.
  144. ' *******************************************************************************
  145. FUNCTION GetCurrentPub$()
  146.     BEGINWAITCURSOR
  147.     WITHOBJECT OBJECT_VENTURA8
  148.     ENDWAITCURSOR
  149.         IF .CountWindows() = 0 THEN
  150.             PubMsg$ = "You need an open publication to run this script." & CHR(13) & "Open one now?"
  151.             MsgVal% = MESSAGEBOX(PubMsg$, "WARNING", MB_YES_NO OR MB_STOP_ICON)
  152.             IF MsgVal% = MSG_YES THEN         'Yes, open a pub
  153.                 SETCURRFOLDER VenturaRoot$
  154.                 PubName$ = GETFILEBOX("Publication files (*.VP*)|*.VP*", , , ,"*.vp*", VenturaRoot$ & "\Ventura\Samples" )
  155.                 IF PubName$ <> "" THEN
  156.                     .SetVisible TRUE
  157.                     .FileOpen PubName$, , TRUE, 1, TRUE, FALSE
  158.                 ELSE
  159.                     STOP
  160.                 ENDIF
  161.             ELSE
  162.                 STOP
  163.             ENDIF
  164.         ENDIF
  165.         GetCurrentPub$ = .PublicationName()
  166.     END WITHOBJECT
  167. END FUNCTION
  168.  
  169.  
  170. ' *********************************************************************************
  171. ' GetPublicationDir
  172. ' This function separates the directory from the name of the specified publication.
  173. '
  174. ' PARAMS: CurrentPublication$ - the publication from which to obtain the directory.
  175. '
  176. ' RETURN: GetPublicationDir$ - the directory that the specified pub resides in.
  177. ' *********************************************************************************
  178. FUNCTION GetPublicationDir$(CurrentPublication$)
  179.     'IF name doesn't contain a directory, default to Ventura root directory
  180.     NoDir% = INSTR(CurrentPublication$, "\", 1)
  181.     IF NoDir% = 0 THEN 
  182.         GetPublicationDir$ = VenturaRoot$ & "\Ventura\Samples"
  183.     ELSE
  184.         first% = 1
  185.         pos% = 1
  186.         WHILE first% <> 0
  187.             first% = INSTR(CurrentPublication$, "\", first%)
  188.             IF first% <> 0 THEN
  189.                 pos% = first%
  190.                 first% = first% + 1
  191.             ENDIF
  192.         WEND
  193.         GetPublicationDir$ = LEFT(CurrentPublication$, pos% - 1) 
  194.     ENDIF
  195. END FUNCTION
  196.  
  197.  
  198. ' *******************************************************************************
  199. ' ShowIntro
  200. ' This function displays the introduction dialog.
  201. ' PARAMS: None
  202. '
  203. ' RETURNS: ShowIntro AS INTEGER - Integer indicating dialog return value.
  204. ' *******************************************************************************
  205. FUNCTION ShowIntro%
  206. BEGIN DIALOG OBJECT IntroDialog 290, 180, "Set Files to Export On Save", SUB IntroDialogEventHandler
  207.     PUSHBUTTON  181, 160, 46, 14, .NextButton, "&Next >"
  208.     CANCELBUTTON  234, 160, 46, 14, .CancelButton
  209.     PUSHBUTTON  135, 160, 46, 14, .BackButton, "< &Back"
  210.     TEXT  95, 10, 189, 20, .Text2, "This Wizard guides you through the steps necessary to set all text files to Export on Save."
  211.     TEXT  95, 40, 185, 20, .Text3, "Specify a directory and select a format in which to save the exported files."
  212.     IMAGE  10, 10, 75, 130, .IntroImage
  213.     GROUPBOX  10, 150, 270, 5, .LineGroupBox
  214.     DDLISTBOX  140, 120, 140, 59, .FormatDDListBox
  215.     TEXT  95, 122, 43, 12, .Text4, "&Text Format:"
  216.     TEXT  95, 78, 30, 12, .Text5, "&Directory:"
  217.     TEXTBOX  140, 75, 140, 13, .DirectoryTextBox
  218.     PUSHBUTTON  234, 92, 46, 14, .BrowseButton, "B&rowse"
  219. END DIALOG
  220.  
  221.     IntroDialog.SetStyle STYLE_INVISIBLE
  222.     IntroDialog.IntroImage.SetImage "#IntroBMP"
  223.     IntroDialog.IntroImage.SetStyle STYLE_IMAGE_CENTERED
  224.  
  225.     IntroRet%=DIALOG(IntroDialog)
  226.     IF IntroRet% = DIALOG_RETURN_CANCEL THEN STOP            
  227.     IF IntroRet% = DIALOG_RETURN_NEXT THEN 
  228.         FilterSelection% = IntroDialog.FormatDDListBox.GetSelect()
  229.         ShowIntro = 1        
  230.     ENDIF
  231. END FUNCTION
  232.  
  233.  
  234. ' *******************************************************************************
  235. ' IntroDialogEventHandler
  236. ' This subroutine responds to user interface with the introduction dialog.
  237. ' PARAMS: BYVAL ControlID% - Integer indicating the dialog control that is 
  238. '                            generating a dialog event.
  239. '        BYVAL Event% - Integer indicating the dialog event that has occurred.
  240. ' *******************************************************************************
  241. SUB IntroDialogEventHandler(BYVAL ControlID%, BYVAL Event%)
  242. DIM FolderStatus AS BOOLEAN
  243.     IF Event% = EVENT_INITIALIZATION THEN         
  244.         IntroDialog.BackButton.Enable FALSE 
  245.         IntroDialog.SetStyle STYLE_VISIBLE
  246.         IntroDialog.DirectoryTextBox.SetText CurrentDir$
  247.         IntroDialog.FormatDDListBox.SetArray ExportFormats$
  248.         IntroDialog.FormatDDListBox.SetSelect FilterSelection%
  249.     ENDIF
  250.  
  251.     IF Event% = EVENT_CHANGE_IN_CONTENT THEN         
  252.         CurrentDir$ = IntroDialog.DirectoryTextBox.GetText() 
  253.     ENDIF
  254.  
  255.     IF Event% = EVENT_MOUSE_CLICK THEN 
  256.         SELECT CASE ControlID%
  257.             CASE IntroDialog.NextButton.GetID()
  258.                 CurrentDir$ = IntroDialog.DirectoryTextBox.GetText() 
  259.                 FolderStatus = MKFOLDER(CurrentDir$)    
  260.                 IF FolderStatus = FALSE THEN         
  261.                     IntroDialog.CloseDialog DIALOG_RETURN_NEXT
  262.                 ELSE
  263.                     CreateFolder CurrentDir$
  264.                     IntroDialog.CloseDialog DIALOG_RETURN_NEXT
  265.                 ENDIF        
  266.  
  267.             CASE IntroDialog.CancelButton.GetID()
  268.                 IntroDialog.CloseDialog DIALOG_RETURN_CANCEL
  269.  
  270.             CASE IntroDialog.BrowseButton.GetID()
  271.                 NewFolder$ = GETFOLDER(CurrentDir$)
  272.                 IF NewFolder$ <> "" THEN CurrentDir$ = NewFolder$
  273.                 IntroDialog.DirectoryTextBox.SetText CurrentDir$
  274.  
  275.             CASE IntroDialog.FormatDDListBox.GetID()
  276.                 FilterSelection% = IntroDialog.FormatDDListBox.GetSelect()
  277.  
  278.         END SELECT
  279.     ENDIF
  280. END SUB
  281.  
  282.  
  283. ' *******************************************************************************
  284. ' ShowFileList
  285. ' This function displays the list of available files (FileList).
  286. ' PARAMS: None
  287. '
  288. ' RETURNS: ShowIntro AS INTEGER - Integer indicating dialog return value.
  289. ' *******************************************************************************
  290. FUNCTION ShowFileList
  291. BEGIN DIALOG OBJECT ShowFileListDialog 290, 180, "VENTURA File Export Wizard", SUB FileListDialogEventHandler     '"Corel VENTURA Conversion Wizard - Done"
  292.     LISTBOX  10, 25, 100, 107, .FilesListBox
  293.     PUSHBUTTON  122, 33, 46, 14, .SelectButton, "&Select >>"
  294.     PUSHBUTTON  122, 49, 46, 14, .DeselectButton, "<< &Deselect"
  295.     PUSHBUTTON  123, 95, 46, 14, .SelectAllButton, "Select &All"
  296.     PUSHBUTTON  123, 112, 46, 14, .DeselectAllButton, "D&eselect All"
  297.     LISTBOX  180, 26, 100, 107, .SelectedFilesListBox
  298.     PUSHBUTTON  135, 160, 46, 14, .BackButton, "< &Back"
  299.     PUSHBUTTON  181, 160, 46, 14, .NextButton, "&Finish"
  300.     CANCELBUTTON  234, 160, 46, 14, .CancelButton
  301.     LISTBOX  180, 27, 100, 107, .SelectedChaptersListBox
  302.     TEXT  10, 2, 269, 11, .Text2, "Select the files you wish to set to Export on Save."
  303.     TEXT  10, 14, 56, 10, .Text4, "Available files:"
  304.     TEXT  88, 14, 20, 10, .FilesCountText, ""
  305.     TEXT  180, 14, 61, 10, .Text5, "Selected files:"
  306.     TEXT  258, 14, 20, 10, .SelectedFilesCountText, ""
  307.     LISTBOX  10, 25, 100, 107, .ChapterListBox
  308.     TEXT  10, 136, 270, 12, .StatusText, "No files selected"
  309.     GROUPBOX  10, 150, 270, 5, .LineGroupBox
  310. END DIALOG
  311.     ShowFileListDialog.SetStyle STYLE_INVISIBLE
  312.     ShowFileListDialog.StatusText.SetStyle STYLE_SUNKEN
  313.     ShowFileListRet% = DIALOG(ShowFileListDialog)
  314.     
  315.     SELECT CASE ShowFileListRet%
  316.         CASE DIALOG_RETURN_CANCEL        
  317.             STOP
  318.         CASE DIALOG_RETURN_NEXT        
  319.             ShowFileList = 1
  320.         CASE DIALOG_RETURN_BACK         
  321.             ShowFileList = -1
  322.     END SELECT
  323. END FUNCTION
  324.  
  325.  
  326. ' *******************************************************************************
  327. ' FileListDialogEventHandler
  328. ' This subroutine responds to user interface with the file list dialog.
  329. ' PARAMS: BYVAL ControlID% - Integer indicating the dialog control that is 
  330. '                            generating a dialog event.
  331. '        BYVAL Event% - Integer indicating the dialog event that has occurred.
  332. ' *******************************************************************************
  333. SUB FileListDialogEventHandler(BYVAL ControlID%, BYVAL Event%)
  334.     IF Event% = EVENT_INITIALIZATION THEN         
  335.         ShowFileListDialog.ChapterListBox.SetStyle STYLE_INVISIBLE
  336.         ShowFileListDialog.SelectedChaptersListBox.SetStyle STYLE_INVISIBLE
  337.         ShowFileListDialog.FilesCountText.SetStyle STYLE_RIGHT_JUSTIFY
  338.         ShowFileListDialog.SelectedFilesCountText.SetStyle STYLE_RIGHT_JUSTIFY
  339.         IF ShowFileListDialog.SelectedFilesListBox.GetItemCount() = 0 THEN 
  340.             ShowFileListDialog.NextButton.Enable FALSE
  341.         ELSE
  342.             ShowFileListDialog.NextButton.Enable TRUE
  343.         ENDIF    
  344.  
  345.         BEGINWAITCURSOR
  346.         WITHOBJECT OBJECT_VENTURA8
  347.             'FOR every chapter in publication
  348.             NumberOfChapters& = .ChapterCount()
  349.             FOR i% = 1 TO NumberOfChapters&
  350.                 CurChapter$ = .ChapterGetAt(i%)
  351.                 .ViewGoToPage , CurChapter$, GOTO_RELATIVE_TO_CHAPTER, GOTO_PAGE_FIRST, FALSE
  352.                 'FOR every text file in chapter
  353.                 NumberOfTextFiles& = .TextFileCount()
  354.                 FOR j% = 1 TO NumberOfTextFiles&
  355.                     CurFile$ = .TextFileGetAt(j%) 
  356.                     ShowFileListDialog.FilesListBox.AddItem CurFile$
  357.                     ShowFileListDialog.ChapterListBox.AddItem CurChapter$
  358.                 NEXT j%
  359.             NEXT i%
  360.         END WITHOBJECT
  361.         ENDWAITCURSOR
  362.         ShowFileListDialog.FilesListBox.SetSelect 1
  363.         ShowFileListDialog.StatusText.SetText CurrentDir$
  364.         ShowFileListDialog.FilesCountText.SetText ShowFileListDialog.FilesListBox.GetItemCount()
  365.         ShowFileListDialog.SelectedFilesCountText.SetText ShowFileListDialog.SelectedFilesListBox.GetItemCount()
  366.  
  367.         ShowFileListDialog.SetStyle STYLE_VISIBLE
  368.     ENDIF
  369.  
  370.     IF Event% = EVENT_MOUSE_CLICK THEN         
  371.         SELECT CASE ControlID%
  372.             CASE ShowFileListDialog.NextButton.GetID()        
  373.                 SelectedFilesCount% = ShowFileListDialog.SelectedFilesListBox.GetItemCount()
  374.                 REDIM SelectedFiles$(SelectedFilesCount)                            'redimension array to accomodate all selected files
  375.                 REDIM SelectedChapters$(SelectedFilesCount)
  376.                 FOR i% = 1 TO SelectedFilesCount%                                    'FOR all items in selected files list
  377.                     SelectedFiles$(i%) = ShowFileListDialog.SelectedFilesListBox.GetItem(i%)    'add selection to FilesList
  378.                     SelectedChapters$(i%) = ShowFileListDialog.SelectedChaptersListBox.GetItem(i%)
  379.                 NEXT i%
  380.                 ShowFileListDialog.closedialog DIALOG_RETURN_NEXT
  381.  
  382.             CASE ShowFileListDialog.BackButton.GetID()        
  383.                 ShowFileListDialog.closedialog DIALOG_RETURN_BACK
  384.  
  385.             CASE ShowFileListDialog.SelectButton.GetID()        
  386.                 indx% = ShowFileListDialog.FilesListBox.GetSelect()                    'get index of selection
  387.                 IF indx%=0 THEN    'no files selected
  388.                     IF ShowFileListDialog.FilesListBox.GetItemCount() = 0 THEN
  389.                         MESSAGE "There are no files available for selection."
  390.                     ELSE
  391.                         MESSAGE "Please select a file from the available files list."
  392.                     ENDIF
  393.                 ELSE
  394.                     ShowFileListDialog.SelectedFilesListBox.AddItem ShowFileListDialog.FilesListBox.GetItem(indx%)    'add selection to SelectedFilesList
  395.                     ShowFileListDialog.FilesListBox.RemoveItem indx%                                        'remove selection from available files list
  396.                     ShowFileListDialog.SelectedChaptersListBox.AddItem ShowFileListDialog.ChapterListBox.GetItem(indx%)    'add selection to selected path list
  397.                     ShowFileListDialog.ChapterListBox.RemoveItem indx%                                        'remove selection from available paths list
  398.                     IF indx% > ShowFileListDialog.FilesListBox.GetItemCount() THEN
  399.                         ShowFileListDialog.FilesListBox.SetSelect indx%-1
  400.                     ELSE
  401.                         ShowFileListDialog.FilesListBox.SetSelect indx%
  402.                     ENDIF
  403.                      ShowFileListDialog.StatusText.SetText CurrentDir$
  404.                     ShowFileListDialog.SelectedFilesListBox.SetSelect 0
  405.                 ENDIF
  406.  
  407.             CASE ShowFileListDialog.DeselectButton.GetID()                    
  408.                 indx% = ShowFileListDialog.SelectedFilesListBox.GetSelect()                            'get index of selection
  409.                 IF indx%=0 THEN    'no files selected
  410.                     IF ShowFileListDialog.SelectedFilesListBox.GetItemCount() = 0 THEN
  411.                         MESSAGE "There are no files available for deselection"
  412.                     ELSE
  413.                         MESSAGE "Please select a file from the selected files list."
  414.                     ENDIF
  415.                 ELSE
  416.                     ShowFileListDialog.FilesListBox.AddItem ShowFileListDialog.SelectedFilesListBox.GetItem(indx%)    'add selection to FilesList
  417.                     ShowFileListDialog.SelectedFilesListBox.RemoveItem indx%                                'remove selection from selected files list
  418.                     ShowFileListDialog.ChapterListBox.AddItem ShowFileListDialog.SelectedChaptersListBox.GetItem(indx%)    'add selection to available path list
  419.                     ShowFileListDialog.SelectedChaptersListBox.RemoveItem indx%                                'remove selection from selected path list
  420.                     IF indx% > ShowFileListDialog.SelectedFilesListBox.GetItemCount() THEN
  421.                         ShowFileListDialog.SelectedFilesListBox.SetSelect indx%-1
  422.                     ELSE
  423.                         ShowFileListDialog.SelectedFilesListBox.SetSelect indx%
  424.                     ENDIF
  425.                      ShowFileListDialog.StatusText.SetText CurrentDir$
  426.                     ShowFileListDialog.FilesListBox.SetSelect 0
  427.                 ENDIF
  428.  
  429.             CASE ShowFileListDialog.SelectAllButton.GetID()        
  430.                 ShowFileListDialog.StatusText.SetText "All files selected."
  431.                 ShowFileListDialog.SelectedFilesListBox.SetSelect 0
  432.                 WHILE ShowFileListDialog.FilesListBox.GetItemCount() > 0            'while there are available files
  433.                     ShowFileListDialog.SelectedFilesListBox.AddItem ShowFileListDialog.FilesListBox.GetItem(1)    'add selection to SelectedFilesList
  434.                     ShowFileListDialog.FilesListBox.RemoveItem 1                                            'remove selection from available files list    
  435.                     ShowFileListDialog.SelectedChaptersListBox.AddItem ShowFileListDialog.ChapterListBox.GetItem(1)        'add selection to selected path list
  436.                     ShowFileListDialog.ChapterListBox.RemoveItem 1                                            'remove selection  from available paths list
  437.                     ShowFileListDialog.FilesCountText.SetText ShowFileListDialog.FilesListBox.GetItemCount()        'number of available files
  438.                     ShowFileListDialog.SelectedFilesCountText.SetText ShowFileListDialog.SelectedFilesListBox.GetItemCount()    'number of selected files
  439.                 WEND
  440.  
  441.             CASE ShowFileListDialog.DeselectAllButton.GetID()        
  442.                 ShowFileListDialog.StatusText.SetText "No files selected."
  443.                 ShowFileListDialog.FilesListBox.SetSelect 0
  444.                 WHILE ShowFileListDialog.SelectedFilesListBox.GetItemCount() > 0        'while there are selected files
  445.                     ShowFileListDialog.FilesListBox.AddItem ShowFileListDialog.SelectedFilesListBox.GetItem(1)    'add selection to FilesList
  446.                     ShowFileListDialog.SelectedFilesListBox.RemoveItem 1                                    'remove selection from selected files list
  447.                     ShowFileListDialog.ChapterListBox.AddItem ShowFileListDialog.SelectedChaptersListBox.GetItem(1)        'add selection to available path list
  448.                     ShowFileListDialog.SelectedChaptersListBox.RemoveItem 1                                    'remove selection from selected path list
  449.                     ShowFileListDialog.FilesCountText.SetText ShowFileListDialog.FilesListBox.GetItemCount()        'number of available files
  450.                     ShowFileListDialog.SelectedFilesCountText.SetText ShowFileListDialog.SelectedFilesListBox.GetItemCount()        'number of selected files
  451.                 WEND
  452.  
  453.             CASE ShowFileListDialog.CancelButton.GetID()            
  454.                 ShowFileListDialog.closedialog DIALOG_RETURN_CANCEL    
  455.             CASE ShowFileListDialog.FilesListBox.GetID()                    'files list
  456.                  ShowFileListDialog.StatusText.SetText CurrentDir$
  457.                 ShowFileListDialog.SelectedFilesListBox.SetSelect 0
  458.             CASE ShowFileListDialog.SelectedFilesListBox.GetID()            'selected files list
  459.                  ShowFileListDialog.StatusText.SetText CurrentDir$
  460.                 ShowFileListDialog.FilesListBox.SetSelect 0
  461.         END SELECT
  462.         ShowFileListDialog.FilesCountText.SetText ShowFileListDialog.FilesListBox.GetItemCount()                    'number of available files
  463.         ShowFileListDialog.SelectedFilesCountText.SetText ShowFileListDialog.SelectedFilesListBox.GetItemCount()        'number of selected files
  464.     ENDIF
  465.  
  466.     IF Event% = EVENT_DBL_MOUSE_CLICK THEN         
  467.         SELECT CASE ControlID%
  468.             CASE ShowFileListDialog.FilesListBox.GetID()            
  469.                 indx% = ShowFileListDialog.FilesListBox.GetSelect()                                    'get index of selection
  470.                 ShowFileListDialog.SelectedFilesListBox.AddItem ShowFileListDialog.FilesListBox.GetItem(indx%)    'add selection to SelectedFilesList
  471.                 ShowFileListDialog.FilesListBox.RemoveItem indx%                                        'remove selection from available files list
  472.                 ShowFileListDialog.SelectedChaptersListBox.AddItem ShowFileListDialog.ChapterListBox.GetItem(indx%)    'add selection to selected path list
  473.                 ShowFileListDialog.ChapterListBox.RemoveItem indx%                                        'remove selection from available paths list
  474.                 IF indx% > ShowFileListDialog.FilesListBox.GetItemCount() THEN
  475.                     ShowFileListDialog.FilesListBox.SetSelect indx%-1
  476.                 ELSE
  477.                     ShowFileListDialog.FilesListBox.SetSelect indx%
  478.                 ENDIF
  479.  
  480.             CASE ShowFileListDialog.SelectedFilesListBox.GetID()            'selected files list
  481.                 indx% = ShowFileListDialog.SelectedFilesListBox.GetSelect()                                'get index of selection
  482.                 ShowFileListDialog.FilesListBox.AddItem ShowFileListDialog.SelectedFilesListBox.GetItem(indx%)    'add selection to FilesList
  483.                 ShowFileListDialog.SelectedFilesListBox.RemoveItem indx%                                'remove selection from selected files list
  484.                 ShowFileListDialog.ChapterListBox.AddItem ShowFileListDialog.SelectedChaptersListBox.GetItem(indx%)    'add selection to available path list
  485.                 ShowFileListDialog.SelectedChaptersListBox.RemoveItem indx%                                'remove selection from selected path list
  486.                 IF indx% > ShowFileListDialog.SelectedFilesListBox.GetItemCount() THEN
  487.                     ShowFileListDialog.SelectedFilesListBox.SetSelect indx%-1
  488.                 ELSE
  489.                     ShowFileListDialog.SelectedFilesListBox.SetSelect indx%
  490.                 ENDIF
  491.  
  492.         END SELECT
  493.         ShowFileListDialog.FilesCountText.SetText ShowFileListDialog.FilesListBox.GetItemCount()                'number of available files
  494.         ShowFileListDialog.SelectedFilesCountText.SetText ShowFileListDialog.SelectedFilesListBox.GetItemCount()    'number of selected files
  495.     ENDIF
  496.     IF ShowFileListDialog.SelectedFilesListBox.GetItemCount() = 0 THEN 
  497.         ShowFileListDialog.NextButton.Enable FALSE
  498.     ELSE
  499.         ShowFileListDialog.NextButton.Enable TRUE
  500.     ENDIF    
  501. END SUB
  502.  
  503.  
  504. ' *******************************************************************************
  505. ' SetToExport
  506. ' This function sets the selected files to Export on save. The publication is 
  507. ' then saved to implement the set.
  508. '
  509. ' PARAMS: None
  510. ' *******************************************************************************
  511. SUB SetToExport
  512. ON ERROR RESUME NEXT
  513.     BEGINWAITCURSOR
  514.     WITHOBJECT OBJECT_VENTURA8
  515.         FOR i% = 1 TO SelectedFilesCount%
  516.             pos% = INSTR(SelectedFiles$(i%), ".")
  517.             IF pos% = 0 THEN
  518.                 NewName$ = SelectedFiles$(i%) & "."
  519.             ELSE
  520.                 NewName$ = LEFT(SelectedFiles$(i%),pos%)
  521.             ENDIF
  522.             NewName$ = CurrentDir$ & "\" & NewName$ & ExportExtensions$(FilterSelection%)
  523.              .FileRenameTextFile SelectedFiles$(i%) ,NewName$ , ExportFilters%(FilterSelection%), TRUE, SelectedChapters$(i%)
  524.         NEXT i%
  525.  
  526.         .FileSave (.PublicationName())
  527.     END WITHOBJECT
  528.     ENDWAITCURSOR
  529. END SUB
  530.  
  531.  
  532. ' *******************************************************************************
  533. ' CreateFolder
  534. ' This subroutine creates the specified folder.
  535. '
  536. ' PARAMS: Folder$ - the folder to create.
  537. ' *******************************************************************************
  538. SUB CreateFolder(Folder$)
  539. DIM FolderStatus AS BOOLEAN
  540.  
  541.     Temp$ = Folder$
  542.     FolderStatus = MKFOLDER(Temp$)
  543.     IF FINDFIRSTFOLDER(Temp$, 1 OR 2 OR 4 OR 16 OR 32 or 128 OR 256 OR 2048) = "" THEN
  544.         DO WHILE  FolderStatus = FALSE 
  545.             first% = 1
  546.             pos% = 1
  547.             DO WHILE first <> 0
  548.                 first% = INSTR(Temp$, "\", first%)
  549.                 IF first% <> 0 THEN
  550.                     pos% = first%
  551.                     first% = first% + 1
  552.                 END IF
  553.             LOOP
  554.             Temp$ = LEFT(Temp$, pos% - 1)  
  555.             FolderStatus = MKFOLDER(Temp$)
  556.         LOOP    
  557.         FolderStatus = MKFOLDER(Temp$)
  558.         IF FolderStatus = FALSE THEN CreateFolder(Folder$)
  559.     ENDIF
  560. END SUB
  561.  
  562.  
  563.