Is there a better way to check if a configuration variable is blank?

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.

Parents Reply Children
  • FlexiTable

    Unknown said:
    Thanks for the clarification about the freeware Configuration Variable Validator

    FlexiTable does an even better job.  Among its many capabilities, FlexiTable will harvest configuration variables and expand their values...

    When FlexiTable harvests configuration variables, it expands earch variable's value and validates that files and folder locations really exist.   For multi-path variableds, such as MS_RFDIR, it examines each path. It flags invalid variables by colouring them red, as shown in the screenshot.

     
    Regards, Jon Summers
    LA Solutions

  • I set what I call FLAG variables - these can tell me if certain sections of a CFG ran, on no uncertain terms and some of these I then use by running tests on their value. You can make them hidden so only you see them.
    Certain ones are in each client workspace CFG files but others allow me to confirm that a particular network resource was available during CFG processing.
    The benefit is that I know if the variable is defined and exists.

    Charles (Chuck) Rheault
    CADD Manager

    MDOT State Highway Administration

    • MicroStation user since IGDS, InRoads user since TDP.
    • AutoCAD, Land Desktop and Civil 3D, off and on since 1996
  • If you must have the variable defined correctly for the configuration to work as intended do you actually want it to proceed when an error is encountered? That seems like a bad idea to me.

    How about the following structure for each custom variable:

    MY_VARIABLE = ReplaceDefaultValue

    %if $(MY_VARIABLE) == "ReplaceDefaultValue"

    %error MY_VARIABLE must be given the correct value for the configuration to work properly

    %endif

    Produces this message in a text window:

    "MY_VARIABLE must be given the correct value for the configuration to work properly, [W:\SS6\PCF\ABD_TestProject.pcf], line 21"

    Any other value allows processing to proceed.

    Regards

    Marc