280 posts
Location
Earth
Posted 05 October 2012 - 02:48 AM
Is it possible to execute code in a loop for each character in a file?
864 posts
Location
Sometime.
Posted 05 October 2012 - 02:54 AM
What exactly do you mean?
Execute code..
In a loop..
Each character in a file?
8543 posts
Posted 05 October 2012 - 02:54 AM
for char in string.gmatch(file.readAll(), ".") do
42 posts
Location
New Zealand
Posted 06 October 2012 - 04:04 AM
Do you mean to execute different functions with their own key press? If so, then it's perfectly possible.
You can do something like this:
local event,p1 = os.pullEvent()
if event == "char" and p1 == "<key>" then
<function>
elseif <same as above with different key>
<function>
end
280 posts
Location
Earth
Posted 13 October 2012 - 02:14 AM
Do you mean to execute different functions with their own key press? If so, then it's perfectly possible.
You can do something like this:
I mean to read a file and then execute code for each char in the file as opposed to each line of a file.
42 posts
Location
New Zealand
Posted 13 October 2012 - 05:22 AM
Sounds simple enough, but probably not too simple. I think you could have a bunch of local variables for each character, and link those characters to functions.
871 posts
Posted 13 October 2012 - 05:25 AM
Do you mean to execute different functions with their own key press? If so, then it's perfectly possible.
You can do something like this:
I mean to read a file and then execute code for each char in the file as opposed to each line of a file.
yeeah… what lyqyd said does exactly that.