I am collecting 4 analog input voltages with programming in the PLC script.  Each sweep of the PLC reads the analog voltage and it displays on a meter.   
I would like to turn on recording to collect these values for 5 seconds.  
 I am thinking of a global variable startrecording = "on" could be set with the down script of a button on the screen.  Then the PLC script would be checking for the "on" state of that variable and begin building an array with the voltages for 5 seconds when "on". Then after 5 seconds, the PLC script would change the startrecording to "off".  
Now I would have the array ready to write to a file.  Is there a problem doing this all in the PLC script?  Should I put the file operations in the script of a button on the screen?  Can I pick up the array as a global variable from that button or should I create a function to pass the array?  Not sure just how to sort through all the possibilities to decide what is the best method.  It does not seem like a good idea to potentially slow down the PLC script doing file operations.
Thanks!