This is a read-only snapshot of the ComputerCraft forums, taken in April 2020.
DaWooShit's profile picture

How to shorten a string

Started by DaWooShit, 02 November 2012 - 07:42 PM
DaWooShit #1
Posted 02 November 2012 - 08:42 PM
How do I shorten a string?

Ex:
string="thisisaprettylongstringindeed"
string=shorten(string,6)
print(string)
>thisis

Thanks in advance.
Cruor #2
Posted 02 November 2012 - 08:46 PM
as in remove everything besides the 6 first?
str = string.sub(str, 1, 6)
DaWooShit #3
Posted 02 November 2012 - 09:09 PM
Thanks a lot, works perfect.