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

Concatenation tutorial

Started by makerimages, 24 December 2012 - 03:46 AM
makerimages #1
Posted 24 December 2012 - 04:46 AM
Concatenation- what it is and why do we need it
Con-cate-nati-on what a difficult word-what does it mean?

To put it short- concatenation is a way we can print out variables, do fs.something with the variables.

We need It to make our programs more flexible.

can you tell me more??

Yes I can, first things first- create a piece of code wich looks like this



term.clear();
fs.makeDir("/testfiles");
print("Please enter a directory name:")
local dirname= read("")

this cleares the window, Makes a directory called testfiles and prints a command.

AND THEN it creates a local variable called dirname and it reads the value of it from user input
Lets now make a directory in testfiles with the name of the dir we just specified, add this to the end of the last code


fs.makeDir("/testfiles"..dirname)
print("made a dir and called it"..dirname)

This now makes a directory inside testfiles and names it with the name we typed in before, it then shows a sentence that also has that name inside it. The .. are neccesary before the variable and the variable must be outside of the "". All other fs api functions should work the same way, textutils and write aswell.

Hope this helped, if you see a mistake or want me to make another tut on something, feel free to say so in the comments below.

Kind regards, makerimages
Doyle3694 #2
Posted 24 December 2012 - 05:10 AM
It's a good tutorial, though abit missleading. concatenation is the thing we use to put 2 variables together to make a new variable. You also forgot to mention concatenated variables always are strings. Also, abit missleading ending your lines with semi-colons
makerimages #3
Posted 24 December 2012 - 05:22 AM
; are a good coding practice

The rest will be added tomorrow when Im at my Pc this was originally written on my phone.
Orwell #4
Posted 24 December 2012 - 05:28 AM
; are a good coding practice
Got a source for that? :P/> It's just rendundant really. :P/>
Doyle3694 #5
Posted 24 December 2012 - 05:37 AM
Writing a tutorial about something this small, that even though is covered by the tutorial that is 1 step under yours, seems pretty, not useless, but unnessesary. especially writing a tutorial on your phone wont increse the tutorial quality.
PixelToast #6
Posted 24 December 2012 - 06:58 AM
; are a good coding practice
not really
its just another whitespace character
an enter or a space is good enough
ChunLing #7
Posted 25 December 2012 - 01:50 AM
Meh, some people like them, I personally do not.

But if you're going to use them, do it consistently.
makerimages #8
Posted 25 December 2012 - 02:42 AM
Alright, enough of that I will revamp the tutorial in a few days time…