Do you have some example of these to work with? General speaking whiles, ifs, etc are not exactly just merged together but contained, that is a block may contain another blocks, and a block is whatever starts with { and ends with }.
And beware with these blocks, because they define scopes for local variables. If a local variable has not been defined in a higher level block and it is used in an inner level block, this variable will be visible for that block, but will not be visible outside of that block. So, using private command to declare all the local variables that you want to be "usable" anywhere within your script is a good practice.