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

1 answer

  • answered 2022-05-04 10:45 vech

    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.

How many English words
do you know?
Test your English vocabulary size, and measure
how many words do you know
Online Test
Powered by Examplum