Forum Discussion
tony_haynes_247
Nimbostratus
Oct 23, 2007convert string into an integer
I need to convert a variable string "mserver_number" that contains a number"string" into an integer. I need to take that integer so I can build a loop where my loop number starts as the "mserver_number". So if I have 1 - 10 and my mserver_number equals 3 my loop number starts at 3 and goes to 10. I found some information on Tcl_GetInt from the TCL reference. But seeing how I am not experienced in TCL I am unsure how to use it. So basically I want to take "mserver_number" string and convert it to "loop_number" integer
Thanks
1 Reply
- hoolio
Cirrostratus
Does your data literally look like mserver_2 or mswerver_10? And you're trying to parse that string to get just the digits after the underscore? If so, you can use getfield to split the string and take just the second field:set test_string mserver_9 set digit [getfield $test_string "_" 2] log local0. $digit
Recent Discussions
Related Content
DevCentral Quicklinks
* Getting Started on DevCentral
* Community Guidelines
* Community Terms of Use / EULA
* Community Ranking Explained
* Community Resources
* Contact the DevCentral Team
* Update MFA on account.f5.com
Discover DevCentral Connects