Monday, October 17, 2022

[FIXED] How to keep front whole number in Tcl

Issue

How to keep the first five integers in TCL? For example: set x 12058934562

I expect to get result 12058

Thanks in advance.


Solution

Treat the variable as a string and return the first five characters (which are expected to be integers):

string range $x 0 4
  --> 12058


Answered By - Chris Heithoff
Answer Checked By - Katrina (PHPFixing Volunteer)

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.