• 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. Loading a directory to .cdsinit and looping through list...

Stats

  • Locked Locked
  • Replies 2
  • Subscribers 144
  • Views 15636
  • 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

Loading a directory to .cdsinit and looping through list of strings

snezana111
snezana111 over 9 years ago

Hi,

my initial idea was to load a directory of custom SKILL routines to .cdsinit

then I found out load function can't load a directory (like for instance you can do in EMACS with load function...)

so, I searched a bit through examples and saw that people load custom .il/.ils routines by loading up a single loadSkill.il file which contains then a list of load(...) functions...

Then I wanted to make the loadSkill.il file with a procedure that actually reads the files in the specified directory and then loads them up...

For that purpose I've dug up the getDirFiles(t_path) function so I get my list of files as strings

What I wanted to do was to filter through that list of strings and remove the directories and "." and ".."

But for some reason when I use foreach function on that list of strings - the first element is skipped.

for example:

routines = getDirFiles(getShellEnvVar("SKILLDIR"))

foreach(element routines

unless(rexMatchp(".il$" element) || rexMatchp(".ils$" element) remd(element routines))

);foreach

routines = ("practice_SKILL" "cleanFrame.il" "test.il" "dummy.test" "123test" "toplevel.ils")

=> ("practice_SKILL" "cleanFrame.il" "test"il" "toplevel.ils")

I've tried with if's and for's too... when I get them right, for some reason the first string element in that list prevails.

So I have two questions:

Is there a better way to load a directory of custom SKILL routines to .cdsinit?

And what am I doing wrong with strings here?

  • Cancel
  • berndfi
    berndfi over 9 years ago

    Setof is the filter function for SKILL list which you could apply and overwrite the initial variable "routines" with a new value.

    routines = setof(element routines (rexMatchp(".il$" element) || rexMatchp(".ils$" element)))

    Nevertheless you could also do all at once and filter and load through the foreach loop

    skillDir = getShellEnvVar("SKILLDIR")
    routines = getDirFiles(skillDir)
     foreach(element routines
          when(rexMatchp(".il$" element) || rexMatchp(".ils$" element)
               load(strcat(skillDir "/" element))
         )
     )

    • Cancel
    • Vote Up 0 Vote Down
    • Cancel
  • Andrew Beckett
    Andrew Beckett over 9 years ago

    The original code didn't work because you must use the return value of remd() - because otherwise the variable routines is still pointing at the original first entry in the list. You cannot just call remd() for its side effects (at least not safely). I have covered this in other posts on the forums.

    A simple way of finding all the files would be to do:

    routines=pcreMatchList("\\.ils?$" getDirFiles(skillDir))

    That will match all .il and .ils files in the directory. I used pcreMatchList because it offers a more powerful regular expression syntax than the "rex" equivalent (PCRE is the Perl-Compatible-Regular-Expression library).

    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