home *** CD-ROM | disk | FTP | other *** search
/ Chip 1997 January / Chip_1997-01_cd.bin / ms95 / disk22 / dir02 / f000810.re_ / f000810.re
Text File  |  1996-04-02  |  8KB  |  228 lines

  1. ' BASIC program to output the reference file attachment information
  2. '   using the MbeRefFile object.
  3. '
  4. '--------------------------------------------------------------------
  5. '
  6. '  Copyright (1995) Bentley Systems, Inc., All rights reserved.
  7. '
  8. '   $Workfile:   refinfo.bas  $
  9. '   $Revision:   6.3  $
  10. '       $Date:   19 Sep 1995 09:06:30  $
  11. '
  12. '  "MicroStation" is a registered trademark of Bentley Systems, Inc. 
  13. '
  14. '  Limited permission is hereby granted to reproduce and modify this
  15. '  copyrighted material provided that the resulting code is used only
  16. '  in conjunction with Bentley Systems products under the terms of the
  17. '  license agreement provided therein, and that this notice is retained
  18. '  in its entirety in any such reproduction or modification.
  19. '
  20. '--------------------------------------------------------------------
  21. Dim active as Integer              
  22. Dim notFound as Integer            
  23. Dim display  as Integer            
  24. Dim locate as Integer              
  25. Dim snap as Integer                
  26. Dim plot as Integer                
  27. Dim scaleLineStyles as Integer     
  28. Dim fileName as String 
  29. Dim logFileName as String
  30. Dim attachName as String           
  31. Dim logical as String              
  32. Dim description as String          
  33. Dim scale as Double                
  34. Dim stat_saveSettings as Integer   
  35.  
  36. '---------------------------------------------------------------
  37. '
  38. ' getRefInfo - Copy reference file attachment information to
  39. '           global variables for processing.
  40. '---------------------------------------------------------------
  41. Sub getRefInfo(refFile as MbeRefFile)
  42.     Dim view as Integer
  43.  
  44.     ' store the current reference file information in global variables
  45.     view = 1
  46.     active = refFile.active
  47.     notFound = refFile.notFound
  48.     display = refFile.display
  49.     locate = refFile.locate
  50.     snap = refFile.snap
  51.     plot = refFile.plot
  52.     scaleLineStyles = refFile.scaleLineStyles
  53.     fileName = refFile.fileName
  54.     attachName = refFile.attachName
  55.     logical = refFile.logical
  56.     description = refFile.description
  57.     scale = refFile.scale
  58.     stat_saveSettings = refFile.saveSettings()
  59.     
  60. end Sub
  61.  
  62. '---------------------------------------------------------------
  63. '
  64. ' printRefInfo - Output reference attachment settings to the 
  65. '               file
  66. '---------------------------------------------------------------
  67. sub printRefInfo (iRef as Integer)
  68.     Print #2, " "
  69.     Print #2, " Settings For Reference File : ";iRef
  70.     Print #2, " =========================== : "
  71.     Print #2, "             Ref File Active :";active           
  72.     Print #2, "          Ref File Not Found :";notFound     
  73.     Print #2, "            Ref File Display :";display        
  74.     Print #2, "             Ref File Locate :";locate         
  75.     Print #2, "               Ref File Snap :";snap                   
  76.     Print #2, "               Ref File Plot :";plot              
  77.     Print #2, "  Ref File Scale Line Styles :";scaleLineStyles  
  78.     Print #2, "          Ref File Full Name :";fileName          
  79.     Print #2, "        Ref File Attach Name :";attachName         
  80.     Print #2, "        Ref File Logcal Name :";logical    
  81.     Print #2, "        Ref File Description :";description        
  82.     Print #2, "              Ref File Scale :";scale            
  83.     Print #2, "Ref File Status Save Settings :";stat_saveSettings
  84. end Sub
  85.  
  86. '---------------------------------------------------------------
  87. '
  88. ' updateRef -  Update the Reference file object with the 
  89. '           changed information
  90. '---------------------------------------------------------------
  91. Sub updateRef (refFile as MbeRefFile, iRef as Integer)
  92.  
  93.     print refFile.display
  94.     print display
  95.  
  96.     if MbeRefFiles(iRef).active <> 0 then
  97.         if display <> refFile.display then
  98.             MbeRefFiles(iRef).display = display
  99.         end if    
  100.         if locate <> refFile.locate then
  101.             MbeRefFiles(iRef).locate = locate
  102.         end if
  103.         if snap <> refFile.snap then
  104.             MbeRefFiles(iRef).snap = snap
  105.         end if
  106.         if plot <> refFile.plot then
  107.             MbeRefFiles(iRef).plot = plot
  108.         end if
  109.         if scaleLineStyles <> refFile.scaleLineStyles then
  110.             MbeRefFiles(iRef).scaleLineStyles = scaleLineStyles
  111.         end if
  112.         if logical <> refFile.logical then
  113.             MbeRefFiles(iRef).logical = logical
  114.         end if
  115.         if description <> refFile.description then
  116.             MbeRefFiles(iRef).description = description
  117.         end if
  118.     end if
  119. end Sub
  120.  
  121. '---------------------------------------------------------------
  122. '
  123. ' Main Entry point
  124. '
  125. '---------------------------------------------------------------
  126. sub Main
  127.  
  128.     Dim refFile     as MbeRefFile
  129.     Dim iRef        as Integer
  130.     Dim iRefDisplay as Integer
  131.     Dim view        as Integer
  132.     Dim title       as String
  133.     Dim defaultName as String
  134.     Dim logFileName as String
  135.  
  136.     ' if the user did not supply a file name on the command line then prompt for one
  137.     if command$ = "" then
  138.         ' Ask operator for a file name
  139.         Prompt$ = " Please enter an output file name or CANCEL to use a dialog box"
  140.  
  141.         ' give the user a default file name
  142.         defaultName$ = "refinfo.txt"
  143.         
  144.         ' set the title of the input box
  145.         Title$ = "Enter Output File Name"
  146.         
  147.         logFileName$ = MbeInputBox ( Prompt, defaultName, Title)
  148.     else
  149.         ' use the command line input as the file name
  150.         logFileName$ = command$
  151.     end if
  152.  
  153.     ' If file name supplied open the file 
  154.     if logFileName <> "" then
  155.         open logfileName for output access write lock write as #2
  156.     end if
  157.  
  158.     ' store the maximum number of reference files value
  159.     maxRefFiles = MbeRefFiles.maxRefFiles
  160.     
  161.     ' initialize loop counters
  162.     iRef = 1
  163.     viewTable = 1
  164.     
  165.     ' for each reference file do
  166.     do while iRef > 0 and iRef <= maxRefFiles
  167.     
  168.         iRefDisplay = iRef
  169.         
  170.         ' set the refFile object variable to the current reference file object
  171.         set refFile = MbeRefFiles(iRef)
  172.         
  173.         ' get the information about this reference file attachment
  174.         call getRefInfo(refFile)
  175.         
  176.         ' if a log file was requested then output the reference attachment information to the file
  177.         if logFileName <> "" then
  178.             call printRefInfo(iRef)
  179.         end if
  180.  
  181.         ' if a log file was not provided then open the dialog box
  182.         if LogfileName = "" then
  183.             actionButton = mbeOpenModalDialog (1)
  184.         else
  185.             ' simulate the OK button so processing continues
  186.             actionButton = 3
  187.         end if
  188.         
  189.         ' if OK button pressed 
  190.         if actionButton = 3 then 
  191.  
  192.             ' increment indexes in reference file object
  193.             if iRefDisplay <> iRef then
  194.                 iRef = iRefDisplay
  195.             else
  196.                 iRef = iRef + 1
  197.             end if
  198.         
  199.         ' user hit Cancel, exit the loop
  200.         elseif actionButton = 4 then
  201.             goto quitRef
  202.             
  203.         ' user hit apply button, update information
  204.         elseif actionButton = 1 then
  205.             call updateRef (refFile, iRef)
  206.             
  207.         ' user wants to see previous attachment
  208.         elseif actionButton = 1000 then 
  209.             iRefDisplay = iRefDisplay - 1
  210.             iRef = iRefDisplay
  211.         end if
  212.  
  213.         ' do not let the reference file index below 1
  214.         if iRef < 1 then
  215.             iRef = 1
  216.         end if
  217.     Loop
  218.  
  219.     ' If we opened a file then close it
  220.     if logfileName <> "" then
  221.         Print #2," End Program"
  222.         close
  223.     end if
  224.  
  225. quitRef:
  226.  
  227. end Sub