• Skip to main content
  • Skip to search
  • Skip to footer
Cadence Home
  • This search text may be transcribed, used, stored, or accessed by our third-party service providers per our Cookie Policy and Privacy Policy.

  1. Community Forums
  2. Custom IC SKILL
  3. Compare list items in if condition.

Stats

  • Locked Locked
  • Replies 3
  • Subscribers 143
  • Views 17175
  • Members are here 0
This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Compare list items in if condition.

gs748
gs748 over 10 years ago

Hello,

I am running issues while comparing below 2 list items. can you please help me identify the bug.

pline = '( "State" "4" "time")
    i=length(pline)
    item3 = nth(i-1 pline)
    item2 = nth(i-2 pline)
    item1 = nth(i-3 pline)

line = '("4" "Done")
     len_line=length(line)
     item5=nth(len_line-1 line)
     item4=nth(len_line-2 line)

if( (item2 == item4); compare fails and executes else part but if condition should pass as item2 & item4 has "4"!
    then
    lista = list(item1 item2 item3 item4 item5)

else

   item5 = "UNKNOWN"
   lista = list(item1 item2 item3 item4 item5)
 );end if 

printf("List is %L\n" lista)

  • Cancel
Parents
  • Andrew Beckett
    Andrew Beckett over 10 years ago

    Given that you're just comparing strings here (the parseString is going to produce lists of strings, and using nth() will either give you one of those strings or nil if it was an entry that didn't exist), the most likely scenario is that the strings really are NOT equal. == doesn't lie. The one case that causes confusion is where you are comparing floating point numbers, because you may have rounding errors which make two numbers look the same bit actually differ by a tiny amount, smaller than the printing resolution. That's not the case here.

    You've not provided the data, or shown an example of the data that produces the problem. So expecting the community to debug it is a bit optimistic! Your previous cut-down example didn't even have a problem at all (I would have expected you to try it before you posted it)...

    As a wild guess, maybe there is a space in one of the values  you've read but not in the other - you've got different delimiters in the files being read, but maybe there are other differences? Try printing them out - in your code you're not even printing item9 to check it. Or use the SKILL debugger (in the SKILL IDE in IC615/IC616) and put a breakpoint just before the condition and then  you can inspect the local variables in the CIW.

    It's highly unlikely (I'd say that with 100% certainty) that either == or if() are doing anything wrong here - it'll be your data that is different. When debugging, always look for the most likely scenario - if a conditional statement or == were wrong in a language that has been around for so long, it would break all sorts of code, so that's not very likely to have such a fundamental problem.

    Kind Regards,

    Andrew.

    • Cancel
    • Vote Up 0 Vote Down
    • Cancel
Reply
  • Andrew Beckett
    Andrew Beckett over 10 years ago

    Given that you're just comparing strings here (the parseString is going to produce lists of strings, and using nth() will either give you one of those strings or nil if it was an entry that didn't exist), the most likely scenario is that the strings really are NOT equal. == doesn't lie. The one case that causes confusion is where you are comparing floating point numbers, because you may have rounding errors which make two numbers look the same bit actually differ by a tiny amount, smaller than the printing resolution. That's not the case here.

    You've not provided the data, or shown an example of the data that produces the problem. So expecting the community to debug it is a bit optimistic! Your previous cut-down example didn't even have a problem at all (I would have expected you to try it before you posted it)...

    As a wild guess, maybe there is a space in one of the values  you've read but not in the other - you've got different delimiters in the files being read, but maybe there are other differences? Try printing them out - in your code you're not even printing item9 to check it. Or use the SKILL debugger (in the SKILL IDE in IC615/IC616) and put a breakpoint just before the condition and then  you can inspect the local variables in the CIW.

    It's highly unlikely (I'd say that with 100% certainty) that either == or if() are doing anything wrong here - it'll be your data that is different. When debugging, always look for the most likely scenario - if a conditional statement or == were wrong in a language that has been around for so long, it would break all sorts of code, so that's not very likely to have such a fundamental problem.

    Kind Regards,

    Andrew.

    • Cancel
    • Vote Up 0 Vote Down
    • Cancel
Children
No Data

Community Guidelines

The Cadence Design Communities support Cadence users and technologists interacting to exchange ideas, news, technical information, and best practices to solve problems and get the most from Cadence technology. The community is open to everyone, and to provide the most value, we require participants to follow our Community Guidelines that facilitate a quality exchange of ideas and information. By accessing, contributing, using or downloading any materials from the site, you agree to be bound by the full Community Guidelines.

© 2025 Cadence Design Systems, Inc. All Rights Reserved.

  • Terms of Use
  • Privacy
  • Cookie Policy
  • US Trademarks
  • Do Not Sell or Share My Personal Information