A bit of explanation about time values may be helpful here.
A time value in SenseTalk is (internally) a number, that usually has a display format associated with it. If you add or subtract a number from that value, it will retain its format. This lets you do things like this:
put the long date into dueDate
add 1 week to dueDate
put dueDate -- displays "Tuesday, January 27, 2009"
Here, the new dueDate is displayed in the long date format that was specified in the first line, although the actual value has been changed by a week.
On the other hand, if you subtract one time value from another you should simply get the difference between them (as a number of seconds), which you can see by extending the above example:
put the date into originalDate
subtract originalDate from dueDate
put dueDate -- displays "604800" (which is 1 week)
In your case, I’m guessing that in some parts of your code you borrowed from some old examples (that can still be found here and there on this forum) from the days when we recommended using “the long seconds” to time an operation. Nowadays we suggest that you simply use “the time”. Although this will display a value that only shows the hour and minute, internally it is a very precise value down to a small fraction of a second.
What I’m getting to with this long explanation is that if you mix the two styles, using both “the long seconds” and “the time”, you can get what appears to be a very different value. For example:
put the long seconds into startTime
wait a second
put the time into endTime
put endTime - startTime into elapsed
This example displays “05:00 PM” for me (this will vary depending on what time zone you are in) which clearly doesn’t look much like the elapsed time of a one-second operation! Changing the first line to “put the time into startTime” will display a number instead, like 1.000301 (one second plus the length of time it took to execute a couple of commands).
Hopefully this gives you a better understanding of why sometimes you may see a value that’s formatted as a time (like “12:34”) and sometimes as a number.
However, this doesn’t explain why you’re getting a “not a number” error. Although they look different, the value obtained either way should be a number. In my tests it worked fine to do something like “put elapsed rounded to 0 places” (which displays “1” as expected). If you continue to have trouble, you may need to post more details about exactly how you’re calling the function so we can see just what’s going on.