home *** CD-ROM | disk | FTP | other *** search
/ PC World Komputer 1998 October A / Pcwk10a98.iso / Corel / Ventura8 / Ventura / Scripts / FileList.CSC < prev    next >
Encoding:
Text File  |  1998-07-08  |  7.8 KB  |  218 lines

  1. REM Prints a list of all files in publication [CorelSCRIPT 8]
  2. REM FileList.csc  March, 1998
  3. REM ⌐ 1998 Corel Corporation. All rights reserved.
  4.  
  5. REM **************************************************************************************
  6. REM This script prints a list of all the files contained in the current publication. 
  7. REM The information is displayed in a new VENTURA publication.
  8. REM **************************************************************************************
  9.  
  10. ' Create a temporary folder to provide a path for the include files
  11. '  -this enables the include files to be located 
  12. #addfol "..\..\Scripts"
  13. #include "ScpConst.csi"
  14. #include "VPConst.csi"
  15.  
  16. ' Embed bitmaps if script is to be compiled into exe or csb formats
  17. ' -this will eliminate the need to include these files
  18. #ADDRESBMP IntroBMP "Bitmaps\IntroBMP.bmp"
  19.  
  20. 'Constants for Dialog Return Values
  21. GLOBAL CONST DIALOG_RETURN_CANCEL% = 2
  22. GLOBAL CONST DIALOG_RETURN_NEXT% = 3
  23. GLOBAL CONST DIALOG_RETURN_BACK% = 4
  24. GLOBAL CONST DIALOG_RETURN_BROWSE% = 5
  25.  
  26. '/////FUNCTION & SUBROUTINE DECLARATIONS/////////////////////////////////////////
  27. DECLARE SUB RegQuery()
  28. DECLARE SUB ShowIntro()
  29. DECLARE SUB GetFiles(FileName$)
  30. DECLARE SUB PrintFiles(FileName$)
  31. DECLARE FUNCTION GetCurrentPub$()
  32.  
  33. '/////GLOBAL VARIABLES //////////////////////////////////////////////////////////
  34. GLOBAL VenturaRoot$            'root directory where Ventura is installed
  35.  
  36.  
  37. '///// MAIN ////////////////////////////////////////////////////
  38. RegQuery                                'get root directory where Ventura is installed
  39. ShowIntro                                'display introduction dialog
  40. TempFolder$ = GETTEMPFOLDER()                'get Windows temporary folder
  41. TempFile$ = TempFolder$ & "FileList.txt"    'temporary file containing file list information
  42. PubName$ = GetCurrentPub$()                'get name of active publication
  43. GetFiles(TempFile$)                        'get a list of all files in current pub and write to a temporary file
  44. PrintFiles(TempFile$)                    'import temporary file to a new VENTURA publication
  45. KILL TempFile$                            'remove temporary file
  46.  
  47.  
  48. ' *******************************************************************************
  49. ' RegQuery
  50. ' This subroutine queries the Registry to determine the root directory where 
  51. ' Ventura is installed.
  52. ' *******************************************************************************
  53. SUB RegQuery
  54. ON ERROR GOTO ErrorHandler
  55.  
  56.     'get Ventura config directory
  57.     VentDir$ = REGISTRYQUERY(HKEY_LOCAL_MACHINE,VENTURA_REGQUERY_CONST,"ConfigDir")     
  58.     
  59.     'isolate Ventura root directory from Ventura config directory
  60.     first% = 1
  61.     pos% = 1
  62.     DO WHILE first <> 0
  63.         first = INSTR(VentDir$, "\", first )
  64.         IF first <> 0 THEN
  65.             pos = first
  66.             first = first + 1
  67.         END IF
  68.     LOOP
  69.     VenturaRoot$ = LEFT(VentDir$, pos - 1)     'root directory where Ventura is installed
  70.  
  71. EXIT SUB
  72. ErrorHandler:
  73.     MESSAGE "Error reading registry:" & CHR(13) & RegString$
  74.     ErrNum = 800
  75. END SUB
  76.  
  77.  
  78. ' *******************************************************************************
  79. ' GetCurrentPub
  80. ' This function queries VENTURA for the name of the current publication. IF no 
  81. ' publication is open, the user is prompted to open one before continuing.
  82. ' PARAMS: None
  83. '
  84. ' RETURNS: GetCurrentPub$ - the name of the current publication.
  85. ' *******************************************************************************
  86. FUNCTION GetCurrentPub$()
  87.     BEGINWAITCURSOR
  88.     WITHOBJECT OBJECT_VENTURA8
  89.     ENDWAITCURSOR
  90.         IF .CountWindows() = 0 THEN
  91.             PubMsg$ = "You need an open publication to run this script." & CHR(13) & "Open one now?"
  92.             MsgVal% = MESSAGEBOX(PubMsg$, "WARNING", MB_YES_NO OR MB_STOP_ICON)
  93.             IF MsgVal% = MSG_YES THEN         'Yes, open a pub
  94.                 SETCURRFOLDER VenturaRoot$
  95.                 PubName$ = GETFILEBOX("Publication files (*.VP*)|*.VP*", , , ,"*.vp*", VenturaRoot$ & "\Ventura\Samples" )
  96.                 IF PubName$ <> "" THEN
  97.                     .SetVisible TRUE
  98.                     .FileOpen PubName$, , TRUE, 1, TRUE, FALSE
  99.                 ELSE
  100.                     STOP
  101.                 ENDIF
  102.             ELSE
  103.                 STOP
  104.             ENDIF
  105.         ENDIF
  106.         GetCurrentPub$ = .PublicationName()
  107.     END WITHOBJECT
  108. END FUNCTION
  109.  
  110.  
  111. ' *********************************************************************************
  112. ' GetFiles
  113. ' This subroutine creates a list of all files (in all chapters) in the current 
  114. ' VENTURA publication and writes the information to a temporary text file 
  115. ' specified by FileName$.
  116. ' PARAMS: FileName$ - name of temporary text file containing file list information.
  117. ' *********************************************************************************
  118. SUB GetFiles(FileName$)
  119.     OPEN FileName$ FOR OUTPUT AS 1
  120.     BEGINWAITCURSOR
  121.     WITHOBJECT OBJECT_VENTURA8
  122.         'FOR every chapter in publication
  123.         NumberOfChapters& = .ChapterCount()
  124.         FOR i% = 1 TO NumberOfChapters&
  125.             CurChapter$ = .ChapterGetAt(i%)
  126.             .ViewGoToPage , CurChapter$, GOTO_RELATIVE_TO_CHAPTER, GOTO_PAGE_FIRST, FALSE
  127.             PRINT #1, "@Minor Heading = " & CurChapter$
  128.             'get all text files in current chapter
  129.             NumberOfTextFiles& = .TextFileCount()        
  130.             FOR j% = 1 TO NumberOfTextFiles&
  131.                 CurFile$ = .TextFileGetAt(j%) 
  132.                 PRINT #1,
  133.                 PRINT #1, "@Bullet = " &  CurFile$
  134.             NEXT j%
  135.             'get all picture files in current chapter
  136.             NumberOfPictureFiles& = .PictureFileCount()    
  137.             FOR j% = 1 TO NumberOfPictureFiles&
  138.                 CurFile$ = .PictureFileGetAt(j%) 
  139.                 PRINT #1,
  140.                 PRINT #1, "@Bullet = " &   CurFile$
  141.             NEXT j%
  142.         PRINT #1,
  143.         NEXT i%
  144.     END WITHOBJECT
  145.     ENDWAITCURSOR
  146.     CLOSE(1)
  147. END SUB
  148.  
  149. ' *******************************************************************************
  150. ' PrintFiles
  151. ' This subroutine imports the text file containing the file list information into 
  152. ' a new VENTURA publication.
  153. ' PARAMS: FileName$ - name of text file to be imported.
  154. ' *******************************************************************************
  155. SUB PrintFiles(FileName$)
  156.     BEGINWAITCURSOR
  157.     WITHOBJECT OBJECT_VENTURA8
  158.         .FileNew
  159.         .FrameFirst TRUE
  160.         .FileImportText FileName$
  161.     END WITHOBJECT
  162.     ENDWAITCURSOR
  163. END SUB
  164.  
  165.  
  166.  
  167. ' *******************************************************************************
  168. ' ShowIntro
  169. ' This subroutine displays the introduction dialog.
  170. ' PARAMS: None
  171. ' *******************************************************************************
  172. SUB ShowIntro
  173. BEGIN DIALOG OBJECT IntroDialog 290, 180, "File List Wizard", SUB IntroDialogEventHandler
  174.     PUSHBUTTON  181, 160, 46, 14, .NextButton, "&List Files"
  175.     CANCELBUTTON  234, 160, 46, 14, .CancelButton
  176.     PUSHBUTTON  135, 160, 46, 14, .BackButton, "< &Back"
  177.     TEXT  95, 10, 189, 20, .Text2, "This Wizard will create a list of all files within each chapter in the current publication."
  178.     IMAGE  10, 10, 75, 130, .IntroImage
  179.     GROUPBOX  10, 150, 270, 5, .LineGroupBox
  180.     TEXT  95, 35, 185, 15, .Text5, "To create the file list, click List Files."
  181. END DIALOG
  182.  
  183.     IntroDialog.IntroImage.SetImage "#IntroBMP"
  184.     IntroDialog.IntroImage.SetStyle STYLE_IMAGE_CENTERED
  185.  
  186.     IntroRet%=DIALOG(IntroDialog)
  187.     IF IntroRet% = DIALOG_RETURN_CANCEL THEN STOP            
  188. END SUB
  189.  
  190.  
  191. ' *******************************************************************************
  192. ' IntroDialogEventHandler
  193. ' This subroutine responds to user interface with the introduction dialog.
  194. ' PARAMS: BYVAL ControlID% - Integer indicating the dialog control that is 
  195. '                            generating a dialog event.
  196. '        BYVAL Event% - Integer indicating the dialog event that has occurred.
  197. ' *******************************************************************************
  198. SUB IntroDialogEventHandler(BYVAL ControlID%, BYVAL Event%)
  199.     IF Event% = EVENT_INITIALIZATION THEN         
  200.         IntroDialog.BackButton.Enable FALSE 
  201.     ENDIF
  202.  
  203.     IF Event% = EVENT_MOUSE_CLICK THEN     
  204.         SELECT CASE ControlID%
  205.             CASE IntroDialog.NextButton.GetID()
  206.                     IntroDialog.CloseDialog DIALOG_RETURN_NEXT
  207.             CASE IntroDialog.CancelButton.GetID()
  208.                 IntroDialog.CloseDialog DIALOG_RETURN_CANCEL
  209.         END SELECT
  210.     ENDIF
  211. END SUB
  212.  
  213.