Hi
Is there a way to reduce a string length to a user specified number of characters using Visual Lisp?
Example Reduce “ABCDEFGH” to “DEFGH”
With the user specifying how many characters to trim?
John
|
Hi
Is there a way to reduce a string length to a user specified number of characters using Visual Lisp?
Example Reduce “ABCDEFGH” to “DEFGH”
With the user specifying how many characters to trim?
John
That's exactly it.
Something so simple.
Many Thanks
John
If you want to trim from the end of the string (instead of the start), then this should work:Code:(setq str "ABCDEFGH") (substr str 1 (- (strlen str) number))
Thanks Irneb,
I was trying all this vl-string-trim left and right and forgot all about the simple substr command.
I got it to work in the end anyway.
Many thanks
John
You're welcome!
I can understand your reasoning ... having programmed in several other languages, when I 1st saw it I also thought string-trim aha!
Although the AutoLisp (or rather VisualLisp) vl-string-trim is more like a string cleanup than a trim. Thankfully it is explained in the help though .
Help???????
www.augi.com is the best manual on the market.