Author Topic: I need help again.  (Read 1548 times)

0 Members and 1 Guest are viewing this topic.

Offline Augs

  • LV6 Super Member (Next: 500)
  • ******
  • Posts: 306
  • Rating: +30/-29
    • View Profile
I need help again.
« 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>)

Offline Jim Bauwens

  • Lua! Nspire! Linux!
  • Editor
  • LV10 31337 u53r (Next: 2000)
  • **********
  • Posts: 1881
  • Rating: +206/-7
  • Linux!
    • View Profile
    • nothing...
Re: I need help again.
« Reply #1 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 ;)

Offline Augs

  • LV6 Super Member (Next: 500)
  • ******
  • Posts: 306
  • Rating: +30/-29
    • View Profile
Re: I need help again.
« Reply #2 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?

Offline Jim Bauwens

  • Lua! Nspire! Linux!
  • Editor
  • LV10 31337 u53r (Next: 2000)
  • **********
  • Posts: 1881
  • Rating: +206/-7
  • Linux!
    • View Profile
    • nothing...
Re: I need help again.
« Reply #3 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.

Offline Augs

  • LV6 Super Member (Next: 500)
  • ******
  • Posts: 306
  • Rating: +30/-29
    • View Profile
Re: I need help again.
« Reply #4 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.