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 programming question.

Status
Not open for further replies.

hoots711

Structural
Jan 5, 2006
19
I have been looking all over the net and have been unable to accomplish something that would take 10 seconds in any programming language...HELP PLEASE

simply, I need to run multiple commands if a value is true or false.
Exampl

if H < 5

x=2
y=9
gg=567
h.3=h.9

If H > 5
x=42
y=93
gg=23567
h.3=h.7

I have seen the commen if function (Condition,TV,FV)
but have not been able to find a away to accomplish what I need to do without writing a if statement for every line.

I have so many lines that are based on conditions that it will be really really sloppy if I have to write a (if) for each line.

Can in any way I run a block of code using a if statement.

I have been looking all over the web and couldnt find an example/answer.
Thanks
 
Replies continue below

Recommended for you


z:2,9,567,h.9 (using ALt m)
z2: same idea
z:if(H>5,z1,z2)
x:z[0
y:z[1
gg:z[2
h.3:z[3

is an easy way to only write one 'if'. There is a shorter way, see if you can find it, that needs no 'if' statements at all.







Cheers

Greg Locock

Please see FAQ731-376 for tips on how to make the best use of Eng-Tips.
 
That's probably full of mistakes, for instance the first z should be a z1

Cheers

Greg Locock

Please see FAQ731-376 for tips on how to make the best use of Eng-Tips.
 
Thanks Greg. I think this will get me headed in the right direction
 
Ugggg, to use a if like this do all the items in the matrix have to be the same units of measure?

Im getting an error that units dont match when I populate the matrix with different forumals.

any ideas?
 
Yes, elements in a matric should have the same units

TTFN



 
Oh well, you'll have to do it another way.

Cheers

Greg Locock

Please see FAQ731-376 for tips on how to make the best use of Eng-Tips.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor