...and a macro to set them all back. The macro, a late Christmas present, allows you to store project settings as configuration varaibles, then rebuild the UPF file appropriately. Beware of line wrapping. More instructions after the code...
'UPF.BA
'Rebuilds User Preference File based on configuration variables defined in 'the project configuration file. 'Simon Wurster, NYO 06/01/00 'Last Updated: 12/29/00 - Added many more variables . Sub Main Dim CMD$ As String Dim arg(3) As String Dim j As Integer Dim projMaxRefs As String Dim projTextUnderline As String Dim projDisplayWeights As String
Dim projHiliteSelected As String
Dim projMemElementCache As String
Dim projMemResourceCache As String
Dim projMemUndo As String
Dim projMemFont As String
Dim projRefLocate As String
Dim projNestDepth As String
Dim projPreserveNodes As String
'kill doesn't work, since ustn is writing to the file. Name does! 'Kill MbeGetConfigVar ("MS_USERPREF") 'delete the "old" .UPF file 'MbeMessageBox FileParse$(MbeGetConfigVar("MS_USERPREF"),2) + "\old.upf" If FileExists(FileParse$(MbeGetConfigVar("MS_USERPREF"),2) + "\old.upf") Then Kill FileParse$(MbeGetConfigVar("MS_USERPREF"),2) + "\old.upf" End If
Name MbeGetConfigVar ("MS_USERPREF") As
FileParse$(MbeGetConfigVar("MS_USERPREF"),2) + "\old.upf"
CMD$ = Ucase$(Command$) ' get command input
If CMD$ "" Then
' parse command line into array
For j = 1 To ItemCount(CMD$,",")
arg(j) = Item$(CMD$, j, j, ",")
Next j
projMaxRefs = arg(1)
projTextUnderline = arg(2)
projDisplayWeights = arg(3)
Else
projDisplayWeights = MbeGetConfigVar ("PREFS_DISPLAYWEIGHTS") projHiliteSelected = MbeGetConfigVar ("PREFS_HILITESELECTED") projMemElementCache = MbeGetConfigVar ("PREFS_MEM_ELEMENTCACHE") projMemResourceCache = MbeGetConfigVar ("PREFS_MEM_RESOURCECACHE") projMemUndo = MbeGetConfigVar ("PREFS_MEM_UNDO") projMemFont = MbeGetConfigVar ("PREFS_MEM_FONT") projRefLocate = MbeGetConfigVar ("PREFS_REFLOCATE") projMaxRefs = MbeGetConfigVar ("PREFS_MAXREFFILES") projNestDepth = MbeGetConfigVar ("PREFS_NESTDEPTH") projPreserveNodes = MbeGetConfigVar ("PREFS_PRESERVENODES") projTextUnderline = MbeGetConfigVar ("PREFS_TEXTUNDERLINESPACE")
End If
If projMaxRefs = "" Then projMaxRefs = "100" '100 ref files If projTextUnderline = "" Then projTextUnderline = "40" '40% spacing
MbeSendCommand "DIALOG CMDBROWSE"
MbeSendCommand "DIALOG TOOLBOX STANDARD OFF"
MbeSendCommand "DIALOG TOOLBOX PRIMARY ON"
MbeSendCommand "DIALOG TOOLBOX MAIN ON"
MbeSendCommand "MDL LOAD LINEWT dialog"
If projDisplayWeights "" Then
Dim newWeight(20,1) As String
Dim dummy As String
'MbeSetAppVariable "LINEWT", "lweightInfo->newDispWeight[0]", 0 'MbeSetAppVariable "LINEWT", "lweightInfo->newDispWeight[1]", 1 'MbeSetAppVariable "LINEWT", "lweightInfo->newDispWeight[2]", 2 'MbeSetAppVariable "LINEWT", "lweightInfo->newDispWeight[3]", 3 'MbeSetAppVariable "LINEWT", "lweightInfo->newDispWeight[4]", 4 'MbeSetAppVariable "LINEWT", "lweightInfo->newDispWeight[5]", 5 'MbeSetAppVariable "LINEWT", "lweightInfo->newDispWeight[6]", 6 'MbeSetAppVariable "LINEWT", "lweightInfo->newDispWeight[7]", 7 'MbeSetAppVariable "LINEWT", "lweightInfo->newDispWeight[8]", 8 'MbeSetAppVariable "LINEWT", "lweightInfo->newDispWeight[9]", 9 'MbeSetAppVariable "LINEWT", "lweightInfo->newDispWeight[10]", 0 'MbeSetAppVariable "LINEWT", "lweightInfo->newDispWeight[11]", 0 'MbeSetAppVariable "LINEWT", "lweightInfo->newDispWeight[12]", 0 'MbeSetAppVariable "LINEWT", "lweightInfo->newDispWeight[13]", 0 'MbeSetAppVariable "LINEWT", "lweightInfo->newDispWeight[14]", 0 For j = 1 To ItemCount(projDisplayWeights,"|") dummy = Item$(projDisplayWeights, j, j, "|") 'dummy = 0=0 newWeight(20,0) = Mid$(dummy,1,InStr(dummy,"=")-1) newWeight(20,1) = Mid$(dummy,InStr(dummy,"=")+1) MbeSetAppVariable "LINEWT", "lweightInfo->newDispWeight[" + newWeight(20,0) + "]", Val(newWeight(20,1)) Next j End If
MbeSendCommand "DMSG ACTION OK" 'one for the money... MbeSendCommand "DMSG ACTION OK" 'two for the show.
MbeSendCommand "MDL SILENTLOAD USERPREF"
MbeSetAppVariable "USERPREF", "savePrefs.cacheLimit", Val(projMemElementCache) MbeSetAppVariable "USERPREF", "savePrefs.rscCacheSize", Val(projMemResourceCache) MbeSetAppVariable "USERPREF", "savePrefs.undoBufSize", Val(projMemUndo) MbeSetAppVariable "USERPREF", "savePrefs.fontCacheSize", Val(projMemFont) MbeSetAppVariable "USERPREF", "savePrefs.moreFlags.refLocateDef", Val(projRefLocate) 'locate off when attached MbeSetAppVariable "USERPREF", "savePrefs.maxRefFiles", Val(projMaxRefs) MbeSetAppVariable "USERPREF", "savePrefs.refFilePrefs.defaultNestDepth", Val(projNestDepth) 'nest-depth 0 MbeSetAppVariable "USERPREF", "savePrefs.moreFlags.preserveTextNodes", Val(projPreserveNodes) 'preserve text nodes MbeSetAppVariable "USERPREF", "savePrefs.textUnderlineSpace", Val(projTextUnderline) MbeSetAppVariable "USERPREF", "savePrefs.addFlags.hiliteSelectionSet", Val(projHiliteSelected) MbeSendCommand "DMSG ACTION OK" 'one for the money... MbeSendCommand "DMSG ACTION OK" 'two for the show MbeSendCommand "FILEDESIGN"
End Sub
The macro reads the environment for configuration varaiables, then uses them to set the preferences. Somewhere (UCF, PCF, whatever), include these vars:
PREFS_DISPLAYWEIGHTS=0=0|1=1|2=2|3=3|4=4|5=5|6=6|7=7|8=8|9=9|10=0|11=0|12=0|13=0|14=0|15=0 PREFS_HILITESELECTED=1 PREFS_MEM_ELEMENTCACHE=16000 PREFS_MEM_RESOURCECACHE=256 PREFS_MEM_UNDO=1024 PREFS_MEM_FONT=30 PREFS_REFLOCATE=0 PREFS_MAXREFFILES=100 PREFS_NESTDEPTH=0 PREFS_PRESERVENODES=1 PREFS_TEXTUNDERLINESPACE=40
The DISPLAYWEIGHTS one you can ignore: it just forces weights 10 thru 15 to display as weight 0 (custom setting). Not all preferences are shown; you can add others, then update the macro and add the new preference vars to your configuration.
You'll need to check these settings and determine whether they're suitable for your office/projects. Also, test the macro before unleashing it in your office...
Merry Christmas!
Simon
ga Morozoff wrote:
...and...it's also not a bad idea to have a backup copy of your UPF so that you don't have to go through all the settings again once Microstation creates the new one.
"Anthony and Kirsty" wrote:
> If that all goes horribly wrong, you delete the UPF file which takes you