• 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. Convert a complex list to a string, and back

Stats

  • Locked Locked
  • Replies 4
  • Subscribers 143
  • Views 20300
  • 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

Convert a complex list to a string, and back

RVERP
RVERP over 7 years ago

Hello,

Since cdf can't handle list, the solution is to convert this to a string.

But how do you convert a list of this type to a string, and back??

example = list("example")

example->values = list("values")

example->values->num1 = "one"

example->values->num2 = '("t" "w" "o")

example->values->num3 = 3

example->char = list("char")

example->char->char1 = "A"

example->char->char2 = '("B" "C")

  • Cancel
  • skillUser
    skillUser over 7 years ago

    Hi,

    You can perhaps use buildString() and parseString() to convert a list of strings into a single string and vice-versa. The 'glue' or separation character is a single space by default but you can enter a different character, e.g. "," or "|" or something that will not be used in an entry value. Note that for buildString the list elements should all be strings, so values like 'num3' would cause an issue.  Also, I'm not sure I completely follow your example, but perhaps take a look at buildString() and parseString() to see if they fit your needs.

    Best regards,

    Lawrence.

    • Cancel
    • Vote Up 0 Vote Down
    • Cancel
  • RVERP
    RVERP over 7 years ago in reply to skillUser

    Hi Lawrence,

    I can convert the list to a string, but converting it back to a list is a bit harder. The issues I have are:

    • How do I rebuild the nested lists?
    • For a list of this type, the are also elements with type symbol, how do rebuild those?

    The string I generate looks like this:

    "(|string example|symbol char|list (|string char|symbol char2|list (|string B|string C|)|symbol char1|string A|)|symbol values|list (|string values|symbol num3|fixnum num3|symbol num2|list (|string t|string w|string o|)|symbol num1|string one|)|)"

    • Cancel
    • Vote Up 0 Vote Down
    • Cancel
  • Andrew Beckett
    Andrew Beckett over 7 years ago in reply to RVERP

    Use linereadstring to convert from string to list, and sprintf(stringOut "%L" theList) to convert back from a list to a string. Or something along those lines...

    Andrew.

    • Cancel
    • Vote Up 0 Vote Down
    • Cancel
  • RVERP
    RVERP over 7 years ago in reply to Andrew Beckett

    Thanks Andrew, that did the trick.

    • Cancel
    • Vote Up 0 Vote Down
    • Cancel

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