Omnimaga

Calculator Community => TI Calculators => Lua => Topic started by: Augs on September 05, 2012, 05:55:11 am

Title: I need help again.
Post by: Augs on September 05, 2012, 05:55:11 am
The description  says it. Is there any code for readin 1 letter off a whole line of letters.

Example,here is the C# one.

(<string>.Substring(<where to start reading>, <How many letters after that>)
Title: Re: I need help again.
Post by: Jim Bauwens on September 05, 2012, 07:53:20 am
Yup:

Code: [Select]
str = "My Name Is Jim"
print(str:sub(2,8))
print(string.sub(str, 2, 8))
Two ways to do it :)
Remember though, the first character is 1, not 0. (as in many other languages)
And, the second arg is the position where you want to stop.
More info here: http://lua-users.org/wiki/StringLibraryTutorial .

Also, you could just post in the other topic. There is no need to create a new one just for this ;)
Title: Re: I need help again.
Post by: Augs on September 05, 2012, 07:57:54 am
Yup:

Code: [Select]
str = "My Name Is Jim"
print(str:sub(2,8))
print(string.sub(str, 2, 8))
Two ways to do it :)
Remember though, the first character is 1, not 0. (as in many other languages)
And, the second arg is the position where you want to stop.
More info here: http://lua-users.org/wiki/StringLibraryTutorial .

Also, you could just post in the other topic. There is no need to create a new one just for this ;)

Thanks a lot. While your I'm at it. Do arrays exist in LUA?
Title: Re: I need help again.
Post by: Jim Bauwens on September 05, 2012, 08:01:02 am
You got tables.
Tables are like the most incredible thing ever :D
You can use them as arrays, dictionaries, anything. In fact, many stuff in Lua are based around tables.
Just check this out: http://lua-users.org/wiki/TablesTutorial.
Title: Re: I need help again.
Post by: Augs on September 05, 2012, 08:19:15 am
You got tables.
Tables are like the most incredible thing ever :D
You can use them as arrays, dictionaries, anything. In fact, many stuff in Lua are based around tables.
Just check this out: http://lua-users.org/wiki/TablesTutorial.
Thanks bro.