I am trying to create an alarm clock that is set by the user using a pickerwheel widget. After the user sets the alarm time in the pickerwheel, a clock continuously checks whether the alarm time is equal to the actual time once per second using the ‘==’ operator. The problem is that the ‘==’ operator does not recognize that the alarm time (extracted from pickerwheel using the the getValues function) is the same as the actual time, when they are in fact equal. The following is a simplified version of my code which illustrates the problem:
local alarmTime = {}
local actualTime = {10, 30} – actual time is 10:30
–after setting picker wheel column one to “10” and column two to “30”:
local pickerValues = pickerWheel:getValues()
local alarmTime[1] = pickerValues[1].value
local alarmTime[2] = pickerValues[2].value
print( actualTime[1], actualTime[2] )
print( alarmTime[1], alarmTime[2] )
print( actualTime[1] == alarmTime[1] ) – returns true if values are equal and false if they are not
print( actualTime[2] == alarmTime[2] ) – returns true if values are equal and false if they are not
Output:
10
30
10
30
false
false
The above code returns “false” twice in the output window, indicating the values are not the same even though they print the same.
Any help or feedback in addressing this problem would be much appreciated!