home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Chip 1997 January
/
Chip_1997-01_cd.bin
/
ms95
/
disk21
/
dir03
/
f000820.re_
/
f000820.re
Wrap
Text File
|
1996-04-02
|
15KB
|
475 lines
' BASIC program to report information about the current MicroStation
' session.
' Sample command lines:
' macro report - prompts user for an output file name, writes
' report to the file, and asks user if the file
' should be displayed.
' macro report display - prompts user for an output file name, writes
' report to the file, and displays the contents of
' the file using the "TYPE" command.
'--------------------------------------------------------------------
'
' Copyright (1995) Bentley Systems, Inc., All rights reserved.
'
' $Workfile: report.bas $
' $Revision: 6.5 $
' $Date: 31 Jan 1996 16:52:42 $
'
' "MicroStation" is a registered trademark of Bentley Systems, Inc.
'
' Limited permission is hereby granted to reproduce and modify this
' copyrighted material provided that the resulting code is used only
' in conjunction with Bentley Systems products under the terms of the
' license agreement provided therein, and that this notice is retained
' in its entirety in any such reproduction or modification.
'
'--------------------------------------------------------------------
' Global Variables
'
' Display the report information with the "TYPE" command?
Private gDispFile As Integer
'-------------------------------------------------------------
'
' outputPlotterInfo - Writes the current plot configuration
' information to the output file
'
'-------------------------------------------------------------
Function outputPlotterInfo (fileNum As Integer)
Dim plotConfig As String
Print #fileNum, "Plotter information:"
' get the plot config file name from MS_PLTR config variable
plotConfig = MbeGetConfigVar ("MS_PLTR")
If plotConfig = "" Then
Print #fileNum, Tab(5); "No plot configuration file"
Else
Print #fileNum, Tab(5); "Plot configuration file:"; plotConfig
End If
Print #fileNum, ""
' return a successful status
outputPlotterInfo = MBE_Success
End Function
'-------------------------------------------------------------
'
' outputMdlAppInfo - Writes the MS_INITAPPS & MS_DGNAPPS file
' information to the output file
'
'-------------------------------------------------------------
Function outputMdlAppInfo (fileNum As Integer)
Dim initApps As String
Dim dgnApps As String
Print #fileNum, "Application information:"
' get the startup application names from MS_INITAPPS config variable
initApps = MbeGetConfigVar ("MS_INITAPPS")
If initApps = "" Then
Print #fileNum, Tab(5); "No MS_INITAPPS applications"
Else
Print #fileNum, Tab(5); "MS_INITAPPS:"; Tab(25); initApps
End If
Print #fileNum, ""
' get the dgn application names from MS_DGNAPPS config variable
dgnApps = MbeGetConfigVar ("MS_DGNAPPS")
If dgnApps = "" Then
Print #fileNum, Tab(5); "No MS_DGNAPPS applications"
Else
Print #fileNum, Tab(5); "MS_DGNAPPS:"; Tab(25); dgnApps
End If
Print #fileNum, ""
' return a successful status
outputMdlAppInfo = MBE_Success
End Function
'-------------------------------------------------------------
'
' outputWorkspaceInfo - Writes the workspace file information
' to the output file
'
'-------------------------------------------------------------
Function outputWorkspaceInfo (fileNum As Integer)
Dim tempDir As String
Dim tempString As String
Print #fileNum, "Workspace information:"
' get the user preference file name from _USTN_USERCFG config variable
tempString = MbeGetConfigVar ("_USTN_USERCFG")
If tempString <> "" Then
Print #fileNum, Tab(5); "User Configuration:"; Tab(25); tempString
End If
Print #fileNum, ""
' get the project description
tempString = MbeGetConfigVar ("_USTN_PROJECTDESCR")
If tempString <> "" Then
Print #fileNum, Tab(5); "Project:"; Tab(25); tempString
End If
' get the project file
tempString = MbeGetConfigVar ("_USTN_PROJECTCFG")
If tempString <> "" Then
Print #fileNum, Tab(25); tempString
End If
' get the user interface description
tempString = MbeGetConfigVar ("_USTN_USERINTNAME")
If tempString <> "" Then
Print #fileNum, Tab(5); "User Interface:"; Tab(25); tempString
' get the user interface file name
tempDir = MbeGetConfigVar ("_USTN_USERINT")
If tempDir <> "" Then
Print #fileNum, Tab(25); tempDir + tempString
End If
End If
' get the user preference description
tempString = mbeCExpressionString ("userPrefsP->descriptiveName")
If tempString <> "" Then
Print #fileNum, Tab(5); "Preferences:"; Tab(25); tempString
End If
' get the user interface file name
tempString = MbeGetConfigVar ("MS_USERPREF")
If tempString <> "" Then
Print #fileNum, Tab(25); tempString
End If
' return a successful status
outputWorkspaceInfo = MBE_Success
End Function
'-------------------------------------------------------------
'
' outputLicenseInfo - Writes the license file information
' to the output file
'
'-------------------------------------------------------------
Function outputLicenseInfo (fileNum As Integer)
Dim licFileNum As Integer
Dim licFileName As String
Dim organizationName As String
Dim userName As String
Dim serialNum As String
Dim licenseNum As String
Dim inputString As String
licFileNum = 2
' get the license file name from MS_USERLICENSE config variable
licFileName = MbeGetConfigVar ("MS_USERLICENSE")
If licFileName = "" Then
' return an error status
outputLicenseInfo = MBE_Error
Exit Function
End If
' open the MicroStation license file
Open licFileName For Input Access Read As licFileNum
Input #licFileNum, serialNum, licenseNum, userName, organizationName
' close the license file
Close #licFileNum
Print #fileNum, "License file information:"
Print #fileNum, Tab(5); "Serial:"; Tab(20); serialNum
Print #fileNum, Tab(5); "Your Name:"; Tab(20); userName
Print #fileNum, Tab(5); "Organization:";Tab(20); organizationName
' return a successful status
outputLicenseInfo = MBE_Success
End Function
'-------------------------------------------------------------
'
' outputProductVersionInfo - Writes the Product name and version
' to the output file
'
'-------------------------------------------------------------
Function outputProductVersionInfo (fileNum As Integer)
Select Case MbeSession.msProduct
Case MBE_MicroStation
Print #fileNum, "MicroStation Version:"; Tab(35); MbeSession.msVersion
Case MBE_MSPowerDraft
Print #fileNum, "MicroStation PowerDraft Version:"; Tab(35); MbeSession.msVersion
Case MBE_MSReview
Print #fileNum, "MicroStation Review Version:"; Tab(35); MbeSession.msVersion
End Select
' return a successful status
outputProductVersionInfo = MBE_Success
End Function
'-------------------------------------------------------------
'
' outputReferenceFileInfo - Writes the reference file information
' to the output file
'
'-------------------------------------------------------------
Sub outputReferenceFileInfo (fileNum As Integer)
Dim iRef As Integer
Print #fileNum, "Attached reference files:"
' loop through all reference file slots
For iRef = 1 to MbeRefFiles.maxRefFiles
' if the reference file is active then
If MbeRefFiles(iRef).active <> 0 Then
Print #fileNum, Tab(5); "File in slot #"; Str$(iRef); ": "; _
MbeRefFiles(iRef).fileName
End If
Next iRef
End Sub
'-------------------------------------------------------------
'
' getNumRefAttach - get the number of attached reference files
'
'-------------------------------------------------------------
Function getNumRefAttach ()
Dim iRef As Integer
Dim counter As Integer
counter = 0
' loop through all reference file slots
For iRef = 1 to MbeRefFiles.maxRefFiles
' if the reference file is active then count it
If MbeRefFiles(iRef).active <> 0 Then
counter = counter + 1
End If
Next iRef
getNumRefAttach = counter
End Function
'-------------------------------------------------------------
'
' outputReport - Writes the report information to the output
' file
'
'-------------------------------------------------------------
Sub outputReport (fileNum As Integer)
Dim menuNames() as String
Dim numMenus As Integer
Dim iMenu As Integer
Dim numBytes As Double
Dim cacheUsage As Double
Print #fileNum, Tab(30); "MicroStation Session Information Report"
Print #fileNum, Tab(30); "======================================="
Print #fileNum, ""
Print #fileNum, ""
stat = outputProductVersionInfo (fileNum)
Print #fileNum, ""
Print #fileNum, "Current design file:"; Tab(25); MbeDgnInfo.dgnFileName
Print #fileNum, "Design file size in bytes:"; Tab(30); Str$(FileLen(MbeDgnInfo.dgnFileName))
If MbeDgnInfo.dgn3D <> 0 Then
Print #fileNum, Tab(30); "3D design file"
Else
Print #fileNum, Tab(30); "2D design file"
End If
Print #fileNum, ""
'---------------------------------------------------------------------------
' MbeSession.cacheSize returns size of the element cache in bytes
'---------------------------------------------------------------------------
numBytes = MbeSession.cacheSize
Print #fileNum, "Element cache size in bytes:"; Tab(30); Format$(numBytes#, "Standard")
'---------------------------------------------------------------------------
' MbeSession.cacheUsage which returns a double between 0 and 1
' telling the fraction of the cache used
'---------------------------------------------------------------------------
cacheUsage = MbeSession.cacheUsage
Print #fileNum, "Percentage of cache used:"; Tab(30); Format$(cacheUsage#, "Percent")
Print #fileNum, ""
'---------------------------------------------------------------------------
' mbeSession.getMenus returns the names of the attached menus
'---------------------------------------------------------------------------
numMenus = mbeSession.getMenus (menuNames)
If numMenus = 0 Then
Print #fileNum, "No menus attached"
Else
Print #fileNum, "Number of attached menus:"; Tab(30); Str$(numMenus%)
For iMenu = LBound(menuNames) to UBound(menuNames)
Print #fileNum, "Attached menu #"; Str$(iMenu); ": "; Tab(30); menuNames(iMenu)
Next iMenu
End If
Print #fileNum, ""
'---------------------------------------------------------------------------
' MbeDgnInfo.saved returns 1 if the file is up to date on the disk
' and 0 otherwise.
'---------------------------------------------------------------------------
if MbeDgnInfo.saved = 1 Then
Print #fileNum, "Design file is saved and up to date"
else
Print #fileNum, "Design file needs to be saved"
End If
Print #fileNum, ""
If MbeDgnInfo.cellFileName = "" Then
Print #fileNum, "No cell library attached."
Else
Print #fileNum, "Attached cell library: "; Tab(25); MbeDgnInfo.cellFileName
End If
Print #fileNum, ""
stat = getNumRefAttach ()
If stat = 0 Then
Print #fileNum, "No reference files attached."
Else
Print #fileNum, "Number of attached reference files: "; Str$(stat)
' Output the names of attached reference files
outputReferenceFileInfo (fileNum)
End If
Print #fileNum, ""
stat = outputWorkspaceInfo (fileNum)
If stat <> MBE_Success Then
Print #fileNum, "Workspace information unavailable"
End If
Print #fileNum, ""
stat = outputMdlAppInfo (fileNum)
Print #fileNum, ""
stat = outputPlotterInfo (fileNum)
Print #fileNum, ""
stat = outputLicenseInfo (fileNum)
If stat <> MBE_Success Then
Print #fileNum, "License information unavailable"
End If
Print #fileNum, ""
End Sub
'-------------------------------------------------------------
'
' getFileName - get the name of the output file name from the
' user
'
'-------------------------------------------------------------
Function getFileName (fileName As String)
Dim status as long
suggest$ = "report.txt"
filter$ = "*.txt,Report Output Files [*.txt]"
directory$ = "MS_MACRO"
title$ = "Choose a Report Output File Name"
status = MbeFileCreate (fileName, suggest$, filter$, directory$, title$)
getFileName = status
End Function
'-------------------------------------------------------------
'
' processCmdLineArgs -
' Returns the number of command line arguments
'-------------------------------------------------------------
Sub processCmdLineArgs
Dim numArgs As Integer
Dim cmd As String
Dim cmdArg As String
gDispFile = 0
' save the command line arguments to a local variable
cmd$ = Command$
' save the number of arguments in a local variable
numArgs = WordCount(cmd$)
' parse the command line arguments and check the value of each argument
For counter% = 1 to numArgs
cmdArg = Word$ (cmd$, counter)
Select Case cmdArg
Case "display"
gDispFile = 1
End Select
Next counter
end sub
'-------------------------------------------------------------
'
' main - Entry point
'
'-------------------------------------------------------------
sub main
Dim stat As Integer
Dim fileNumber As Integer
Dim outputFileName As String
Dim cmdString As String
processCmdLineArgs
stat = getFileName (outputFileName)
If stat <> MBE_Success Then
exit sub
End if
' set the number of the output file
fileNumber = 1
' open the output file
Open outputFileName For Output Access Write As fileNumber
outputReport (fileNumber)
' Close the output file
Close fileNumber
' If the user specified to display the file...
If gDispFile = 1 Then
' queue the "TYPE" command to display the text file
cmdString = "TYPE " + outputFileName
MbeSendCommand cmdString
Else
' open a message box to inform the user that the report is finished
button = MbeMessageBox ("Report created in (" + outputFileName + "). Display file?", _
MBE_YesNoBox or MBE_QuestionIcon)
If button = MBE_BUTTON_YES Then
' queue the "TYPE" command to display the text file
cmdString = "TYPE " + outputFileName
MbeSendCommand cmdString
End If
End If
end sub