I am trying to control which application and versions can be used on files. For example, we have several data sources that are ORD 10.10 and a few that are 10.12, so we have a mix of installations. I want to be able to test for the application and then version to either allow the opening of ORD files from ProjectWise.
My code looks like this:
%if $(_USTN_PRODUCT_FULLMARKETINGNAME) = "OpenRoads Designer CE - 2021 Release 1" %if $(_USTN_PRODUCT_VERSION_MAJOR) != "10" %error "Unsupported OpenRoads Designer version detected." %endif%else if $(_USTN_PRODUCT_FULLMARKETINGNAME) = "OpenRoads Designer CE - 2021 Release 2" %if $(_USTN_PRODUCT_VERSION_MAJOR) != "10" %error "Unsupported OpenRoads Designer version detected." %endif%else if $(_USTN_PRODUCT_FULLMARKETINGNAME) = "OpenRoads Designer CE - 2022 Release 3" %if $(_USTN_PRODUCT_VERSION_MAJOR) != "12" %error "Unsupported OpenRoads Designer version detected." %endif%else if $(_USTN_PRODUCT_FULLMARKETINGNAME) = "MicroStation CONNECT Edition" %if $(_USTN_PRODUCT_VERSION_MAJOR) != "16" %error "Unsupported MicroStation version detected." %endif%else if $(_USTN_PRODUCT_FULLMARKETINGNAME) != "MicroStation 2023" %error "No valid modelling engine found."%endif
This results in an illegal operator error on launch. Can someone please fill me in as to why this fails, and how I can change it to work as I need?
NOTE: This is testing, and depending on which data source this is implemented on, I'll remove the unnecessary ORD test.
Thank you!
Scott
The illegal operator error is because your %if statements are using a single =, to test for equality you need a ==
%if $(_USTN_PRODUCT_FULLMARKETINGNAME) == "OpenRoads Designer CE - 2021 Release 1"
Correcting all the %if will fix that error, however that won't fix the overall issue and that's because of a bug in ProjectWise Explorer managed workspaces:
There is an issue with the _USTN_PRODUCT_VERSION* variables in ProjectWise Managed workspaces. Configs are processed twice in a Managed Workspace - Once by ProjectWise Explorer where it runs through all the CSB and config files and generates a single config file to pass to the CADD product. Then that CADD product processes that single config file.
The first pass does all if/then/else and only puts the final results in the single config file it makes. If an %error is generated that error is a ProjectWise error and brings up a dialog box with the error in it.
During that ProjectWise Explorer pass some Predefined variables from newer Connect products are not actually available. This includes all the _USTN_PRODUCT_VERSION* variables. The way around this is to get the version from the registry instead.
I'll put my solution up shortly, have some fires to put out first.
Answer Verified By: Scott Turner
Here's a version of what I do:
_DYNAMIC_PRODUCT_VERSION_REGISTRY = ${registryread{"HKEY_CLASSES_ROOT\Installer\Dependencies\$(MS_PRODUCTCODEGUID)\Version"}} #returns format 00.00.00.00\ _DYNAMIC_PRODUCT_VERSION = lastdirpiece(C:\${_DYNAMIC_PRODUCT_VERSION_REGISTRY}) #return format 00.00.00.00, removes trailing slash _DYNAMIC_PRODUCT_VERSION_GEN_MAJ_MNR = basename(${_DYNAMIC_PRODUCT_VERSION}) #return format 00.00.00, removes build number _DYNAMIC_PRODUCT_VERSION_GEN_MAJ = basename(${_DYNAMIC_PRODUCT_VERSION_GEN_MAJ_MNR}) #return format 00.00, removes minor version number _CURRENT_VERSION_MAJOR = $(_ENGINENAME) $(_DYNAMIC_PRODUCT_VERSION_GEN_MAJ) _CURRENT_VERSION_MINOR = $(_ENGINENAME) $(_DYNAMIC_PRODUCT_VERSION_GEN_MAJ_MNR) %undef _VERSION_ALLOWED %if ($(_CURRENT_VERSION_MAJOR) == "MicroStation 10.16") || ($(_CURRENT_VERSION_MAJOR) == "MicroStation 10.17") || ($(_CURRENT_VERSION_MAJOR) == "MicroStation 23.00") _VERSION_ALLOWED = $(_CURRENT_VERSION_MAJOR) %endif %if ($(_CURRENT_VERSION_MAJOR) == "OpenRoadsDesigner 10.10") _VERSION_ALLOWED = $(_CURRENT_VERSION_MAJOR) %endif %if ($(_CURRENT_VERSION_MAJOR) == "OpenBridgeModeler 10.10") _VERSION_ALLOWED = $(_CURRENT_VERSION_MAJOR) %endif %if !defined(_VERSION_ALLOWED) %error $(_CURRENT_VERSION_MAJOR) is not supported by this workspace %endif
The beginning parts with the _DYNAMIC variables is from Bentley's Dynamic managed workspace It reads the full version number from the registry then strips it down to the major (xx.xx) and minor (xx.xx.xx).
I then prepend the engine name to the front of that and then do comparisons on that value. You could do this with a long %if %elseif %endif chain but I've found over the years that I screw those up and having dedicated %if blocks is easier to maintain.
_ENGINENAME variable is the short product name with no spaces. So just MicroStation, OpenRoadsDesigner, OpenRailDesigner, etc...
Kevin, THANK YOU!
I am reading through your code now and will give it a go shortly.You are a lifesaver!