Continue to Site

Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

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

If then else length limit.

Status
Not open for further replies.

JurgenKreisel

Automotive
Feb 3, 2010
102
I believe that there is a length limit of 1024 characters when creating an expression with an if,then,else statement.
I also thought that there was a way to go beyond that by putting something at the end to have it look at another expression to continue the if,then,else statement.
Does anyone know how to accomplish that?

Thank you in advance
Regards
Jurgen
 
Replies continue below

Recommended for you

If you are looking through a list of values, have a look at Taylor Anderson's reply in thread561-412524. His technique may be of help.

www.nxjournaling.com
 
Not exactly what I was looking for but has made me relook at the expression and try something new.
Thanks.
 
Hi -

I Did back in time, exactly What you are asking for..Split a Long expression in multipe expressions..So Else if mechanism is just continueing in next Expression…

I Will see if I Can find my solution, and the Share with you….,
 
I found what I was looking for. At the end of the if statement you can have the else point to another expression.
The expression is named METRIC_BODY_Dia and it points to METRIC_BODY_Dia2 at the end. This then ideally continues the if statement.
Thanks to all for your input.

if(Screw_Size=3MM)(3.5MM)else(if(Screw_Size=4MM)(4.5MM)else(if(Screw_Size=5MM)(5.5MM)else(if(Screw_Size=6MM)(6.5MM)else(if(Screw_Size=8MM)(8.5MM)else(if(Screw_Size=10MM)(10.5MM)else(if(Screw_Size=12MM)(12.5MM)else(if(Screw_Size=14MM)(14.5MM)else(if(Screw_Size=16MM)(16.5MM)else(if(Screw_Size=20MM)(21MM)else((Metric_Body_Dia2)))))))))))


if(Screw_Size=24MM)(37.5MM)else(if(Screw_Size=30MM)(47.5MM)else(if(Screw_Size=36MM)(56.5MM)else(66MM)))
 
yes - exactly....
expression_conditional_iwkzpp.jpg
 
That is one ugly formula. Is there a string to value function such that:


[pre]
thread_value = STRING_TO_VALUE(LEFT(thread_string,length(thread_string)-2)) would take "5MM" and return 5.

Then:

if thread_value <- 16 then new_thread_value = thread_value + 0.5
if thread_value > 16 then new_thread_vale = thread_value +1.0


Alternatively, create a arrays
input[3, 4, 5, 6, ... 20] (this could be 3MM, 4MM, 5MM, ... so no string to value conversion is required.
output[3.5, 4.5, 5.5, 6.5 ... 21]

Then:

found = False
for i = 1 to length(input[])
if thread_value = input then found = True; item = i; exit loop (thread_value is either string or a number as extracted above.)
next i

if found = True then new_thread_value = output[item] else (Whatever is supposed to happen if there is no matching thread.[/pre]

The array method allows any combination of input to output mapping; it is easily flexible. The direct calculation method accepts any input, though that might not be desired, it doesn't require editing the program to add new values. Both are far better than the monster.
 
These were created about 12 years ago when we were first learning NX. At the time it worked and I am sure there are many better ways to get the same result. Once we created the parts that needed these types of if statements we have not created anything since then, until now when we ran into the 1024 character length limit.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor