Home > Community > Forums > Custom IC SKILL > How to convert integer to string?

Email

* Required Fields

Recipients email * (separate multiple addresses with commas)

Your name *

Your email *

Message *

Contact Us

* Required Fields
First Name *

Last Name *

Email *

Company / Institution *

Comments: *

 How to convert integer to string? 

Last post Mon, Jul 15 2013 9:33 AM by skillUser. 10 replies.
Started by latha 29 Jan 2010 04:17 PM. Topic has 10 replies and 7798 views
Page 1 of 1 (11 items)
Sort Posts:
  • Fri, Jan 29 2010 4:17 PM

    • latha
    • Not Ranked
    • Joined on Fri, Dec 4 2009
    • Posts 9
    • Points 225
    How to convert integer to string? Reply

     Hi,

    Can anybody let me know skill the function how to convert integer to string?

    Ex: a=123 (integer)

    I need

    a="123" (string)

     

    Filed under:
    • Post Points: 65
  • Fri, Jan 29 2010 5:19 PM

    Re: How to convert integer to string? Reply
    sprintf(a "%d" a)
    • Post Points: 5
  • Fri, Jan 29 2010 8:27 PM

    • babji
    • Top 500 Contributor
    • Joined on Thu, Apr 23 2009
    • hyderabad, Andhra Pradesh
    • Posts 24
    • Points 360
    Re: How to convert integer to string? Reply

     pcExprToString should work as well.

    • Post Points: 5
  • Fri, Jan 29 2010 9:46 PM

    • skillUser
    • Top 10 Contributor
    • Joined on Fri, Sep 19 2008
    • Austin, TX
    • Posts 2,567
    • Points 15,575
    Re: How to convert integer to string? Reply

     Hi,

    I think that Andrew's answer is the way to go, use sprintf().  You can perform further processing using the cdfFormatFloatString() function too:

    
      a = 123
      => 123
      formatted_a = cdfFormatFloatString( sprintf(nil "%d" a) "K")
      => "0.123K"
    

    Regards,

    Lawrence.

    • Post Points: 20
  • Sun, Jan 31 2010 12:50 PM

    • gheryiesan
    • Not Ranked
    • Joined on Sun, Jan 31 2010
    • <?xml version="1.0" encoding="utf-16"?><string>Chicago, IL</string>
    • Posts 1
    • Points 5
    Re: How to convert integer to string? Reply

     oh..its really works well..

    • Post Points: 5
  • Thu, Mar 18 2010 10:08 AM

    • pvvikas
    • Not Ranked
    • Joined on Sat, Feb 6 2010
    • Posts 1
    • Points 20
    Re: How to convert integer to string? Reply
    Thank you so much Lawrence. This is exactly what I wanted. I needed to label output of a decoder as "row0", "row1" ..etc. Thanks Vikas
    Filed under:
    • Post Points: 20
  • Thu, Mar 18 2010 7:33 PM

    • Peach99
    • Top 500 Contributor
    • Joined on Thu, Jul 30 2009
    • Posts 27
    • Points 435
    Re: How to convert integer to string? Reply

    Another question: How can I convert string to integer like this: "pmos"  to  pmos ???

    Regards

    Daniel Pietsch

    • Post Points: 20
  • Thu, Mar 18 2010 7:38 PM

    Re: How to convert integer to string? Reply

    Daniel,

    Sorry, that doesn't make sense. "pmos" is a string, but pmos is not an integer. What are you actually trying to do? I could tell you how to convert a string to a symbol, but I'm not sure that's what  you actually want?

    Regards,

    Andrew.

    • Post Points: 35
  • Thu, Mar 18 2010 7:56 PM

    • Peach99
    • Top 500 Contributor
    • Joined on Thu, Jul 30 2009
    • Posts 27
    • Points 435
    Re: How to convert integer to string? Reply

    I know that my statemant was wrong and I have found the correct function (stringToSymbol) I think! Thank you all the same!

    Regards

    Daniel Pietsch

    • Post Points: 5
  • Mon, Jul 15 2013 7:56 AM

    • DonWP9
    • Not Ranked
    • Joined on Tue, May 14 2013
    • Posts 1
    • Points 20
    Re: How to convert string to symbol? Reply

    Hi Andrew,

    How do you convert a string to a symbol or w_windowId?  I am using Ocean and want to make the w_windowId variable in the hardCopy command from strings I created. This way I can change the windowId with my program based on other variables.  I do not see the stringToSymbol function as described by another user.

     var = "window1"

    convertering steps to make "window1" to window1 (symbol or windowId)

    HardCopy(window1)

    Thanks for your help.

    Don

    • Post Points: 20
  • Mon, Jul 15 2013 9:33 AM

    • skillUser
    • Top 10 Contributor
    • Joined on Fri, Sep 19 2008
    • Austin, TX
    • Posts 2,567
    • Points 15,575
    Re: How to convert string to symbol? Reply

    Hi Don,

    The stringToSymbol function is a core SKILL function, so it is available in OCEAN.  You could also choose to use concat() for converting a string to a symbol - concat does not complain if you pass it either a string or a symbol, so it may be a little more flexible than stringToSymbol, depending on your usage of the function.

    In your post you mention "window1" - I'm used to seeing window id's like window:5 but perhaps yours is different because it is a waveform window?  However, if you have a window id like window:5 you can use the window function to return such an id, e.g.

    
    window(5)
    => window:5
    

    I hope this helps!
    Best regards,
    Lawrence.

    • Post Points: 5
Page 1 of 1 (11 items)
Sort Posts:
Started by latha at 29 Jan 2010 04:17 PM. Topic has 10 replies.