i am making a program on my computer the first part of the program is print whats your name then the user puts in there name then i want to have it print welcome and then the name they put in.
this is what i have so far i don t no how to have it print what they typed i put ?? where i am confused on what to do
-----
print("hello whats your name")
--they type in there name here there name is printed in the next line
print("welcome --there name i dont no how to put that there plz help thank u")
reverting back to user input
Started by Crowdy199, Sep 06 2012 07:21 PM
12 replies to this topic
#1
Posted 06 September 2012 - 07:21 PM
#2
Posted 06 September 2012 - 07:25 PM
use the string.format function
name = read() print(string.format( " The name is %s ", name))
#3
Posted 06 September 2012 - 07:26 PM
thank u
#4
Posted 06 September 2012 - 07:28 PM
Use string concatenation, just do "string"..variable
so:
so:
print("Hello, what's your name?")
name = read()
print("Welcome,"..name)
#5
Posted 06 September 2012 - 07:30 PM
guys i got another quetion can i make it so that there name is saved into the code of a program called names automasticly when they type it
#7
Posted 06 September 2012 - 07:32 PM
yah just like that
#8
Posted 06 September 2012 - 07:35 PM
<Shameless Self Promotion>
Well, i've just released an API which helps you save data to a file, so you could use that for a quick solution:
Here
</Shameless Self Promotion>
Or you can read up on the fs API on the wiki and write your own functions to sort out the data
There
Well, i've just released an API which helps you save data to a file, so you could use that for a quick solution:
Here
</Shameless Self Promotion>
Or you can read up on the fs API on the wiki and write your own functions to sort out the data
There
#9
Posted 06 September 2012 - 07:43 PM
listen i suck at tekkit can u be more specfic and acutly type the code i need for this exact situation
#10
Posted 06 September 2012 - 07:45 PM
I'll give you a hand in a little when i'm not busy, but really, it's a much better idea to at least read through the docs on the wiki, or use somebody elses API, it'll help you get better.
#11
Posted 06 September 2012 - 07:46 PM
while true do
write("What is you're name: ")
name = read()
file = fs.open("filename", "w") open the file filename in write mode
file.writeLine(name) --Writes the variable name to the file filename
file.close() --Prevents it messing up
end
I belive that works
#12
Posted 06 September 2012 - 07:50 PM
it says on line 4 = expected
1 user(s) are reading this topic
0 members, 1 guests, 0 anonymous users












