title: Lua script - collection data and save into a file
body: <p>I am working on coding lua script.</p>
  
  <p>What I am coding is..Collecting the data and save it into the certain file.</p>
  
  <p><em>Situation</em> :<br>
  There are two sensors that when they recognize the object in front of it, the value of the sensor will be increased.<br>
  I want to save the data of the value of sensor every 100ms with time.<br>
  Time format would be "2013-04-25 10:30:004"</p>
  
  <p>What I did is here.</p>
  
  <pre><code>===========================================================
  
  require("TIMER")
  require("TIMESTAMP")
  require("ANALOG_IN")
  
  function OnExit()
      print("Exit code...do something")
  end
  
  function main()
  
      timer = "TIMER"
      analogsensor_1 = "AIR_1"
      analogsensor_2 = "AIR_2"
  
      while true do 
          valueOfSensor_1 = ANALOG_IN.readAnalogIn(analogsensor_1);
          valueOfSensor_2 = ANALOG_IN.readAnalogIn(analogsensor_2);
  
          write(colltection_of_data.txt)
          go(print(valueOfSensor_1), 0.1)     //print value of sensor every 100ms
          print(time)
          go(print(valueOfSensor_2), 0.1)
          print(time)
      end 
      TIMER.sleep(timer,500)
  
  end 
  
  print("start main")
  main()
  
  ================================================================
  </code></pre>
  
  <p>I know it's not complete code. How can I save the data into certain file?
  and how can I show the time format like that?</p>
  
  <p>Thank you in advance!</p>