I was working on incorporating a new client's standards and was trying to idiot-proof our project setup files and ran into an issue that seems like it should have a one line solution, but I can't figure it out. After banging my head against a wall for quite some time trying to figure out how a variable that I was clearly defining was coming up as "Symbol '$(MY_VARIABLE)' is undefined", I finally realized that Microstation gives the same error message for defined variables with no value as it does for undefined variables. So then I started trying to figure out how to determine if the variable was blank so I could proactively set a value so the logic in the project setup won't bomb out when it hits a variable with a null value. Neither !defined or setting a variable's value with : work as the variable is technically defined, so I ended up doing the following, but it feels like a bit of a hack job:
_CHECK_EMPTY = $(MY_VARIABLE)EMPTY %if $(_CHECK_EMPTY) == "EMPTY"MY_VARIABLE = OHMYGODAVALUE! %endif
It seems like I should be able to go:
%if $(MY_VARIABLE) == ""
but I couldn't come up with a "null" expression that worked [""," ",null,(null),'null', ,'',[ ],etc.]. Anyone have any ideas? Thanks.
Timothy Hickman
CADD Manager | CADD Department
timothy.hickman@colliersengineering.com
Main: 877 627 3772|
1000 Waterview Drive Suite 201 | Hamilton, New Jersey 08691
Unknown said:if you clearly defined it, then something else is going on and I would be investigating that, not trying to put some hack catchall line in. Run a debug and look thru it to see what is happening. Looking at the screenshot Jon provided, it looks like his VBA is only telling you if it is defined or not, not where the problem is.
Sorry, to clarify, when I said it was clearly defined, I meant the following expression was being used:
MY_VARIABLE =
So the variable was defined, but it had no value. I'm trying to account for people not following directions when setting up a project.
Unknown said:ok - so you are allowing others to create and use configurations and on occasion they have defined a variable , but there is no value defined ? and you want to be able to see these ? or you want to define them if they are not set ?
The idea was to check the handful of variables we use once at the beginning of the script, and if it finds one that's 'null', give it a value,so I wouldn't have to check each variable in every %if statement in our project config individually. Which is what I'm currently doing with:
_CHECK_EMPTY = $(MY_VARIABLE)EMPTY%if $(_CHECK_EMPTY) == "EMPTY"MY_VARIABLE = OHMYGODAVALUE%endif
It's just that this feels like a kludge instead of being able to check directly if a variable is 'null'.