Extracting File & Folder Information from MicroStation® Configuration Variables | LA Solutions |
Q How do I extract file and folder information from a configuration variable?
A
MicroStation uses configuration variables (CfgVars) to specify, amongst other things, locations for files.
CfgVars are defined in the configuration files specified for your MicroStation workspace.
These may include a user workspace (.ucf file), project workspace (.pcf file), or
one of the many plain old configuration (.cfg) files used when customising your
MicroStation environment.
Here's an example of a CfgVar defined as a folder …
MS_SETTINGSDIR = v:/projects/data/MicroStation/settings/
And another CfgVar that defines a file in that folder …
# Next line expands to
# v:/projects/data/MicroStation/settings/data.dat
DATA_FILE = $(MS_SETTINGSDIR)data.dat
There are a number of functions relating to configuration file & folder parsing.
They are documented in the MicroStation Administrator's Guide in the section Configuration Variable File Syntax.
Suppose, for whatever reason, I want to extract the folder or file name from the DATA_FILE CfgVar.
I can use the special configuration file operators parentdevdir() and filename() like this …
# Next line extracts # v:/projects/data/MicroStation/settings/FOLDER = $(parentdevdir (DATA_FILE))# Next line extracts # data.datFILENAME = $(filename (DATA_FILE))
However, not all the functions made it as far as the documentation in MicroStation V8: two functions,
firstdirpiece() and lastdirpiece(), were omitted. However, they are mentioned
in this MicroStation/J Technote (#8160).
You can use these to extract respectively the first folder in a path and the last folder in a path …
# Next line expands to # projectsTOP_LEVEL_DIR = $(firstdirpiece (DATA_FILE))# Next line expands to # settingsBOTTOM_LEVEL_DIR = $(lastdirpiece (DATA_FILE))
Questions similar to this pop up regularly on the Bentley Discussion Groups.
All trademarks are acknowledged. Trademarks may be registered in some jurisdictions.
Home |
Updated on 07-Apr-08 | Copyright © 2005…2008 LA Solutions Ltd |