5 posts
Posted 19 October 2012 - 12:30 PM
Thank you guys!
521 posts
Location
Stockholm, Sweden
Posted 19 October 2012 - 01:09 PM
If you want it to write
local c = "input"
then you'll have to type
h:write("local c = "input"")
Otherwise if you want it to write
local c = --whatever input is equal to
then you'll have to type
h:write("local c = "..input)
So in your case you go with the last suggestion.
It's important to have two dots (
..) between your syntaxes.
To make it simple:
5 + 10
-- will return 15
5 .. 10
-- will return 510
5 + "dollars"
-- will return an error
5 .. "dollars"
-- will return "5dollars"
"Hello" + "World"
-- will return an error
"Hello" .. "World"
-- will return "HelloWorld"
5 posts
Posted 19 October 2012 - 01:36 PM
Ty
1111 posts
Location
Portland OR
Posted 19 October 2012 - 01:36 PM
You don't need the concatenate it to get it to work. The ..'s are not needed you can use a , as well.
h:write("local c = ",input)
Just remember not to put quotes around vars when you are handling them.
5 posts
Posted 19 October 2012 - 01:51 PM
how i can choose in what line it goes?
2088 posts
Location
South Africa
Posted 19 October 2012 - 02:31 PM
how i can choose in what line it goes?
What do you mean? Like if it goes onto a new line?
If you want something to on a new line with only using one print/write use n (starts a new line)
715 posts
Posted 19 October 2012 - 02:35 PM
how i can choose in what line it goes?
term.setCursorPos(x, y)
See "help term" for more.*Derp*, sorry.
See my next post.
Edited on 19 October 2012 - 01:29 PM
5 posts
Posted 19 October 2012 - 03:15 PM
how i can choose in what line it goes?
What do you mean? Like if it goes onto a new line?
If you want something to on a new line with only using one print/write use n (starts a new line)
if i use
h = io.open("startup","a")
h:write("text")
the text will go in end of startup code but i want that it will be in the second line.
715 posts
Posted 19 October 2012 - 03:28 PM
[…]
if i use
h = io.open("startup","a")
h:write("text")
the text will go in end of startup code but i want that it will be in the second line.
I think you can't go to a specific line when writing a file, especially not when in append-mode.
You could work around this though by reading all the content of a file into a variable, then iterate over the lines of this variable until you reach the line you want to edit.
Now overwrite it with the new content and finally write the content of the variable (which contains all of the old content plus your changes) into the the new file, this time using the "write" mode to overwrite everything.
And sorry for my misunderstanding earlier. That was my derp for the month (hopefully).^^
5 posts
Posted 19 October 2012 - 03:35 PM
[…]
if i use
h = io.open("startup","a")
h:write("text")
the text will go in end of startup code but i want that it will be in the second line.
I think you can't go to a specific line when writing a file, especially not when in append-mode.
You could work around this though by reading all the content of a file into a variable, then iterate over the lines of this variable until you reach the line you want to edit.
Now overwrite it with the new content and finally write the content of the variable (which contains all of the old content plus your changes) into the the new file, this time using the "write" mode to overwrite everything.
And sorry for my misunderstanding earlier. That was my derp for the month (hopefully).^^
Okay, thanks for your help anyway.
8543 posts
Posted 19 October 2012 - 03:57 PM
When your question is solved, please do NOT destroy the original question and title. If you feel any change is necessary, simply prepend [solved] to your title and leave everything else alone. This allows your question to still be searched, so that others with the same/a similar question can find it and have their question answered without needing to post the question again.