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

Functions?

Started by jtdavis99, 04 March 2012 - 09:43 PM
jtdavis99 #1
Posted 04 March 2012 - 10:43 PM
I was testing some stuff and decided I wanted to make a short program devoted to make sending/receiving messages over rednet easier. I figured it would be a function, but I'm very confused as to what they do. For example, if I made a print("Hello World!") function, would it show up as a program and run that function when I ran it? Thanks, very confused :unsure:/>/>
MysticT #2
Posted 04 March 2012 - 11:22 PM
Functions are blocks of code you can execute. You define them as follows:

function someFunction(param1, param2, ...)
    print("Hello, the parameters are: ", param1, param2)
end
And then you can call them in the program (it should be in the same file):

someFunction("a string", 123)