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!

IF statement which test a variable text string?

Status
Not open for further replies.

GrayIntel

Mechanical
Feb 9, 2012
11
I am having difficulty with the following IF scenario:

IF PTC_MATERIAL_NAME=(==?)STEEL (material steel & aluminum have been assigned in setup, as have the steel & alum spring rates as variable values)
SPRING_RATE=SPRING_RATE_STEEL
ELSE
SPRING_RATE=SPRING_RATE_ALUMINUM
ENDIF

I realized my syntax is bad with the initial IF statement, so what should it be if you don't mind responding? IF PTC_MATERIAL_NAME='STEEL' OR IF PTC_MATERIAL_NAME=="STEEL" or something similar.

Thanks....Mark
 
Replies continue below

Recommended for you

IF PTC_MATERIAL_NAME=="STEEL"
This should be the format for the initial iF.


"Wildfires are dangerous, hard to control, and economically catastrophic."

Ben Loosli
 
Thanks Ben; it worked when I placed entire IF statement as 1 line, but ElSE(& nothing else) had to be on its own line with the condition/equality to follow on the next line....if this makes any sense.

Mark
 
Yes, that is the way it works :)

IF <parameter1> == "string1"
<parameter2> = "string2"
ELSE
<parameter2> = "string3"
ENDIF

string# could also be numeric values.


"Wildfires are dangerous, hard to control, and economically catastrophic."

Ben Loosli
 
thanks very much Ben. 1056 instances of a generic (spring)worked very well for different materials.

Mark
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor