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

Two questions

Started by anonimo182, 09 October 2012 - 04:30 PM
anonimo182 #1
Posted 09 October 2012 - 06:30 PM
I have two questions:

1.How can I turn a letter into a number?

2. How can I count the number of files listed by fs.list()?

Thanks
PixelToast #2
Posted 09 October 2012 - 06:42 PM
what do you mean turn a letter into a number?
if you want to get the ascii value of it you can use string.byte(char)
if you want to turn a string like "3123" into a number you can do number operations with you can use tonumber(string)

fs.list returns a table, you can check the size of that table by putting a # infront it

files=fs.list()
number_of_files=#files -- or just use #files in the expression you use it
anonimo182 #3
Posted 09 October 2012 - 09:01 PM
the problem with that is that I tried it, but it was the same result if for example "hello" and "obis"