• 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. writing into output file

Stats

  • Locked Locked
  • Replies 10
  • Subscribers 144
  • Views 17183
  • 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

writing into output file

RAGHU2634
RAGHU2634 over 6 years ago

I have an input file\reference file . Based on a condition met in program I want to add prefix (# or ;)  before lines into output file using line number.

Thanks,

Raghu

  • Cancel
Parents
  • mbracht
    mbracht over 6 years ago

    Hi Raghu,

    Reading through a file and based on a condition prepending a comment characters to the lines is fairly easy:
    (let (from file)
       from = (infile "/tmp/test.il") ||
          (error "cannot open file...")
       (while (gets line from)
          (if <yourCondition>
             (println (strcat "# " line))
             (println line))))

    I don't understand though what you want to do with the line number, can you please elaborate on this

    Max

    • Cancel
    • Vote Up 0 Vote Down
    • Cancel
  • RAGHU2634
    RAGHU2634 over 6 years ago in reply to mbracht

    Hi Max,

    I want to add prefix using line numbers.Is this possible ?

    • Cancel
    • Vote Up 0 Vote Down
    • Cancel
  • Andrew Beckett
    Andrew Beckett over 6 years ago in reply to RAGHU2634

    Your questions are very poorly formed, and so a lot of guesswork is involved as to what you're really asking. I'm really surprised you cannot work out the answers if they are as simple as we're guessing they are.

    let((from to lineNum line)
      from=infile("input.txt")
      to=outfile("output.txt")
      lineNum=1
      ; no \n in the fprintf because gets leaves the \n in each line read
      while(gets(line from)
        if(lineNum>5  ; i.e. some condition
          fprintf(to "#%d %s" line)
        else
          fprintf(to "%s" line)
        )
      )
      close(from)
      close(to)
    )

    Andrew.

    • Cancel
    • Vote Up 0 Vote Down
    • Cancel
  • RAGHU2634
    RAGHU2634 over 6 years ago in reply to Andrew Beckett

    apologies Andrew.

    I will avoid asking simple things

    Thanks,

    Raghu

    • Cancel
    • Vote Up 0 Vote Down
    • Cancel
Reply
  • RAGHU2634
    RAGHU2634 over 6 years ago in reply to Andrew Beckett

    apologies Andrew.

    I will avoid asking simple things

    Thanks,

    Raghu

    • 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