• 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. Using the "apply" SKILL function

Stats

  • Locked Locked
  • Replies 1
  • Subscribers 143
  • Views 2836
  • 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

Using the "apply" SKILL function

Curtisma
Curtisma over 6 years ago

Hello:

I am trying to use the "apply" skill function to allow a function to take any number of format arguments and pass them to sprintf to form a string.  However if one of those format arguements happens to be a list, it tries to evaluate it and if it is just 2 numbers this fails. 

How do I keep it from evaluating the list contained within the @rest pfArgs list?

; Append a line to the file
; Args
; txt: The txt object created by using the new function (DPL)
; line: A string to append as a new line of the text.
; It can include printf style format specifiers (%s, etc)
; @rest: Arguements for the format specifiers in line
; Returns: The contents
procedure(appendLine(txt line @rest pfArgs)
txt->contents = tconc(txt->contents apply('sprintf nil line pfArgs))

Problem is when I try to use the function with a list as one of the pfArgs.
txt->appendLine(txt "%L" list(1 2))

Gives:
*** Error in routine eval:
Message: *Error* eval: not a function - 1

This is similar to the following:
apply('sprintf nil "%L" list(list(1 2)))
*** Error in routine eval:
Message: *Error* eval: not a function - 1

I have seen this old post wheich confirmed the problem, but didn't help solve it.
community.cadence.com/.../confused-about-the-apply-operation

  • Cancel
  • Andrew Beckett
    Andrew Beckett over 6 years ago

    The good news is that there's (nowadays) a lambda form of the sprintf function which is suitable for use with funcall or apply. This form doesn't have the first argument - it only returns the string rather than sets the variable in the first argument - but you weren't using that anyway (you had nil). So you'd simply do:

    txt->contents = tconc(txt->contents apply('lsprintf line pfArgs))

    That will fix your problem.

    Regards,

    Andrew.

    • 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