I'm having my first try at porting existing V8i apps to CONNECT. The first problem I've encountered is that much of my code will do things like this:
valueP = mdlSystem_expandCfgVar ( "$(MSDIR)config\\mslocal.cfg" );
If the string might contain a UNC path I also use mdlSystem_extExpandCfgVarNoFmt() to expand a string with embedded configuration variables. These two functions are no longer available in the SDK.
I get that the Connect SDK now automatically does an expansion of the variable as part of mdlSystem_getCfgVar(), however I need to expand a user-defined string that may or may not have one or more embedded configuration variables in it. I assume that mdlSystem_getCfgVar() would fail on such a string, since it won't match an existing variable.
Is there a workaround for this, and why were these functions removed? The ConfigurationManager structure does not seem to have this missing functionality either. I just want to expand a string that may contain one or more nested variables.
Cheers.
How about the following replaced code ?
WString cfgValue; ConfigurationManager::GetVariable(cfgValue, L"MSDIR"); cfgValue.AppendA("config\\mslocal.cfg"); mdlDialog_dmsgsPrint(cfgValue.GetWCharCP());
--Piers PorterAltiva Software
We have two or three functions that expand a configuration variable...
There are several methods of ConfigurationManager that deal with CfgVars, but only one ConfigurationManager::GetVariable() that Piers and I can see that gets the value of a CfgVar.
Pier's question is this: given a string that includes embedded CfgVars, how do I get its expanded value in CONNECT?
Example 1: "$(MSDIR)config/appl/"
Using mdlSystem_extExpandCfgVarNoFmt() that would expand to something like "C:\Program FIles(x86)\Bentley\MicroStation\config\appl\". That is, the function has substituted the expanded CfgVar into the string, retaining the literal text.
Example 2: "$(MSDIR)/config/database/$(MS_SERVER).cfg"
Using mdlSystem_extExpandCfgVarNoFmt() that would expand to something like "C:\Program FIles(x86)\Bentley\MicroStation\config\database\oracle.cfg". That is, the function has made two substitutions of expanded CfgVar values.
How do we do that in CONNECT? Has that functionality been lost in the new API?
Regards, Jon Summers LA Solutions
Answer Verified By: Piers Porter
Hello Piers,
I have a good solution for this. You can firstly assign your string to a temporary configVar (such as MS_FOO) and then call GetVariable to expand it. Actually GetVariable can expand a string which contains some macros. Pls see my below test code:
WString cfgValue; ConfigurationManager::DefineVariable(L"MS_FOO", L"$(MSDIR)config\\mslocal.cfg"); ConfigurationManager::GetVariable(cfgValue, L"MS_FOO"); mdlDialog_dmsgsPrint(cfgValue.GetWCharCP());
I just found out this function does not handle UNC paths, as it truncates "\\" into "\".Some testing has revealed that the last argument "fmtExpansion" prevents this truncation. So anyone looking for an equivalent to V8i's mdlSystem_extExpandCfgVarNoFmt() can use msMacro_expandMacroExpression() with the last bool set to FALSE.