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

Printing a variable

Started by icecube45, 10 November 2012 - 04:10 PM
icecube45 #1
Posted 10 November 2012 - 05:10 PM
Let's say I would like to have code print a variable, like for example

print("enter a name:")
name = read()
print(name "was your name")
could I just do that? or is there some other way I have to do it
PixelToast #2
Posted 10 November 2012 - 05:11 PM
this belongs in the beta forum
and you have to concatenate the two things using the .. operator:
print(var.."something")
icecube45 #3
Posted 10 November 2012 - 05:12 PM
Ok, thanks. Im using it in a script to lock my computer, sorry for wrong section. fairly new to forums
Luanub #4
Posted 10 November 2012 - 05:13 PM
You dont have to concatenate it you can use a comma as well. And this is fine in ask-a-pro. I'm not sure what it has to do with beta??


print(var," Stuff")
PixelToast #5
Posted 10 November 2012 - 05:25 PM
You dont have to concatenate it you can use a comma as well. And this is fine in ask-a-pro. I'm not sure what it has to do with beta??


print(var," Stuff")
that only works with the print command
if you plan on doing something like

thing=var,"stuff"
it wont work
Luanub #6
Posted 10 November 2012 - 05:26 PM
Some functions work with the comma, others don't. This topic is about printing, which does work with a comma.