• 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. Allegro X PCB Editor
  3. String Business in SKILL

Stats

  • Replies 6
  • Subscribers 165
  • Views 16497
  • Members are here 0
More Content

String Business in SKILL

nimoster
nimoster over 13 years ago

Hi Guys

I have some problems processing strings in SKILL. Basically I want to break a string into a list of substrings using "!" as delimiter. I found out that the "parseString"-command will do the job. But if one property is missing in the string, the parseString-command just ignores it. I better give you an example:

My string looks like that: "C419!100n!C0603!Murata!PartNo123"

In this case partseString works perfectly and puts each property in a own list field. But if e.g. the manufacturer property is not present and the string looks like this "C419!100n!C0603!!PartNo123" the parseString command interprets the "!!" as one delimiter. In this case I would have expected the funktion to generate a field with an empty string. But it doesn't, it just ignores it :-( So depending on the database entries I get lists with varying length which makes postprocessing more complicated.

Does anybody of you have an idea of a better solution or a workaround?

Thanks,
Martin

 

 

  • Cancel
  • Sign in to reply
  • aCraig
    aCraig over 13 years ago

     Try this:

    ;*******************************************************************************
    /*+
    NAME:  CAL_shrParseString

    FUNCTION:
      CAL_shrParseString(t_string [t_delimeter] [b_dappend])
        => l_strings/nil

    SYNOPSYS:
      This function takes a string as input and a list of
      delimiter characters then returns a list of substrings.
      The difference between this command and parseString is
      that parseString will not return "empty" fields.

    NEEDS:
      t_string      string to be parsed
      [t_delimeter] a sting of character delimiters. If not delimiters are
                    specified a whitespace character is used.
      [b_dappend]   if t appends the delimiter to the end of the substring

    RETURNS:
      l_strings     the resultanting list of substrings
      nil           on error

    EXAMPLE:

      CAL_shrParseString("ABC||DEF|GEHI" list("|")
        => ("ABC" "" "DEF" "GEHI")
      CAL_shrParseString("NOW IS THE TIME" list(" "))
        => ("NOW" "IS" "THE" "TIME")
      CAL_shrParseString("NOW IS THE TIME list(" ") t)
        => ("NOW " "IS " "THE " "TIME ")

    -*/
    defun(CAL_shrParseString (string @optional (delimiters " ") dappend)
      let((delimiterList parsedString (subString "") char incr )
     
      ;check for good variables
      if(stringp(string) && stringp(delimiters) then

        ; build a list of delimiters
        incr=0
        while(char = getchar(delimiters ++incr)
          delimiterList = cons(char delimiterList)
        )

        ; walk the string, separating substrings at the delimiters
        incr = 0
        while(char = getchar(string ++incr)
          if(member(char delimiterList) then
            ; found a delimiter, add substring to list and reset it.
            when(dappend
              subString = strcat(subString char)
            )
            parsedString = tconc(parsedString subString)
            subString = ""
          else
            ; append character to substring
            subString = strcat(subString char)
          )
        )
        ; add final substring
        parsedString = car(tconc(parsedString subString))

      else
        ; oops bad variables
        error("CAL_shrParseString"
          sprintf(nil "Parameters are not valid strings -- string:%L delimiters%L"
            string delimiters)
        )
      )
      parsedString
    ));CAL_shrParseString

     

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Cancel
  • nimoster
    nimoster over 13 years ago

    Wow, works perfectly. Many thanks!

    Greetings,
    Martin

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Cancel
  • andi2021
    andi2021 over 4 years ago

    Thanks for the info

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Cancel
  • andi2021
    andi2021 over 4 years ago in reply to andi2021
    [deleted]
    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Cancel
  • zxclord123
    zxclord123 over 3 years ago in reply to andi2021

    Two years ago, I thought to myself, "How wonderful and fascinating it is to be a student." But, sadly, that is not the case; I am pursuing a degree in civil engineering and rarely have free time, but I do like to unwind now and again. That's why I started looking at https://onlinefreelancejobs.net/civil-engineering-job/ these individuals for help. I now work here because I have all of the requirements, a flexible schedule, and the ability to work from anywhere. They come highly recommended from me.

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Cancel
>
Cadence Guidelines

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