'TCL how to shorten sentence
I have a sentence let's say : {This is my test sentence} And I would like to shorten by 3 characters at the end like this : {This is my test sente}
Here is what I do in TCL language :
set sentence "This is my test sentence"
set remove "3"
set newSentence [string range $sentence 0 end-$remove]
and here is what I get : "This"
I've tried with
set sentence {This is my test sentence}
and it is even worth because I got an error message "failed: unmatched open brace in list"
Can someone have an idea where I am wrong ? Or may be how I can shorten a string whatever spaces inside it ? Thank you by advance for your help
Solution 1:[1]
Finally got it, I had to force it as a list :
set newSentence [list [string range $sentence 0 end-$remove]]
It seems my engine over interprete the output value.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | vech |
