Continue to Site

Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

  • Congratulations GregLocock on being selected by the Eng-Tips community for having the most helpful posts in the forums last week. Way to Go!

simple question

Status
Not open for further replies.

Pederator

Mechanical
Nov 23, 2012
45
Hello fellas,

I have got one simple question - is there in MC possibility to define a constant in such a manner (eg.):
p := r := 10

instead of writing this in two lines:
p := 10
r := 10

or
p := 10
r := p

?

I assume that p and r will always have the same value, but for readability of the further code I want to have a different names of these constants. So, must I write 2 lines?
 
Replies continue below

Recommended for you

I'm going to step out on a limb here and guess that you are trying to do something a lot more difficult than your example, because if it was just p and r, you've spent a life time of key-stroke savings in writing your post.

You can of course put them on the same line, but that doesn't answer the broader question. You could do it with a vector:

i:0,1;1
pr[i:10

That would let you use pr[0 and pr[1 Still takes two assignments, but if you wanted to assign a dozen variables with the same value it would work.

David Simpson, PE
MuleShoe Engineering

"Belief" is the acceptance of an hypotheses in the absence of data.
"Prejudice" is having an opinion not supported by the preponderance of the data.
"Knowledge" is only found through the accumulation and analysis of data.
The plural of anecdote is not "data"
 
My program is quite complex, but this doesn't matter. I was just curious if there is such a way of writing the input data (like p := r := 10). Such a "feature" would be very helpful, shortening the code and make it more clear. I don't want to deal with vectors in such a case. Anyway, thanks for reply.
 
Yes, you must write two lines. You can, however, do:
r:10
p:r

or vice-versa.

Mathcad is not intended to be a programming language, so many programming constructs are not appropriate for creating worksheets.

TTFN
faq731-376
7ofakss

Need help writing a question or understanding a reply? forum1529
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor