Jump to content

Converting integer to string atoi


Recommended Posts

Hello. I am trying to get the integer value from my rbd piece names "piece0", piece1", piece3", etc . and convert that into a string

I am trying to do this based on what the help card has said:

int  atoi(string str)

i@nameInt= atoi(s@name);

Am I not doing this correctly? this will return 0 

Any help would be appreciated. thank you. 


Link to comment
Share on other sites

@Atom Thank you for the response Atom. That makes sense now. I can't help but ask a few follow up questions.  

So as you mentioned, my name attribute in this case has the same length prefix which is making it easy to isolate the integer for the atoi function.

So if I had a different name attribute with a longer length prefix then it will return 0 if I were to use the same expression .

My question is , how would I automatically detect the length of the name prefix to always isolate the integer at the end ?

My first thought would be to find the length of the string using the len function..

i@nameInt= atoi(s@name[@mylen:]);

But this of course wont work because that will find the length of the string including the integers. 

Is there anything else I should be looking into to achieve this ?

Thank you

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Create New...