Skip to main content
1-Visitor
August 9, 2012
Solved

Externally defined symbol and '#ifndef '

  • August 9, 2012
  • 12 replies
  • 8471 views

Hi all,

I am using OLE automation to excite my maths model with input data taken from a spreadsheet so using .SetValue, .Recalculate and .GetValue methods of the Worksheet class. For that reason I have added the name of the input variables right at the top pf the file without the := operator.

My problem is that I want my MathCad model to be also a standalone model where it will look if automation is active or not, and when not, it will have a local definition with :=

To do that in C, we would define a global symbol when in automation:

#define OLE_AUTOMATION

And then in the program we would add a conditional compilation branch

#ifndef OLE_AUTOMATION

int variable_input_x;

variable_input_x = y;

#endif

Is there any way of doing something similar in Mathcad?

Many thanks

Best answer by RichardJ

Is there any way of doing something similar in Mathcad?

Sort of. There is a way (although it is a kludge!) to trap an undefined variable: see the attached worksheet. That means you you can set up the worksheet to use the input variable if it's defined via the OLE interface, or a default value it it's not.

12 replies

RichardJ19-TanzaniteAnswer
19-Tanzanite
August 13, 2012

Is there any way of doing something similar in Mathcad?

Sort of. There is a way (although it is a kludge!) to trap an undefined variable: see the attached worksheet. That means you you can set up the worksheet to use the input variable if it's defined via the OLE interface, or a default value it it's not.

1-Visitor
August 14, 2012

That's great Richard, thank's a lot