• 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. Reading String from txt file

Stats

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

Reading String from txt file

frasheed
frasheed over 11 years ago

Hello All,

I am writing a short code to read Strings from a file.

Example of file that I want to read.

SAMPLE DATA

Name "Technology" "Version" "revision"

started "15july" "30july"

label "New" "Old"

and the code is

f = infile(my.txt)

while( str = lineread(f)
        case( car(str)
            ( Name               
                  Name = cdr(str)
             )                 
            );; end case

);; end while

Now after reading the values store in Name variable is ( "Technology" "Version" "revision"), and when I check the type for variable "Name" its showing me "list" but when I access any element using nth(0 Name) then its giving me ("Technology"), which is neither symbol nor string , I want it to be string without the paranthesis.

Any Good way to do that, I tried  pcExprToString command but its not giving me the desired output. 

Thanks

 

  • Cancel
Parents
  • Andrew Beckett
    Andrew Beckett over 11 years ago

    No it doesn't. nth(0 Name) will return "Technology". Or you could use car(Name):

    > Name
    ("Technology" "Version" "revision")
    > car(Name)
    "Technology"
    > cadr(Name)
    "Version"
    > nth(1 Name)
    "Version"
    > nth(2 Name)
    "revision"
    > nth(0 Name)
    "Technology"

    Presumably what you've done doesn't match what you've posted (after all your infile is missing quotes around the filename, so I'm assuming the code wasn't necessarily cut and pasted into the post).

    Regards,

    Andrew.

    • Cancel
    • Vote Up 0 Vote Down
    • Cancel
Reply
  • Andrew Beckett
    Andrew Beckett over 11 years ago

    No it doesn't. nth(0 Name) will return "Technology". Or you could use car(Name):

    > Name
    ("Technology" "Version" "revision")
    > car(Name)
    "Technology"
    > cadr(Name)
    "Version"
    > nth(1 Name)
    "Version"
    > nth(2 Name)
    "revision"
    > nth(0 Name)
    "Technology"

    Presumably what you've done doesn't match what you've posted (after all your infile is missing quotes around the filename, so I'm assuming the code wasn't necessarily cut and pasted into the post).

    Regards,

    Andrew.

    • 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