pre-setup() code, things like library callouts, variable declarations, pin assignments.
setup() code, which runs one
loop() code, which runs over and over
function()s which are called out by setup() or loop().
So, will you put your code in a function to have it run once in setup(), will you have the function run once in loop()with a flag to indicate it has run, or will you write it to run in-line in setup() or loop()? Those are pretty much the choices.
Actually the sketch is a c/CPP program in the background see
(Actually some one need to check how this forum works as I wrote a post that just disappeared, an it just showed me a create new thread instead) and by the way could the code pasted in code tags just be converted into ordinary text as the styles always go with it, I have to first copy the text to a text editor before posting here)