Hi,
I normally use some sequence structures to do hardware initialization before the main body of the program.
So I would have a sequence with 3 frames. In the first one initialize the hw, the second one would contain the normal function mode and the third, closing references and hw control, ...
About the structure you use, I find it a little strange, but don't take this as a critic to your programming mode.
You have all those while loops, with a case structure and all of them controlled by the same variable.
So when you press that button, all your while loops will go to measuring mode.
Apparently you are allways measuring everything when messung is true.
So if you had only one while loop it would work the same way, better yet, if messung is a button, you could put everything in the event structure and measure everything when the event messung - mouse down happens and you don't need all those while loops.
Also the stop could be made by that event structure.
Hope this helps,
Paulo