×
INTELLIGENT WORK FORUMS
FOR ENGINEERING PROFESSIONALS

Log In

Come Join Us!

Are you an
Engineering professional?
Join Eng-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Eng-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Jobs

IF statement which test a variable text string?

IF statement which test a variable text string?

IF statement which test a variable text string?

(OP)
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

RE: IF statement which test a variable text string?

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

RE: IF statement which test a variable text string?

(OP)
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

RE: IF statement which test a variable text string?

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

RE: IF statement which test a variable text string?

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

Mark

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Eng-Tips Forums free from inappropriate posts.
The Eng-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Eng-Tips forums is a member-only feature.

Click Here to join Eng-Tips and talk with other members!


Resources