How can I make it wait for the ok button?
It asks the input field even before I presses ok if no USB drive is present. (multiple pop-ups)
--TODO Please insert code here.
if file.usbdriveexists() == 0 then --
display.prompt(display.BUTTONS_OK, "Please insert a USB flash drive into the front-panel USB port.")
display.waitevent()
delay(1.5) -- Wait some time for the USB to be mounted
end
if defbuffer1.n >0 and file.usbdriveexists() != 0 then
statsVar = buffer.getstats(defbuffer1)
desciption=display.input.string("Description",display.SFORMAT_ANY)
fileVar = file.open("/usb1/"..desciption..".csv", file.MODE_WRITE)
file.write(fileVar, "Mean:,"..statsVar.mean.."\n")
file.write(fileVar, "StdDev:,"..statsVar.stddev.."\n")
file.write(fileVar, "Min:,"..statsVar.min.reading.."\n")
file.write(fileVar, "Max:,"..statsVar.max.reading.."\n")
file.write(fileVar, "Relative Time, Reading,,"..desciption.."\n")
for i = 1, defbuffer1.n do
file.write(fileVar, defbuffer1.relativetimestamps[i]..","..defbuffer1.readings[i]..","..defbuffer1.units[i].. "\n")
end
file.close(fileVar)
beeper.beep(0.1, 1000) -- ready beep
else
beeper.beep(0.5, 100) -- fail beep
end
edit nevermind found it adding waitevent()
Script above to save custom .csv file (and faster, run script by pressing 'No Script' button)