ATTENTIONThis FlexSim Community Forum is read-only. Please post any new questions, ideas, or discussions to our new community (we call it Answers) at https://answers.flexsim.com/. Our new Question & Answer site brings a modern, mobile-friendly interface and more focus on getting answers quickly. There are a few differences between how our new Q&A community works vs. a classic, threaded-conversation-style forum like the one below, so be sure to read our Answers Best Practices. |
flexsim.com |
#1
|
|||
|
|||
IF with a String
Here's my code:
string NameItem= getname (item); int Itype= getitemtype (item); if (NameItem=="IWR AftCyl" && Itype==0) return 2; the IF never is true cause of the String in the code. I Must be missing something? However, the variable NameItem is correct.
__________________
"A bird is an instrument working according to mathematical law, which is within the capacity of man to reproduce." -Leonardo da Vinci, 1502 |
#2
|
|||
|
|||
NameItem=="IWR AftCycl" makes a new string in a new spot in memory with characters 'I','W','R',' ','A','f','t','C','y','c','l', and '\0' (a null terminated string). It then compares the locations in memory, which are never equal.
Use this instead: Code:
comparetext(NameItem,"IWR AftCycl") |
The Following 3 Users Say Thank You to Alex Christensen For This Useful Post: | ||
Jörg Vogel (07-15-2008) |